Submission #115433

#TimeUsernameProblemLanguageResultExecution timeMemory
115433youngyojunLock Puzzle (innopolis2018_final_A)C++11
100 / 100
10 ms420 KiB
#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)

A.cpp: In function 'int main()':
A.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%*d %s %s", &N, A+1, B+1);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...