本来就是个很水的题  就是枚举起点长度然后直接判断就行了   但是比赛的时候写了个大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. AIDL实现Android IPC

    1.AIDL文本解释 在软件工程中,接口定义语言(IDL)已经成为通用术语,是用来描述软件组件接口的特定语言.在Android中,该IDL被称为Android接口定义语言(AIDL),它是纯文本文件, ...

  2. 合理使用mysql中的load data infile导入数据

    基本语法: load data  [low_priority] [local] infile 'file_name txt' [replace | ignore]into table tbl_name ...

  3. rowid

    rowid:select t.*,t.rowid from test t; -- AACeJKAAIAAAA4XAAA 注:有个很二需求,通过一个存储过程插入的数据必须是放在一块的,不能分散开存储,考 ...

  4. display的小故事

    实在是想不出来到底整个什么题目好..姑且先整这个吧.. 本文不是讲解display这个牛逼css属性的(讲不好才是真的!),主要是分享一下一些小Tips. display:table-cell wid ...

  5. zz Release memory in Linux (Unused or Cached)

    In computer science, Memory Leakage occurs when a computer software or program consumes required mem ...

  6. CSMA-CA介绍

    本文主要介绍通讯领域中CSMA相关机制,本文全部资料来自于网络.   网络通讯,必须依靠介质来传递数据,将数据调制到模拟信号上,再把此信号通过介质传递到远方.根据介质的不同,分为有线网络和无线网络.为 ...

  7. C++与Lua交互(三)

    通过上一篇的热身,我们对C++调用lua变量有了一个认识,现在让我们再深入一点,去探索一下如何调用lua的函数.表. Lua与宿主通讯的关键--栈 lua是个动态脚本语言,它的数据类型如何映射到C++ ...

  8. PHP 魔术方法(所有的魔术方法)

    慢慢长寻夜,明月高空挂. 目前PHP所有的魔术方法有一下这些 __construct() __destruct() __call() __callStatic() __get() __set() __ ...

  9. 转:浅谈大型web系统架构

    浅谈大型web系统架构 动态应用,是相对于网站静态内容而言,是指以c/c++.php.Java.perl..net等服务器端语言开发的网络应用软件,比如论坛.网络相册.交友.BLOG等常见应用.动态应 ...

  10. android 软件开机自启动

    安卓的很多功能实现方式都是“Don't call me, I'll call you back!”,开机启动就是其中之一 步骤: 1.首先建立一个BroadcastReceiver, 2.在他的onR ...