本来就是个很水的题  就是枚举起点长度然后直接判断就行了   但是比赛的时候写了个大bug 还找不出来     自己太水了

#include <cstdio>
#include <cstring>
using namespace std; int g[110][110]; int findd(int len, int x, int y)
{
int k = (y+len+y)/2;
int r = 0;
for(int i = 0; i <= len; i++)
{
for(int j = 0; j <= len/2; j++)
{
if(j <= r)
{
if(g[x+i][k+j] == 1)
return 0;
if(g[x+i][k-j] == 1)
return 0;
}
else
{
if(g[x+i][k+j] == 0)
return 0;
if(g[x+i][k-j] == 0)
return 0;
}
}
if(i < len/2)
r++;
else
r--;
}
return len +1;
}
int main()
{
int n;
while(scanf("%d",&n) == 1 && n)
{
memset(g, 0, sizeof(g));
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
scanf("%d",&g[i][j]);
int ww = n;
if(ww%2)
ww--;
int dd = 0;
for(int i = ww; i >= 2; i -= 2)
{
for(int j = 1; j+i <= n; j++)
{
for(int k = 1; k+i <= n; k++)
{
dd = findd(i, j, k);
if(dd >= 3)
break;
}
if(dd >= 3)
break;
}
if(dd >= 3)
break;
}
if(dd >= 3)
printf("%d\n",dd);
else
puts("No solution");
}
return 0;
}

ural 1221的更多相关文章

  1. ural 1221. Malevich Strikes Back!

    1221. Malevich Strikes Back! Time limit: 1.0 secondMemory limit: 64 MB After the greatest success of ...

  2. BZOJ 1221: [HNOI2001] 软件开发

    1221: [HNOI2001] 软件开发 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1428  Solved: 791[Submit][Stat ...

  3. 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome

    题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...

  4. ural 2071. Juice Cocktails

    2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...

  5. ural 2073. Log Files

    2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...

  6. ural 2070. Interesting Numbers

    2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...

  7. ural 2069. Hard Rock

    2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...

  8. ural 2068. Game of Nuts

    2068. Game of Nuts Time limit: 1.0 secondMemory limit: 64 MB The war for Westeros is still in proces ...

  9. ural 2067. Friends and Berries

    2067. Friends and Berries Time limit: 2.0 secondMemory limit: 64 MB There is a group of n children. ...

随机推荐

  1. js前端防止默认表单提交

    代码如下: document.forms[0].onsubmit=function(){return false;};

  2. xheditor上传图片的java实现

    最近一个项目中因为框架的原因,很多文本编辑器都不兼容,最后找到xheditor,这个富文本编辑器的确不错,功能基本都能满足,只是上传图片的java接口需要自己写,因此,测试了两种方法,最终成功.分享给 ...

  3. 免费主机kilu使用

    我也是看了这篇文章:http://www.cnblogs.com/tenny/archive/2011/03/30/1999957.html 采取申请注册. 主机申请地址:http://www.kil ...

  4. Cocos2d-x中__Dictionary容器以及实例介绍

    __Dictionary类在Cocos2d-x 2.x时代它就是CCDictionary类,它是模仿Objective-C中的NSDictionary类而设计的,通过引用计数管理内存.__Dictio ...

  5. 生成 网站“面包屑” XML

    using System; using System.Collections.Generic; using System.IO; using System.Threading; using Syste ...

  6. easyui combobox 模糊检索数据并填充

    $("#id"),combobox({ url:'', ......   filter:function(q,row){ var op = $(this).combobox(&qu ...

  7. maven中scope参数说明

    官方说明文档地址https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Depen ...

  8. 算法 fill

    fill(vec.begin(), vec.end(),); //reset all elements to fill(vec.begin(),vec.begin + vec.size/, );//s ...

  9. MySql中,复制旧表结构到新表

    # 创建学生表 create table student(age int,name varchar(32))engine myisam charset utf8;insert into student ...

  10. Java多线程(六) 线程系列总结

    多线程系列终于终结得差不多,本人对该系列所做的总结大致如下: 线程锁模块耗费了大量的时间,底层的AQS实现比较复杂.仍然没有时间总结源码部分,能够坚持写下这么几个篇幅的内容真心佩服自己....希望继续 ...