# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
288954 | 2020-09-02T08:26:41 Z | 반딧불(#5784) | 회전 (JOI12_rotate) | C++17 | 114 ms | 65540 KB |
#include <bits/stdc++.h> using namespace std; struct Matrix{ char c; Matrix *r = nullptr, *d = nullptr; Matrix(){} Matrix(char c): c(c){} ~Matrix(){ if(d) delete d; } }; int n, q; char arr[1005][1005]; char tmp[1005][1005]; Matrix *MA[4][1005]; void makeMatrix(){ vector<Matrix*> v[4]; for(int i=0; i<4; i++) v[i] = vector<Matrix*> (MA[i], MA[i]+n+2); for(int i=1; i<=n+1; i++){ for(int j=0; j<=n+1; j++){ v[0][j]->d = new Matrix(j ? arr[i][j] : ' '); v[1][j]->d = new Matrix(j ? arr[n+1-j][i] : ' '); v[2][j]->d = new Matrix(j ? arr[n+1-i][n+1-j] : ' '); v[3][j]->d = new Matrix(j ? arr[j][n+1-i] : ' '); for(int k=0; k<4; k++){ v[k][j] = v[k][j]->d; // v[k][j]->dir = k, v[k][j]->i = i, v[k][j]->j = j; } } for(int k=0; k<4; k++) for(int j=0; j<n; j++) v[k][j]->r = v[k][j+1]; } } void rotateMatrix(int x, int y, int d){ vector<Matrix*> corner = {MA[0][y-1], MA[1][n+1-(x+d)], MA[2][n+1-(y+d)], MA[3][x-1]}; for(int z=0; z<x-1; z++) corner[0] = corner[0]->d; for(int z=0; z<y-1; z++) corner[1] = corner[1]->d; for(int z=0; z<n+1-(x+d); z++) corner[2] = corner[2]->d; for(int z=0; z<n+1-(y+d); z++) corner[3] = corner[3]->d; vector<Matrix*> corner2 = corner; vector<Matrix*> corner3; for(int i=1; i<=d; i++){ vector<Matrix*> tmp; for(int k=0; k<4; k++) corner2[k] = corner2[k]->r; tmp = vector<Matrix*> {corner2[3]->d, corner2[0]->d, corner2[1]->d, corner2[2]->d}; for(int k=0; k<4; k++) corner2[k]->d = tmp[k]; } corner3 = corner2; for(int k=0; k<4; k++) corner2[k] = corner2[k]->r; for(int i=1; i<=d; i++){ for(int k=0; k<4; k++) corner2[k] = corner2[k]->d, corner3[k] = corner3[k]->d; for(int k=0; k<4; k++) corner3[k]->r = corner2[k]; } corner2 = corner; for(int i=1; i<=d; i++){ vector<Matrix*> tmp; for(int k=0; k<4; k++) corner2[k] = corner2[k]->d; tmp = vector<Matrix*> {corner2[3]->r, corner2[0]->r, corner2[1]->r, corner2[2]->r}; for(int k=0; k<4; k++) corner2[k]->r = tmp[k]; } corner3 = corner2; for(int k=0; k<4; k++) corner2[k] = corner2[k]->d; for(int i=1; i<=d; i++){ for(int k=0; k<4; k++) corner2[k] = corner2[k]->r, corner3[k] = corner3[k]->r; for(int k=0; k<4; k++) corner3[k]->d = corner2[k]; } } int main(){ scanf("%d %d", &n, &q); for(int i=1; i<=n; i++){ scanf("%s", arr[i]+1); // for(int j=1; j<=n; j++) arr[i][j] = (i+j)%26+'a'; } for(int i=0; i<=n+1; i++){ for(int j=0; j<4; j++){ MA[j][i] = new Matrix(' '); // MA[j][i]->dir = j, MA[j][i]->i = 0, MA[j][i]->j = i; } if(i) for(int j=0; j<4; j++) MA[j][i-1]->r = MA[j][i]; } makeMatrix(); q=1; while(q--){ int x, y, d; scanf("%d %d %d", &x, &y, &d); rotateMatrix(x, y, d); } for(int j=1; j<=n; j++){ Matrix* tmp = MA[0][j]; for(int i=1; i<=n; i++){ tmp = tmp->d; arr[i][j] = tmp->c; } } for(int i=1; i<=n; i++){ for(int j=1; j<=n; j++){ printf("%c", arr[i][j]); } puts(""); } for(int k=0; k<4; k++) for(int i=0; i<=n+1; i++) delete MA[k][i]; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 1792 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 114 ms | 65540 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 110 ms | 65540 KB | Execution killed with signal 9 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 110 ms | 65540 KB | Execution killed with signal 9 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 111 ms | 65540 KB | Execution killed with signal 9 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 106 ms | 65540 KB | Execution killed with signal 9 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 114 ms | 65540 KB | Execution killed with signal 9 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 110 ms | 65540 KB | Execution killed with signal 9 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 112 ms | 65540 KB | Execution killed with signal 9 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 110 ms | 65540 KB | Execution killed with signal 9 |