我只能说的亏没做,要不就挂0了。。

本来想四色定理,肯定4就可以的。。。然后准备爆,发现3的时候不好爆,又想了老一会,嗯,数据范围不小,应该不是暴力,直接找规律,貌似最大就是3,有一个3连块,输出3,其他输出2什么的。交,发现有环的时候,特殊的也是3。。。没办法还得暴力啊。暴力2的情况,写的也是各种错误。。。终于过了。

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
char p[][];
int o[][];
int mp[][],pre[];
int a[] = {,,,-,,-};
int b[] = {,-,,,-,};
int num = ;
int dfs(int x,int step)
{
int i;
for(i = ;i < num;i ++)
{
if(i == x) continue;
if(mp[x][i]&&pre[x] == pre[i])
{
return ;
}
else if(mp[x][i])
{
pre[i] = step% + ;
if(dfs(i,step+) == )
return ;
}
}
return ;
}
class HexagonalBoard
{
public :
int minColors(vector <string> board)
{
int i,j,k,n,flag;
n = board[].size();
for(i = ;i < n;i ++)
{
for(j = ;j < n;j ++)
{
if(board[i][j] == 'X')
o[i][j] = num ++;
}
}
for(i = ;i < n;i ++)
{
for(j = ;j < n;j ++)
{
if(board[i][j] != 'X') continue;
if(flag == ) flag = ;
for(k = ;k < ;k ++)
{
if(i + a[k] >= &&i + a[k] < n&&j + b[k] >= &&j + b[k] < n)
{
if(board[i+a[k]][j+b[k]] == 'X')
{
flag = ;
mp[o[i][j]][o[i+a[k]][j+b[k]]] = ;
}
}
}
}
}
if(flag == )
{
for(i = ;i < num;i ++)
{
if(!pre[i])
{
pre[i] = ;
if(dfs(i,) == )
return ;
}
}
return ;
}
else if(flag == )
return ;
else
return ;
}
};

TC SRM 593 DIV1 250的更多相关文章

  1. TC SRM 593 DIV1 250(dfs)

    这图最多3色就可以 搜2就行了 #include <iostream> #include<cstdio> #include<cstring> #include< ...

  2. Topcoder SRM 643 Div1 250<peter_pan>

    Topcoder SRM 643 Div1 250 Problem 给一个整数N,再给一个vector<long long>v; N可以表示成若干个素数的乘积,N=p0*p1*p2*... ...

  3. SRM 595 DIV1 250

    挺简单的组合把. #include <cstdio> #include <cstring> #include <iostream> #include <vec ...

  4. SRM 594 DIV1 250

    可能开始宿舍比较乱,思绪静不下来...想了大半个小时,终于确定了应该暴力+DP,然后写了枚举除数,和被除的版本..这样,还敲错了个字母,第一次提交还100多,修改提交还有75.多,最后想到,貌似不打对 ...

  5. TC SRM 593 DIV2 1000

    很棒的DP,不过没想出,看题解了..思维很重要. #include <iostream> #include <cstdio> #include <cstring> ...

  6. 最小公倍数 SRM 661 Div1 250: MissingLCM

    Problem Statement The least common multiple (denoted "lcm") of a non-empty sequence of pos ...

  7. Topcoder SRM 698 Div1 250 RepeatString(dp)

    题意 [题目链接]这怎么发链接啊..... Sol 枚举一个断点,然后类似于LIS一样dp一波 这个边界条件有点迷啊..fst了两遍... #include<bits/stdc++.h> ...

  8. TC srm 673 300 div1

    TC srm.673 300 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 Description 给你n(n<=50)匹马和n个人,一匹马和一个人能 ...

  9. SRM 583 DIV1

    A 裸最短路. class TravelOnMars { public: int minTimes(vector <int>, int, int); }; vector<int> ...

随机推荐

  1. Delphi之DLL知识学习4---创建DLL

    下面是在Delphi中创建一个DLL的全过程,你将看到怎样创建一个接口单元,使之可以被其他的应用程序访问.并且将学会怎么把Delphi的窗体加入DLL中. 一.数美分:一个简单的DLL 下面是包含一个 ...

  2. linux命令**50

    1.ls命令 命令格式: ls [选项] [目录名] 命令功能: 列出目标目录中所有的子目录和文件. 常用参数: -a,列出所有文件包括隐藏文件 -l,列出详细信息,文件大小一般以字节大小显示 -h, ...

  3. test1.A[【dfs简单题】

    Test1.A Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 sdut 2274:http://acm.sdut.edu.cn/ ...

  4. 游戏主循环(Game Loop)

    游戏主循环是游戏的心跳,一般使用while循环进行主动刷新. 一次循环由获取用户输入.更新游戏状态.处理AI.播放音乐和绘制画面组成. 这些行为可以分成两类: update_game(); // 更新 ...

  5. 手机WEB自适应头部代码

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> < ...

  6. 虚拟机通过NAT方式与主机、互联网通信

    1.首先配置物理主中机VMnet8的IP信息 主机物理IP为192.168.3.9

  7. [译]:Orchard入门——安装Orchard

    原文链接:Installing Orchard 文章内容基于Orchard 1.8版本 安装Orchard的方式 主要有以下四种方式安装Orchard: 利用Microsoft Web Platfor ...

  8. HDU 3341 Lost's revenge(AC自动机+DP)

    Lost's revenge Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)T ...

  9. filter应用案例二:权限控制

    filter可以用来进行权限控制,比如admin文件夹下的文件只允许管理员进入,那么,可以给admin文件夹加上一个过滤器: 简单代码示例: import java.io.IOException; i ...

  10. 使用openface(linux)

    在github上搜索openface,clone下来; 按照requirement.txt中安装需要的项: sudo apt-get install .... sudo pip install ... ...