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 |
Re:测试数据-对应输出In Reply To:测试数据-输入 Posted by:langx at 2010-10-07 16:25:55 1 3 2 0 1 8 3 0 2 2 2 1 19 1 2 15 19 ------------------------- Problem: 1970 User: langx Memory: 200K Time: 0MS Language: C++ Result: Accepted ------------------------- #include <iostream> #include <cstdlib> using namespace std; int t,renju[20][20]; bool TestConsecutive(int l,int u){ int p, q, player = renju[l][u]; q = u; while( ++q < 20 && renju[l][q] == player && q - u < 7); if(q - u == 5 && (u == 1 || (u > 1 &&renju[l][u - 1] != player))) return true; p = l; while( ++p < 20 && renju[p][u] == player && p - l < 7); if(p - l == 5 && (l == 1 || (l > 1 &&renju[l - 1][u] != player))) return true; q = u;p = l; while( --p > 0 && ++q < 20 && renju[p][q] == player && q - u < 7); if(q - u == 5 && (l == 19 || u == 1 ||(l < 19 && u > 1 && renju[l + 1][u - 1] != player))) return true; q = u;p = l; while( ++p < 20 && ++q < 20 && renju[p][q] == player && p - l < 7); if(p - l == 5 && (l == 1 || u == 1 ||(l > 1 && u > 1 && renju[l - 1][u - 1] != player))) return true; return false; } int WhoWon(int &ix,int &jx){ for (int i = 1; i < 20; ++i ) { for (int j = 1; j < 20; ++j ) { if(renju[i][j] && TestConsecutive(i,j)){ ix = i; jx = j; return renju[i][j]; } } } return 0; } int main(){ int i, j, k; scanf("%d",&t); while ( t-- ) { for ( i = 1; i < 20; ++i ) { for ( j = 1; j < 20; ++j ) { scanf("%d",&renju[i][j]); } } k = WhoWon(i,j); printf("%d\n",k); if( k != 0) printf("%d %d\n",i,j); } system("pause"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator