# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
282947 | 2020-08-25T07:41:05 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, cnt[30]; 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); for (int i=1; i<=N; i++) cnt[S[i]-'a']++; for (int i=1; i<=N; i++){ cnt[T[i]-'a']--; if (cnt[T[i]-'a'] < 0){ puts("-1"); return 0; } } int s=N/2, 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++){ int t; if (i%4 == 1 || i%4 == 0) t=s-1, s--; else t=e+1, e++; if (i&1){ for (int j=i+1; j<=N; j++) if (T[t] == S[j]){ sft(j-1), sft(N+i-j+1); break; } } else{ for (int j=1; j<=N-i; j++) if (T[t] == S[j]){ sft(j), sft(N-1); break; } } } if (N%4 == 2 || N%4 == 1) sft(0); printf("%d\n", (int)V.size()); for (int x : V) printf("%d ", N-x); printf("\n"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | [n = 1, m = 10000], OK, 1 operations |
2 | Incorrect | 1 ms | 256 KB | S is not equal after all operations: S = hd, T = dh |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | [n = 1, m = 10000], OK, 1 operations |
2 | Incorrect | 1 ms | 256 KB | S is not equal after all operations: S = hd, T = dh |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | [n = 1, m = 10000], OK, 1 operations |
2 | Incorrect | 1 ms | 256 KB | S is not equal after all operations: S = hd, T = dh |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | [n = 1, m = 10000], OK, 1 operations |
2 | Incorrect | 1 ms | 256 KB | S is not equal after all operations: S = hd, T = dh |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | [n = 1, m = 10000], OK, 1 operations |
2 | Incorrect | 1 ms | 256 KB | S is not equal after all operations: S = hd, T = dh |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | [n = 1, m = 10000], OK, 1 operations |
2 | Incorrect | 1 ms | 256 KB | S is not equal after all operations: S = hd, T = dh |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | [n = 1, m = 10000], OK, 1 operations |
2 | Incorrect | 1 ms | 256 KB | S is not equal after all operations: S = hd, T = dh |
3 | Halted | 0 ms | 0 KB | - |