1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
| #include <cstdio> #define maxN 2010 int r[maxN], c[maxN]; int a[maxN][maxN]; int main () { int n = 0, x = 0, y = 0; scanf("%d %d", &n, &x); if(x) { printf("1 1"); return 0; } for(int i = 2;i < n; i++) { scanf("%d", &c[i]); } scanf("%d", &a[1][n]); for(int i = 2;i <= n; i++) { if(i < n) { scanf("%d", &r[i]); } else { scanf("%d", &a[n][1]); } for(int j = 2;j <= n; j++) { scanf("%d", &a[i][j]); } } int cnt = 0, cntX = 0, cntY = 0, posX = 0, posY = 0; for(int i = 2;i < n; i++) { x = 0, y = 0; for(int p = 1;p <= n; p++) { x ^= a[p][i] ^ a[p][n]; y ^= a[i][p] ^ a[n][p]; } if(x != c[i]) { cnt++; posX = i, cntX++; } if(y != r[i]) { cnt++; posY = i, cntY++; } } if(cnt == 2 && posX && posY) { printf("%d %d", posY, posX); } else if(cntX == n - 2 && cntY <= 1) { if(!cntY) { printf("%d %d", 1, n); } else { printf("%d %d", posY, n); } } else if(cntY == n - 2 && cntX <= 1) { if(!cntX) { printf("%d %d", n, 1); } else { printf("%d %d", n, posX); } } else if(cntX == 1 && !cntY) { printf("%d %d", 1, posX); } else if(cntY == 1 && !cntX) { printf("%d %d", posY, 1); } else { printf("%d %d", n, n); } return 0; }
|