Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
一次AC。。模拟筛选#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int grid[21][21]={0}; int dir[4][2]={{0,1},{1,0},{1,1},{-1,1}}; int main() { int t; int m=0; int i,j; int k; scanf("%d",&t); while(t--) { for(i=1;i<=19;++i) { for(j=1;j<=19;++j) scanf("%d",&grid[i][j]); } for(i=1;i<=19;++i) { for(j=1;j<=19;++j) { if(grid[i][j]==0) continue; for(k=0;k<=3;++k) { int x=i-dir[k][0]; int y=j-dir[k][1]; if(grid[i][j]==grid[x][y]) continue; else { x=i,y=j; for(m=1;m<=4;++m) { x+=dir[k][0];y+=dir[k][1]; if(grid[i][j]!=grid[x][y]) break; } if(m==5) { x+=dir[k][0];y+=dir[k][1]; if(grid[i][j]==grid[x][y]) continue; else break; } } } if(k<=3) break; } if(j<=19) break; } if(i<19) { cout<<grid[i][j]<<endl; cout<<i<<" "<<j<<endl; } else cout<<"0"<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator