我只能说的亏没做,要不就挂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中的接口和抽象类

    参考:http://blog.csdn.net/xinzheng_wang/article/details/6058643 接口:Interface Delphi中接口中的关键字Interface,但 ...

  2. 【openGL】四面体

  3. 关于strcpy_s

    #include"stdafx.h" #include<iostream> #include<cstring> int main() { using nam ...

  4. git branch用法总结

    git branch      git branch 不带参数:列出本地已经存在的分支,并且在当前分支的前面加“*”号标记,例如:   #git branch* master   newbranch ...

  5. 解决oracle11g 空表不能exp导出的问题

    在使用exp备份数据库,然后使用imp导入的时候出现了好多表或者视图不存在的错误信息. 究其原因,是11G中增加了一个新的特性:数据条数是0时不分配segment,所以就不能被导出. 解决思路:就是向 ...

  6. thinkphp计划任务使用cronRun

    thinkphp计划任务使用cronRun .先不管是是否是独立分组,必须在你项目名下的Conf文件夹内创建2个文件一个是tages.php 一个是 crons.php. 注意这两个文件名为think ...

  7. [UI]实用案例--Shape绘制实用圆圈

    Android允许通过xml定义资源,常见的事string,id,integer,dimen等,也可以定义一些图片资源,比如用来做几何的矢量图就非常好用,其中有许多的细节问题,具体需求可以再结合goo ...

  8. android用户界面详尽教程实例

    android用户界面详尽教程实例 1.android用户界面之AlarmManager教程实例汇总http://www.apkbus.com/android-48405-1-1.html2.andr ...

  9. HTML Entity Sets - All

    http://www.htmlentities.com/html/entities/ The view below displays the characters used in the offici ...

  10. Java学习笔记(三)——运算符

    一.运算符: 1.分类: 2.java中的运算符 (1)其中,++在左,表示先加了再用,++在右,表示先用了再加. (2)% 用来求余数,也称为"取模运算符" 3.赋值运算符 4. ...