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的更多相关文章
随机推荐
- nvl()函数
Oracle里面的nvl()函数 Nvl(字段名,0):如果你某个字段为空,但是你想让这个字段显示0,nvl(字段名,0) ,就是当你选择出来的时候,这个字段虽然为空,但是显示的是0,当然这个0也可以 ...
- Socket知识总结
一.网络编程相关概念 1. 互联网通过ip定位电脑 2. 在电脑中通过port定位程序 3. 程序和程序之间通过协议定义通信数据格式 二.Socket相关概念 1. ip地址 1) 每台联网的电脑都有 ...
- Error:(6, 0) No such property: outputDir for class: org.gradle.api.internal.project.DefaultProject_Decorated
在学习greenDao过程中build.gradle文件中出现这个错误,找了半天不知道为什么.代码我是在git上下载的Demo,按理说应该是没问题的.到最后发现缺少了一个关键字Def // 这样有问题 ...
- linux命令 common 文件比较
比较已经排序的文件 comm [options] file1 file2 comm将逐行比较已经排序的两个文件.显示结果包括3列: 第1列为只在file1中找到的行;第2列为只在file2中找到的行; ...
- redirect_uri参数错误解决方法
坑,微信改来改去的,找死人了,以前在“开发者中心”中,现在改在”接口权限“中了.
- UDP 广播 Java
1.服务端 public class UdpBroadcastServer { /** * @param args */ public static void main(String[] args) ...
- 批处理 Mysql Findstr
@set Dump_IP=localhost @set User_Name=root @set Password=1234 @set curPath=%~dp0 mysql -h %Dump_IP% ...
- vJine.Core 0.3.0.49 正式发布
nuget: https://www.nuget.org/packages/vJine.Core/ oschina: http://git.oschina.net/vjine/vJine.Core/a ...
- TLF相关资料
1\(转)http://blog.csdn.net/hu36978/article/details/5796165 TFL 一般先创建TextFlow 通过控制flowComposer属性来控制文本 ...
- java.util.AbstractStringBuilder源码分析
AbstractStringBuilder是一个抽象类,是StringBuilder和StringBuffer的父类,分析它的源码对StringBuilder和StringBuffer代码的理解有很大 ...