제출 #114346

#제출 시각아이디문제언어결과실행 시간메모리
114346sebinkimLock Puzzle (innopolis2018_final_A)C++14
9 / 100
2 ms384 KiB
#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); 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); } } for(i=0; i<n; i++){ if(A[i] != B[i]) break; } if(i == n){ printf("%d\n", V.size()); for(int &t: V) printf("%d ", t); printf("\n"); } else printf("-1\n"); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

A.cpp: In function 'int main()':
A.cpp:87:26: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
   printf("%d\n", V.size());
                  ~~~~~~~~^
A.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~
A.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s%s", A, B);
  ~~~~~^~~~~~~~~~~~~~
#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...