# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
114349 | 2019-06-01T03:21:22 Z | sebinkim | Lock Puzzle (innopolis2018_final_A) | C++14 | 2 ms | 384 KB |
#include <bits/stdc++.h> using namespace std; char A[2020], B[2020]; int D[2020], E[2020]; vector <int> V; int n, m; void shift(int p) { reverse(A, A + n); reverse(A + p, A + n); V.push_back(p); } int main() { int i, j; scanf("%d%d", &n, &m); scanf("%s%s", A, B); char _A[2020], _B[2020]; for(i=0; i<n; i++) _A[i] = A[i], _B[i] = B[i]; sort(_A, _A + n); sort(_B, _B + n); for(i=0; i<n; i++){ if(_A[i] != _B[i]){ printf("-1\n"); return 0; } } if(n & 1){ D[0] = 0; for(i=1; i<n; i+=2){ reverse(D, D + i); for(j=i; j>=1; j--) D[j] = D[j - 1]; D[i + 1] = i; D[0] = i + 1; } for(i=0; i<n; i++){ E[D[i]] = i; } for(i=0; i<n; i++){ if(A[i] == B[E[0]]) break; } shift(n - i); for(i=1; i<n; i+=2){ for(j=0; j<n-i; j++){ if(A[j] == B[E[i]]) break; } shift(n - j - 1); shift(n); shift(i); for(j=i+1; j<n; j++){ if(A[j] == B[E[i + 1]]) break; } shift(n - j); shift(j - i - 1); } } else{ for(i=0; i<n; i+=2){ reverse(D, D + i); for(j=i; j>=1; j--) D[j] = D[j - 1]; D[i + 1] = i; D[0] = i + 1; } for(i=0; i<n; i++){ E[D[i]] = i; } for(i=0; i<n; i+=2){ for(j=0; j<n-i; j++){ if(A[j] == B[E[i]]) break; } shift(n - j - 1); shift(n); shift(i); for(j=i+1; j<n; j++){ if(A[j] == B[E[i + 1]]) break; } shift(n - j); shift(j - i - 1); } } printf("%d\n", V.size()); for(int &t: V) printf("%d ", t); printf("\n"); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | [n = 1, m = 10000], OK, 1 operations |
2 | Correct | 2 ms | 256 KB | [n = 2, m = 10000], OK, 5 operations |
3 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
4 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
5 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
6 | Correct | 2 ms | 256 KB | [n = 8, m = 10000], OK: No solution |
7 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
8 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | [n = 1, m = 10000], OK, 1 operations |
2 | Correct | 2 ms | 256 KB | [n = 2, m = 10000], OK, 5 operations |
3 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
4 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
5 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
6 | Correct | 2 ms | 256 KB | [n = 8, m = 10000], OK: No solution |
7 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
8 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
9 | Incorrect | 2 ms | 384 KB | S is not equal after all operations: S = zykhenbdwesfadpxbutefbwejaskjfffctnzdgvnitoezwnbt, T = eykhenbdwjefadpxbutefbwezaskjfffctnzdgvnitoszwnbt |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | [n = 1, m = 10000], OK, 1 operations |
2 | Correct | 2 ms | 256 KB | [n = 2, m = 10000], OK, 5 operations |
3 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
4 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
5 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
6 | Correct | 2 ms | 256 KB | [n = 8, m = 10000], OK: No solution |
7 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
8 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
9 | Incorrect | 2 ms | 384 KB | S is not equal after all operations: S = zykhenbdwesfadpxbutefbwejaskjfffctnzdgvnitoezwnbt, T = eykhenbdwjefadpxbutefbwezaskjfffctnzdgvnitoszwnbt |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | [n = 1, m = 10000], OK, 1 operations |
2 | Correct | 2 ms | 256 KB | [n = 2, m = 10000], OK, 5 operations |
3 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
4 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
5 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
6 | Correct | 2 ms | 256 KB | [n = 8, m = 10000], OK: No solution |
7 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
8 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
9 | Incorrect | 2 ms | 384 KB | S is not equal after all operations: S = zykhenbdwesfadpxbutefbwejaskjfffctnzdgvnitoezwnbt, T = eykhenbdwjefadpxbutefbwezaskjfffctnzdgvnitoszwnbt |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | [n = 1, m = 10000], OK, 1 operations |
2 | Correct | 2 ms | 256 KB | [n = 2, m = 10000], OK, 5 operations |
3 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
4 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
5 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
6 | Correct | 2 ms | 256 KB | [n = 8, m = 10000], OK: No solution |
7 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
8 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
9 | Incorrect | 2 ms | 384 KB | S is not equal after all operations: S = zykhenbdwesfadpxbutefbwejaskjfffctnzdgvnitoezwnbt, T = eykhenbdwjefadpxbutefbwezaskjfffctnzdgvnitoszwnbt |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | [n = 1, m = 10000], OK, 1 operations |
2 | Correct | 2 ms | 256 KB | [n = 2, m = 10000], OK, 5 operations |
3 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
4 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
5 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
6 | Correct | 2 ms | 256 KB | [n = 8, m = 10000], OK: No solution |
7 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
8 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
9 | Incorrect | 2 ms | 384 KB | S is not equal after all operations: S = zykhenbdwesfadpxbutefbwejaskjfffctnzdgvnitoezwnbt, T = eykhenbdwjefadpxbutefbwezaskjfffctnzdgvnitoszwnbt |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | [n = 1, m = 10000], OK, 1 operations |
2 | Correct | 2 ms | 256 KB | [n = 2, m = 10000], OK, 5 operations |
3 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
4 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
5 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
6 | Correct | 2 ms | 256 KB | [n = 8, m = 10000], OK: No solution |
7 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
8 | Correct | 2 ms | 384 KB | [n = 8, m = 10000], OK, 20 operations |
9 | Incorrect | 2 ms | 384 KB | S is not equal after all operations: S = zykhenbdwesfadpxbutefbwejaskjfffctnzdgvnitoezwnbt, T = eykhenbdwjefadpxbutefbwezaskjfffctnzdgvnitoszwnbt |
10 | Halted | 0 ms | 0 KB | - |