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. ...
随机推荐
- Hibernate+DWR无刷新三级联动
DWR(Direct Web Remoting)是一个用于改善web页面与Java类交互的远程服务器端Ajax开源框架,可以帮助开发人员开发包含AJAX技术的网站.它可以允许在浏览器里的代码使用运行在 ...
- StrictMode模式介绍
最新的Android平台中(Android 2.3起),新增加了一个新的类,叫StrictMode(android.os.StrictMode).这个类可以用来帮助开发者改进他们编写的应用,并且提供了 ...
- 高性能CSS(一)
避免使用@import 有两种方式加载样式文件,一种是link元素,另一种是CSS 2.1加入@import.而在外部的CSS文件中使用@import会使得页面在加载时增加额外的延迟.虽然规则允许在样 ...
- MySQL数据库的登陆
MySQL数据库的登陆 MySQL是一种C/S结构. C/S(Client/Server)客户端/服务器 MySQL的客户端: 1.cmd客户端 2.可视化图形界面 3.php代码 登陆: MySQL ...
- LINQ中实现 In 与 Not In
T-SQL的IN: Select ProductID, ProductName, CategoryID From dbo.Products , ) T-SQL的NOT IN: Select Produ ...
- DEDECMS中,引入文件
引入文件:dede:include 标签:{dede:include filename="foot.htm"/}
- Linux防火墙基本知识
一.防火墙的分类 (一).包过滤防火墙. 数据包过滤(packet Filtering)技术是在网络层对数据包进行选择,选择的依据是系统内设置的过滤逻辑,称为访问控制表(access control ...
- php 实现 mysql数据表优化与修复
<?php $link = mysql_connect("localhost", "root", "") or die("e ...
- [译]线程生命周期-理解Java中的线程状态
线程生命周期-理解Java中的线程状态 在多线程编程环境下,理解线程生命周期和线程状态非常重要. 在上一篇教程中,我们已经学习了如何创建java线程:实现Runnable接口或者成为Thread的子类 ...
- iframe 刷新
iframe刷新父页面 parent.location.reload(); iframe 一个子页面操作过后,刷新指定子页面 parent.frames('ifrmname').location.re ...