ural 1221
本来就是个很水的题 就是枚举起点长度然后直接判断就行了 但是比赛的时候写了个大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的更多相关文章
- ural 1221. Malevich Strikes Back!
1221. Malevich Strikes Back! Time limit: 1.0 secondMemory limit: 64 MB After the greatest success of ...
- BZOJ 1221: [HNOI2001] 软件开发
1221: [HNOI2001] 软件开发 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1428 Solved: 791[Submit][Stat ...
- 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome
题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...
- ural 2071. Juice Cocktails
2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...
- ural 2073. Log Files
2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...
- ural 2070. Interesting Numbers
2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...
- ural 2069. Hard Rock
2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...
- 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 ...
- ural 2067. Friends and Berries
2067. Friends and Berries Time limit: 2.0 secondMemory limit: 64 MB There is a group of n children. ...
随机推荐
- Android之单选框
MainActivity继承Activity使用OnCheckedChangeListener接口: package com.cdp.checkbox; import android.app.Acti ...
- 百度ueditor编辑器背景不显示问题
网友办法:http://www.hongxuejing.com/hulianwang/ueditor_not_show_background-33.html 官方办法:http://fex-team. ...
- OC4_电子词典
// // MyDictionary.h // OC4_电子词典 // // Created by zhangxueming on 15/6/15. // Copyright (c) 2015年 zh ...
- [zz] 安装PostGIS(Linux篇)
0.安装PostgreSQL数据库 参考安装PostgreSQL数据库(Linux篇). 1.安装proj4 #tar zxvf proj-4.8.0.tar.gz#cd proj-4.8.0#./c ...
- windows 程序设计 SetPolyFillMode关于ALTERNATE、WINDING的详细解释
看windows程序第五章GDI编程部分.一直卡壳在这里了. 下面我来说下自己的想法.看是否对您有帮助. 首先我们来看一个图. SetPolyFillMode(ALTERNATE); // 系统默认 ...
- 从 Java 代码逆向工程生成 UML 类图和序列图
from:http://blog.itpub.net/14780914/viewspace-588975/ 本文面向于那些软件架构师,设计师和开发人员,他们想使用 IBM® Rational® Sof ...
- nginx gzip filter模块分析
API:http://refspecs.linuxbase.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/zlib-deflateinit2.html ...
- JQuery 解决 鼠标快速滑过后,会执行多次滑出的问题
如果用slideToggle,鼠标快速滑过后,滑进滑出很多次,要解决这个问题,用stop(false,true) $(".Nav_L").hover(function () { $ ...
- redis学习系列
redis学习系列 基本看完 最近在看redis的代码,简单记录下自己认为重要的点,自己写比较费时间的,我会把查到的资料贴出来方便查看 淘宝的redis内存分析 http://www.searchtb ...
- C# 在运行时动态创建类型
C# 在运行时动态的创建类型,这里是通过动态生成C#源代码,然后通过编译器编译成程序集的方式实现动态创建类型 public static Assembly NewAssembly() { //创建编译 ...