# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
286898 | 2020-08-31T06:41:17 Z | 송준혁(#5773) | None (JOI12_rotate) | C++17 | 269 ms | 18168 KB |
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> pii; int N, Q, id, d; int P[1010101][4]; int A[4][1010], B[4][1010]; int Ad[4][1010], Bd[4][1010]; char ch[1010][1010]; inline int dir(int id, int pr){for (int i=0; i<4; i++) if (P[id][i]==pr) return (i+2)%4;} void go(){ int pr=id; id=P[id][d%4], d=dir(id,pr); } int main(){ scanf("%d %d", &N, &Q); for (int i=0; i<N*N; i++) for (int j=0; j<4; j++) P[i][j]=N*N; for (int i=0; i<N; i++){ scanf("%s", ch[i]); for (int j=0; j<N; j++){ if (j<N) P[i*N+j][3] = i*N+j+1, P[i*N+j+1][1] = i*N+j; if (i<N) P[i*N+j][2] = (i+1)*N+j, P[(i+1)*N+j][0] = i*N+j; } } P[N*N+1][2] = 0, P[0][0] = N*N+1; while (Q--){ int x, y, k; scanf("%d %d %d", &x, &y, &k); id=P[N*N+1][2], d=dir(id, N*N+1); for (int i=1; i<x; i++) go(); d=(d+1)%4; for (int i=1; i<y; i++) go(); d=(d+3)%4; for (int i=0; i<4; i++){ for (int j=0; j<k; j++){ A[i][j] = id, Ad[i][j] = (d+3)%4; B[i][j] = P[id][(d+3)%4], Bd[i][j] = (dir(P[id][(d+3)%4], id)+2)%4; if (j<k-1) go(); else d=(d+1)%4; } } for (int i=0; i<4; i++){ for (int j=0; j<k; j++){ P[A[i][j]][Ad[i][j]] = B[(i+1)%4][j]; P[B[(i+1)%4][j]][Bd[(i+1)%4][j]] = A[i][j]; } } } for (int i=1; i<=N; i++){ id=P[N*N+1][2], d=dir(id, N*N+1); for (int j=1; j<i; j++) go(); d=(d+1)%4; for (int j=1; j<=N; j++){ printf("%c", ch[id/N][id%N]); go(); } printf("\n"); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 640 KB | Output is correct |
2 | Incorrect | 3 ms | 640 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 218 ms | 18040 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 223 ms | 18040 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 225 ms | 18120 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 248 ms | 18168 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 239 ms | 18040 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 259 ms | 18040 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 254 ms | 18040 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 263 ms | 18168 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 269 ms | 18116 KB | Output isn't correct |