제출 #18710

#제출 시각아이디문제언어결과실행 시간메모리
18710pichulia여왕벌 (KOI15_queen)C++98
68 / 100
5000 ms15964 KiB
#include<stdio.h> #include<algorithm> using namespace std; int m, n; char a[701][701][3][3][3]; int r[701][701]; char x[999]; int p[709]; int q[709]; void process() { int i0, i1, i2; int i, j, k, l; scanf("%d %d %d", &i0, &i1, &i2); // p = start of 1, q = start of 2 if (i0 + i1 < n) { p[0] = 0; q[0] = 0; } else if (i0 < n) { p[0] = 0; q[0] = n - i2; } else { p[0] = i0 - n + 1; q[0] = n - i2; } for (i = 1; i < n; i++) { int np, nq; np = p[i - 1]; nq = q[i - 1]; int si = 0; if (i0 + i1 < (n - i))si = 2; else if (i0 < (n - i)) si = 1; else si = 0; if (si == 0) { if (p[i - 1]> 0) // 0 0 0 x x x { if (p[i - 1] != q[i - 1]) // 0 0 0 1 1 1 2 2 2 { for (j = p[i - 1]; j < n && j < q[i - 1]; j++) { if (j == p[i-1] && a[i][j][0][0][1] == 1) break; else if (j > p[i - 1] && a[i][j][0][1][1] == 1) break; } if (j < q[i - 1]) { np = j; for (j = q[i - 1]; j < n; j++) { if (j == q[i-1] && a[i][j][1][1][2] == 2) break; else if (j > q[i - 1] && a[i][j][1][2][2] == 2) break; } nq = j; } else { if (j < n && a[i][j][0][1][2] == 1) { np = j; for (j = q[i - 1]+1; j < n; j++) { if (a[i][j][1][2][2] == 2) break; } nq = j; } else { for (j = q[i - 1]; j < n; j++) { if (j == q[i - 1] && a[i][j][0][1][2] == 2) break; else if (j > q[i - 1] && a[i][j][0][2][2] == 2) break; } nq = j; np = nq; } } } else // 0 0 0 2 2 2 { for (j = q[i - 1]; j < n; j++) { if (j == q[i - 1] && a[i][j][0][0][2] == 2) break; else if (j > q[i - 1] && a[i][j][0][2][2] == 2) break; } nq = j; np = nq; } } else if (q[i - 1] > 0) // 1 1 1 x x x { for (j = 1; j < n && j < q[i - 1]; j++) { if (a[i][j][0][1][1] == 1) break; } if (j < q[i - 1]) { np = j; for (j = q[i - 1]; j < n; j++) { if (j == q[i - 1] && a[i][j][1][1][2] == 2) break; else if (j > q[i - 1] && a[i][j][1][2][2] == 2) break; } nq = j; } else { if (j < n && a[i][j][0][1][2] == 1) { np = j; for (j = q[i - 1] + 1; j < n; j++) { if (a[i][j][1][2][2] == 2) break; } nq = j; } else { for (j = q[i - 1]; j < n; j++) { if (j == q[i - 1] && a[i][j][0][1][2] == 2) break; else if (j > q[i - 1] && a[i][j][0][2][2] == 2) break; } nq = j; np = nq; } } } else // 2 2 2 ... { for (j = 1; j < n; j++) if (a[i][j][0][2][2] == 2) break; nq = j; np = nq; } } // end of si == 0 else if (si == 1) { np = 0; if (q[i - 1] > 0) // 1 1 1 x x x { for (j = q[i - 1]; j < n; j++) { if (j == q[i - 1] && a[i][j][1][1][2] == 2) break; else if (j > q[i - 1] && a[i][j][1][2][2] == 2) break; } nq = j; } else // 2 2 2 x x x { for (j = 1; j < n; j++) if (a[i][j][1][2][2] == 2) break; nq = j; } } // end of si == 1 else { np = nq = 0; } // end of si == 2 p[i] = np; q[i] = nq; } for (i = 0; i < n; i++) { // printf("%d %d\n", p[i], q[i]); r[i][p[i]]++; r[i][q[i]]++; } } int main() { scanf("%d %d", &n, &m); int i, j, k; for (i = 1; i < n; i++) for (j = 1; j < n; j++) { scanf("%s", x); k = 0; for (char ii = 0; ii < 3; ii++) for (char jj = 0; jj < 3; jj++) for (char kk = 0; kk < 3; kk++) { char cc = x[k++]; if (cc == 'L') { cc = ii; } else if (cc == 'D') { cc = jj; } else { cc = kk; } a[i][j][ii][jj][kk] = cc; } } while (m--) { process(); } for (i = 0; i < n; i++) { k = 1; for (j = 0; j < n; j++) { k += r[i][j]; printf("%d ", k); } printf("\n"); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...