# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
282899 | 2020-08-25T06:56:32 Z | 송준혁(#5748) | Lock Puzzle (innopolis2018_final_A) | C++17 | 1 ms | 384 KB |
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> pii; int N; char S[2020], T[2020], B[2020]; vector<int> V; void sft(int x){ V.push_back(x); for (int i=1; i<=x; i++) B[N-x+i] = S[i]; for (int i=1; i<=N-x; i++) B[i] = S[N-i+1]; for (int i=1; i<=N; i++) S[i] = B[i]; } int main(){ scanf("%d %*d", &N); scanf("%s", S+1); scanf("%s", T+1); int s=N/2+1, e=s; for (int i=1; i<=N; i++){ if (T[s] == S[i]){ sft(i), sft(0); break; } } for (int i=1; i<N; i++){ if (i&1){ for (int j=i+1; j<=N; j++) if (T[s-1] == S[j]){ sft(j-1), sft(N+i-j+1); break; } s--; } else{ for (int j=1; j<=N-i; j++) if (T[e+1] == S[j]){ sft(j), sft(N-1), sft(0); break; } e++; } } for (int i=1; i<=N; i++) if (S[i] != T[i]){ puts("-1"); return 0; } printf("%d\n", (int)V.size()); for (int x : V) printf("%d ", x); printf("\n"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | [n = 1, m = 10000], OK, 2 operations |
2 | Correct | 1 ms | 256 KB | [n = 2, m = 10000], OK, 4 operations |
3 | Incorrect | 1 ms | 256 KB | [n = 8, m = 10000] No solution found, but it exists |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | [n = 1, m = 10000], OK, 2 operations |
2 | Correct | 1 ms | 256 KB | [n = 2, m = 10000], OK, 4 operations |
3 | Incorrect | 1 ms | 256 KB | [n = 8, m = 10000] No solution found, but it exists |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | [n = 1, m = 10000], OK, 2 operations |
2 | Correct | 1 ms | 256 KB | [n = 2, m = 10000], OK, 4 operations |
3 | Incorrect | 1 ms | 256 KB | [n = 8, m = 10000] No solution found, but it exists |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | [n = 1, m = 10000], OK, 2 operations |
2 | Correct | 1 ms | 256 KB | [n = 2, m = 10000], OK, 4 operations |
3 | Incorrect | 1 ms | 256 KB | [n = 8, m = 10000] No solution found, but it exists |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | [n = 1, m = 10000], OK, 2 operations |
2 | Correct | 1 ms | 256 KB | [n = 2, m = 10000], OK, 4 operations |
3 | Incorrect | 1 ms | 256 KB | [n = 8, m = 10000] No solution found, but it exists |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | [n = 1, m = 10000], OK, 2 operations |
2 | Correct | 1 ms | 256 KB | [n = 2, m = 10000], OK, 4 operations |
3 | Incorrect | 1 ms | 256 KB | [n = 8, m = 10000] No solution found, but it exists |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | [n = 1, m = 10000], OK, 2 operations |
2 | Correct | 1 ms | 256 KB | [n = 2, m = 10000], OK, 4 operations |
3 | Incorrect | 1 ms | 256 KB | [n = 8, m = 10000] No solution found, but it exists |
4 | Halted | 0 ms | 0 KB | - |