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 |
暴力搜索只要一句有点长的逻辑判断就好 0ms#include<stdio.h> #include<string.h> int a[37][37], n, x, y, f, q,i,j; int main() { scanf("%d", &n); while (n--) { f = 0; memset(a, 0, sizeof(a)); for (i = 11; i < 30; i++) for (j = 11; j < 30; j++) scanf("%d", &a[i][j]); for (i = 11; i < 30; i++) for (j = 11; j < 30; j++) if (a[i][j])if ((a[i - 1][j] != a[i][j] && a[i][j] == a[i + 1][j] && a[i + 1][j] == a[i + 2][j] && a[i + 2][j] == a[i + 3][j] && a[i + 3][j] == a[i + 4][j] && a[i + 4][j] != a[i + 5][j]) || (a[i][j - 1] != a[i][j] && a[i][j] == a[i][j + 1] && a[i][j + 1] == a[i][j + 2] && a[i][j + 3] == a[i][j + 2] && a[i][j + 4] == a[i][j + 3] && a[i][j + 4] != a[i][j + 5]) || (a[i][j] != a[i - 1][j - 1] && a[i][j] == a[i + 1][j + 1] && a[i + 1][j + 1] == a[i + 2][j + 2] && a[i + 3][j + 3] == a[i + 2][j + 2] && a[i + 4][j + 4] == a[i + 3][j + 3] && a[i + 4][j + 4] != a[i + 5][j + 5]) || (a[i + 1][j - 1] != a[i][j] && a[i][j] == a[i - 1][j + 1] && a[i - 1][j + 1] == a[i - 2][j + 2] && a[i - 3][j + 3] == a[i - 2][j + 2] && a[i - 4][j + 4] == a[i - 3][j + 3] && a[i - 4][j + 4] != a[i - 5][j + 5])) f = a[i][j], x = i, y = j; else if (f) break; printf("%d\n", f); if (f) printf("%d %d\n", x - 10, y - 10); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator