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. ...
随机推荐
- 第一次使用github很高端的赶脚
- 第九篇、微信小程序-button组件
主要属性: 注:button-hover 默认为{background-color: rgba(0, 0, 0, 0.1); opacity: 0.7;} 效果图: ml: <!--默认的but ...
- AutoPoco的使用
官方开发指导https://autopoco.codeplex.com/documentation 初步使用: SimpleUser是自己要批量创建的类 1)创建管理工厂 IGenerationSes ...
- web前端面试题收集(二)
简单介绍下你的前端代码开发与调试环境. Doctype声明的作用以及html4.01与html5中此声明的区别? 常用的块级元素与行内元素分别有哪些? 请画一下W3C盒模型 请写一个js函数,将url ...
- 【leetcode】365. Water and Jug Problem
题目描述: You are given two jugs with capacities x and y litres. There is an infinite amount of water su ...
- 2014-10 u-boot make xxx_defconfig 过程分析
/** ****************************************************************************** * @author Maox ...
- 从对偶问题到KKT条件
转自:http://xuehy.github.io/%E4%BC%98%E5%8C%96/2014/04/13/KKT/ 从对偶问题到KKT条件 Apr 13, 2014 对偶问题(Duality) ...
- fedora下python3 安装tkinter和pygame
root 下用 “yum search tkinter”,如下图所示: 然后再根据系统选择安装就好了. tkinter安装完毕. 接下来是安装pygame在fedora的python3上,我的是pyt ...
- spring heibernate 调用存储过程
一:参考网址 http://sunbin123.iteye.com/blog/1007556 二:示例 @Autowired @Qualifier("jdbcTemplate") ...
- JS 正则 获取URL参数
function getQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&] ...