# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
115433 | youngyojun | Lock Puzzle (innopolis2018_final_A) | C++11 | 10 ms | 420 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
char A[2055], B[2055];
int C[26];
int N, M;
void f(int n) {
printf("%d ", n);
rotate(A+1, A+N-n+1, A+N+1);
reverse(A+1, A+n+1);
}
int main() {
scanf("%d%*d %s %s", &N, A+1, B+1);
for(int i = 1; i <= N; i++) {
C[A[i]-'a']++;
C[B[i]-'a']--;
}
for(int i = 0; i < 26; i++) if(C[i]) {
puts("-1");
return 0;
}
M = N/2;
printf("%d\n", M*4);
for(int i = 1; i <= M; i++) {
char c = B[M-i+1], e = B[M+i];
if((M^i)&1) swap(c, e);
int ci, ei;
for(ci = i*2-1;; ci++) if(c == A[ci]) break;
for(ei = i*2-1;; ei++) if(e == A[ei] && ci != ei) break;
if(ci < ei) {
int A = (i-1)<<1, B = ci-A-1, D = ei-ci-1, F = N-ei;
f(F+1); f(B+D+1); f(A+B+F+1); f(1);
} else {
int A = (i-1)<<1, B = ei-A-1, D = ci-ei-1, F = N-ci;
f(D+F+2); f(B); f(A+D+1); f(1);
}
}
puts("");
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |