# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
887529 | rainboy | Lock Puzzle (innopolis2018_final_A) | C11 | 11 ms | 608 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <string.h>
#define N 2000
#define M (N / 2 * 5)
char aa[N + 1], bb[N + 1], cc[N + 1]; int n;
int qu[M], m;
void shift(int k) {
int i;
if (k == 0)
return;
for (i = 0; i < n; i++)
cc[i] = i < k ? aa[n - 1 - i] : aa[i - k];
strcpy(aa, cc);
qu[m++] = k;
}
int main() {
int h, i, j;
scanf("%d%*d%s%s", &n, aa, bb);
m = 0;
for (i = 0; i + 1 < n; i += 2) {
for (j = 0; j < n - i; j++)
if (aa[j] == bb[i])
break;
if (j == n - i) {
printf("-1\n");
return 0;
}
shift(n - 1 - j), shift(1);
for (j = i + 1; j < n; j++)
if (aa[j] == bb[i + 1])
break;
if (j == n) {
printf("-1\n");
return 0;
}
shift(n - j), shift(n), shift(n - j - 1);
}
if (i < n) {
if (aa[0] != bb[n - 1]) {
printf("-1\n");
return 0;
}
shift(n - 1), shift(1), shift(n);
}
printf("%d\n", m);
for (h = 0; h < m; h++)
printf("%d ", qu[h]);
printf("\n");
return 0;
}
컴파일 시 표준 에러 (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... |