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 |
纯暴力,hiahiahia#include <cstdio> #include <iostream> #include <cstring> #include <algorithm> using namespace std; int map[20][20]; int main() { //freopen("input.txt", "r", stdin); int T; int tmp, flag; scanf("%d", &T); while (T --) { for (int i = 1; i <= 19; i ++) { for (int j = 1; j <= 19; j ++) { scanf("%d", &map[i][j]); } } flag = 0; for (int i = 1; i <= 19; i ++) { if (flag) break; for (int j = 1; j <= 19; j ++) { if (flag) break; if (map[i][j]) { tmp = map[i][j]; if (((j+1<=19) && map[i][j+1] == tmp) && ((j+2<=19) && map[i][j+2] == tmp) && ((j+3<=19) && map[i][j+3] == tmp) && ((j+4<=19) && map[i][j+4] == tmp) && (j+5>19 || map[i][j+5] != tmp) && (j-1<=0 || map[i][j-1] != tmp)) { printf("%d\n", tmp); printf("%d %d\n", i, j); flag = 1; } else if (((i+1<=19) && map[i+1][j] == tmp) && ((i+2<=19) && map[i+2][j] == tmp) && ((i+3<=19) && map[i+3][j] == tmp) && ((i+4<=19) && map[i+4][j] == tmp) && (i+5>19 || map[i+5][j] != tmp) && (i-1<=0 || map[i-1][j] != tmp)) { printf("%d\n", tmp); printf("%d %d\n", i, j); flag = 1; } else if (((i+1<=19 && j+1<=19) && map[i+1][j+1] == tmp) && ((i+2<=19 && j+2<=19) && map[i+2][j+2] == tmp) && ((i+3<=19 && j+3<=19) && map[i+3][j+3] == tmp) && ((i+4<=19 && j+4<=19) && map[i+4][j+4] == tmp) && (i+5>19 || j+5>19 || map[i+5][j+5] != tmp) && (i-1<=0 || j-1<=0 || map[i-1][j-1] != tmp)) { printf("%d\n", tmp); printf("%d %d\n", i, j); flag = 1; } else if (((i-1>0) && (j+1<=19) && map[i-1][j+1] == tmp) && ((i-2>0) && (j+2<=19) && map[i-2][j+2] == tmp) && ((i-3>0) && (j+3<=19) && map[i-3][j+3] == tmp) && ((i-4>0) && (j+4<=19) && map[i-4][j+4] == tmp) && (i-5<=0 || j+5>19 || map[i-5][j+5] != tmp) && (i+1>19 || j-1<=0 || map[i+1][j-1] != tmp)) { printf("%d\n", tmp); printf("%d %d\n", i, j); flag = 1; } } } } if (flag == 0) { printf("%d\n", 0); } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator