POJ2302
简单题。
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
const int maxn = ;
int mat[ maxn ][ maxn ];
bool vis[ maxn ][ maxn ];
bool appear[ ];
struct node{
int x,y;
}num[ ]; void init(){
memset( appear,false,sizeof( appear ) );
memset( vis,false,sizeof( vis ) );
vis[][] = true;
} bool judge(){
int cnt;
for( int i=;i<=;i++ ){
cnt = ;
for( int j=;j<=;j++ ){
if( vis[i][j]==true )
cnt++;
else
break;
}
if( cnt== ) return true;//row
cnt = ;
for( int j=;j<=;j++ ){
if( vis[j][i]==true )
cnt++;
else
break;
}
if( cnt== ) return true;//col
}
cnt = ;
for( int i=;i<=;i++ )
if( vis[i][i]==true )
cnt++;
else
break;
if( cnt== ) return true;//dia
if( vis[][]==true&&vis[][]==true&&vis[][]==true&&vis[][]==true )
return true;
return false;
} int main(){
int n;
scanf("%d",&n);
while( n-- ){
init();
for( int i=;i<=;i++ ){
if( i!= ){
for( int j=;j<=;j++ ){
scanf("%d",&mat[i][j]);
num[ mat[i][j] ].x = i;
num[ mat[i][j] ].y = j;
appear[ mat[i][j] ] = true;
}
}
else{
for( int j=;j<=;j++ ){
scanf("%d",&mat[i][j]);
num[ mat[i][j] ].x = i;
num[ mat[i][j] ].y = j;
appear[ mat[i][j] ] = true;
}
for( int j=;j<=;j++ ){
scanf("%d",&mat[i][j]);
num[ mat[i][j] ].x = i;
num[ mat[i][j] ].y = j;
appear[ mat[i][j] ] = true;
}
}
}
int ans = ;
int in_num;
bool flag = false;
//printf("input\n");
for( int i=;i<=;i++ ){
scanf("%d",&in_num);
if( flag==false ) ans++;
if( appear[ in_num ]==true ){
vis[ num[ in_num ].x ][ num[ in_num ].y ] = true;
if( judge()==true ){
flag=true;
}
}
}
printf("BINGO after %d numbers announced\n",ans);
}
return ;
}
POJ2302的更多相关文章
随机推荐
- iis7 php urlrewrite 并隐藏index.php
<rewrite> <rules> <rule name="OrgPage" stopProcessing="true"> ...
- jQuery+php实现ajax文件即时上传
很多项目中需要用到即时上传功能,比如,选择本地图片后,立即上传并显示图像.本文结合实例讲解如何使用jQuery和PHP实现Ajax即时上传文件的功能,用户只需选择本地图片确定后即实现上传,并显示上传进 ...
- CCLablettf读取显示xml文件内容显示中文
CCDictionary *strings = CCDictionary::createWithContentsOfFile("tips2.xml"); const char *h ...
- React组件生命周期过程说明【转】
实例化 首次实例化 getDefaultProps getInitialState componentWillMount render componentDidMount 实例化完成后的更新 getI ...
- scala的REPL shell的调用
最近突然对spark的spark-shell发生了兴趣 它是如何启动scala的REPL的,并且在此前写入了常用的环境变量的呢? 通过查看spark的源码,找到了SparkILoop.scala im ...
- 比较ASP生成静态HTML文件的几种方法
将动态页面转换生成静态Html文件有许多好处,比如生成html网页有利于被搜索引擎收录(特别是对接受动态参数的页面).前台访问时,脱离了数据访问,减轻对数据库访问的压力,加快网页打开速度. 当然,凡事 ...
- 多个html编辑器在同一页面加载
http://127.0.0.1:3750/test.aspx 下载:ckfinder,ckeditor编辑器 <script type="text/javascript" ...
- ACM——直接插入法排序
NOJ——1062 直接插入排序 时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte 总提交:446 测试通过:212 ...
- sorted函数
我们需要对List.Dict进行排序,Python提供了两个方法对给定的List L进行排序,方法1.用List的成员函数sort进行排序,在本地进行排序,不返回副本方法2.用built-in函数so ...
- JQuery里的原型prototype分析
在 JavaScript 中,每个函数对象都有一个默认的属性 prototype,称为函数对象的原型成员,这个属性指向一个对象,称为函数的原型对象,当我们每定义了一个函数的时候,JavaScript ...