Submission #887529

# Submission time Handle Problem Language Result Execution time Memory
887529 2023-12-14T17:19:00 Z rainboy Lock Puzzle (innopolis2018_final_A) C
100 / 100
11 ms 608 KB
#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;
}

Compilation message

A.c: In function 'main':
A.c:24:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  scanf("%d%*d%s%s", &n, aa, bb);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB [n = 1, m = 10000], OK, 2 operations
2 Correct 1 ms 608 KB [n = 2, m = 10000], OK, 3 operations
3 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 19 operations
4 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 19 operations
5 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 18 operations
6 Correct 0 ms 344 KB [n = 8, m = 10000], OK: No solution
7 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 19 operations
8 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 16 operations
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB [n = 1, m = 10000], OK, 2 operations
2 Correct 1 ms 608 KB [n = 2, m = 10000], OK, 3 operations
3 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 19 operations
4 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 19 operations
5 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 18 operations
6 Correct 0 ms 344 KB [n = 8, m = 10000], OK: No solution
7 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 19 operations
8 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 16 operations
9 Correct 0 ms 348 KB [n = 49, m = 10000], OK, 121 operations
10 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 124 operations
11 Correct 0 ms 352 KB [n = 100, m = 10000], OK, 249 operations
12 Correct 0 ms 344 KB [n = 99, m = 10000], OK, 245 operations
13 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 124 operations
14 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 123 operations
15 Correct 0 ms 348 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 124 operations
17 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 123 operations
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB [n = 1, m = 10000], OK, 2 operations
2 Correct 1 ms 608 KB [n = 2, m = 10000], OK, 3 operations
3 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 19 operations
4 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 19 operations
5 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 18 operations
6 Correct 0 ms 344 KB [n = 8, m = 10000], OK: No solution
7 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 19 operations
8 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 16 operations
9 Correct 0 ms 348 KB [n = 49, m = 10000], OK, 121 operations
10 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 124 operations
11 Correct 0 ms 352 KB [n = 100, m = 10000], OK, 249 operations
12 Correct 0 ms 344 KB [n = 99, m = 10000], OK, 245 operations
13 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 124 operations
14 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 123 operations
15 Correct 0 ms 348 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 124 operations
17 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 123 operations
18 Correct 3 ms 348 KB [n = 1000, m = 10000], OK, 2498 operations
19 Correct 3 ms 348 KB [n = 999, m = 10000], OK, 2497 operations
20 Correct 3 ms 348 KB [n = 998, m = 10000], OK, 2492 operations
21 Correct 2 ms 424 KB [n = 997, m = 10000], OK, 2492 operations
22 Correct 2 ms 348 KB [n = 1000, m = 10000], OK, 2499 operations
23 Correct 2 ms 348 KB [n = 1000, m = 10000], OK, 2499 operations
24 Correct 2 ms 348 KB [n = 1000, m = 10000], OK: No solution
25 Correct 3 ms 348 KB [n = 1000, m = 10000], OK, 2498 operations
26 Correct 2 ms 344 KB [n = 1000, m = 10000], OK, 2497 operations
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB [n = 1, m = 10000], OK, 2 operations
2 Correct 1 ms 608 KB [n = 2, m = 10000], OK, 3 operations
3 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 19 operations
4 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 19 operations
5 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 18 operations
6 Correct 0 ms 344 KB [n = 8, m = 10000], OK: No solution
7 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 19 operations
8 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 16 operations
9 Correct 0 ms 348 KB [n = 49, m = 10000], OK, 121 operations
10 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 124 operations
11 Correct 0 ms 352 KB [n = 100, m = 10000], OK, 249 operations
12 Correct 0 ms 344 KB [n = 99, m = 10000], OK, 245 operations
13 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 124 operations
14 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 123 operations
15 Correct 0 ms 348 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 124 operations
17 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 123 operations
18 Correct 3 ms 348 KB [n = 1000, m = 10000], OK, 2498 operations
19 Correct 3 ms 348 KB [n = 999, m = 10000], OK, 2497 operations
20 Correct 3 ms 348 KB [n = 998, m = 10000], OK, 2492 operations
21 Correct 2 ms 424 KB [n = 997, m = 10000], OK, 2492 operations
22 Correct 2 ms 348 KB [n = 1000, m = 10000], OK, 2499 operations
23 Correct 2 ms 348 KB [n = 1000, m = 10000], OK, 2499 operations
24 Correct 2 ms 348 KB [n = 1000, m = 10000], OK: No solution
25 Correct 3 ms 348 KB [n = 1000, m = 10000], OK, 2498 operations
26 Correct 2 ms 344 KB [n = 1000, m = 10000], OK, 2497 operations
27 Correct 9 ms 440 KB [n = 2000, m = 10000], OK, 4999 operations
28 Correct 10 ms 432 KB [n = 1999, m = 10000], OK, 4998 operations
29 Correct 8 ms 348 KB [n = 1998, m = 10000], OK, 4992 operations
30 Correct 8 ms 348 KB [n = 1997, m = 10000], OK, 4989 operations
31 Correct 8 ms 348 KB [n = 2000, m = 10000], OK, 4999 operations
32 Correct 8 ms 348 KB [n = 2000, m = 10000], OK, 4998 operations
33 Correct 8 ms 348 KB [n = 2000, m = 10000], OK: No solution
34 Correct 8 ms 348 KB [n = 2000, m = 10000], OK, 4999 operations
35 Correct 10 ms 424 KB [n = 2000, m = 10000], OK, 4998 operations
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB [n = 1, m = 10000], OK, 2 operations
2 Correct 1 ms 608 KB [n = 2, m = 10000], OK, 3 operations
3 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 19 operations
4 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 19 operations
5 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 18 operations
6 Correct 0 ms 344 KB [n = 8, m = 10000], OK: No solution
7 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 19 operations
8 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 16 operations
9 Correct 0 ms 348 KB [n = 49, m = 10000], OK, 121 operations
10 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 124 operations
11 Correct 0 ms 352 KB [n = 100, m = 10000], OK, 249 operations
12 Correct 0 ms 344 KB [n = 99, m = 10000], OK, 245 operations
13 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 124 operations
14 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 123 operations
15 Correct 0 ms 348 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 124 operations
17 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 123 operations
18 Correct 3 ms 348 KB [n = 1000, m = 10000], OK, 2498 operations
19 Correct 3 ms 348 KB [n = 999, m = 10000], OK, 2497 operations
20 Correct 3 ms 348 KB [n = 998, m = 10000], OK, 2492 operations
21 Correct 2 ms 424 KB [n = 997, m = 10000], OK, 2492 operations
22 Correct 2 ms 348 KB [n = 1000, m = 10000], OK, 2499 operations
23 Correct 2 ms 348 KB [n = 1000, m = 10000], OK, 2499 operations
24 Correct 2 ms 348 KB [n = 1000, m = 10000], OK: No solution
25 Correct 3 ms 348 KB [n = 1000, m = 10000], OK, 2498 operations
26 Correct 2 ms 344 KB [n = 1000, m = 10000], OK, 2497 operations
27 Correct 9 ms 440 KB [n = 2000, m = 10000], OK, 4999 operations
28 Correct 10 ms 432 KB [n = 1999, m = 10000], OK, 4998 operations
29 Correct 8 ms 348 KB [n = 1998, m = 10000], OK, 4992 operations
30 Correct 8 ms 348 KB [n = 1997, m = 10000], OK, 4989 operations
31 Correct 8 ms 348 KB [n = 2000, m = 10000], OK, 4999 operations
32 Correct 8 ms 348 KB [n = 2000, m = 10000], OK, 4998 operations
33 Correct 8 ms 348 KB [n = 2000, m = 10000], OK: No solution
34 Correct 8 ms 348 KB [n = 2000, m = 10000], OK, 4999 operations
35 Correct 10 ms 424 KB [n = 2000, m = 10000], OK, 4998 operations
36 Correct 8 ms 348 KB [n = 2000, m = 8100], OK, 4998 operations
37 Correct 10 ms 348 KB [n = 1999, m = 8100], OK, 4996 operations
38 Correct 9 ms 348 KB [n = 1998, m = 8100], OK, 4992 operations
39 Correct 9 ms 344 KB [n = 1997, m = 8100], OK, 4992 operations
40 Correct 8 ms 348 KB [n = 1996, m = 8100], OK, 4988 operations
41 Correct 8 ms 348 KB [n = 2000, m = 8100], OK, 4999 operations
42 Correct 8 ms 344 KB [n = 2000, m = 8100], OK, 4998 operations
43 Correct 7 ms 344 KB [n = 2000, m = 8100], OK: No solution
44 Correct 8 ms 348 KB [n = 2000, m = 8100], OK, 4998 operations
45 Correct 9 ms 348 KB [n = 2000, m = 8100], OK, 4998 operations
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB [n = 1, m = 10000], OK, 2 operations
2 Correct 1 ms 608 KB [n = 2, m = 10000], OK, 3 operations
3 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 19 operations
4 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 19 operations
5 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 18 operations
6 Correct 0 ms 344 KB [n = 8, m = 10000], OK: No solution
7 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 19 operations
8 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 16 operations
9 Correct 0 ms 348 KB [n = 49, m = 10000], OK, 121 operations
10 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 124 operations
11 Correct 0 ms 352 KB [n = 100, m = 10000], OK, 249 operations
12 Correct 0 ms 344 KB [n = 99, m = 10000], OK, 245 operations
13 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 124 operations
14 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 123 operations
15 Correct 0 ms 348 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 124 operations
17 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 123 operations
18 Correct 3 ms 348 KB [n = 1000, m = 10000], OK, 2498 operations
19 Correct 3 ms 348 KB [n = 999, m = 10000], OK, 2497 operations
20 Correct 3 ms 348 KB [n = 998, m = 10000], OK, 2492 operations
21 Correct 2 ms 424 KB [n = 997, m = 10000], OK, 2492 operations
22 Correct 2 ms 348 KB [n = 1000, m = 10000], OK, 2499 operations
23 Correct 2 ms 348 KB [n = 1000, m = 10000], OK, 2499 operations
24 Correct 2 ms 348 KB [n = 1000, m = 10000], OK: No solution
25 Correct 3 ms 348 KB [n = 1000, m = 10000], OK, 2498 operations
26 Correct 2 ms 344 KB [n = 1000, m = 10000], OK, 2497 operations
27 Correct 9 ms 440 KB [n = 2000, m = 10000], OK, 4999 operations
28 Correct 10 ms 432 KB [n = 1999, m = 10000], OK, 4998 operations
29 Correct 8 ms 348 KB [n = 1998, m = 10000], OK, 4992 operations
30 Correct 8 ms 348 KB [n = 1997, m = 10000], OK, 4989 operations
31 Correct 8 ms 348 KB [n = 2000, m = 10000], OK, 4999 operations
32 Correct 8 ms 348 KB [n = 2000, m = 10000], OK, 4998 operations
33 Correct 8 ms 348 KB [n = 2000, m = 10000], OK: No solution
34 Correct 8 ms 348 KB [n = 2000, m = 10000], OK, 4999 operations
35 Correct 10 ms 424 KB [n = 2000, m = 10000], OK, 4998 operations
36 Correct 8 ms 348 KB [n = 2000, m = 8100], OK, 4998 operations
37 Correct 10 ms 348 KB [n = 1999, m = 8100], OK, 4996 operations
38 Correct 9 ms 348 KB [n = 1998, m = 8100], OK, 4992 operations
39 Correct 9 ms 344 KB [n = 1997, m = 8100], OK, 4992 operations
40 Correct 8 ms 348 KB [n = 1996, m = 8100], OK, 4988 operations
41 Correct 8 ms 348 KB [n = 2000, m = 8100], OK, 4999 operations
42 Correct 8 ms 344 KB [n = 2000, m = 8100], OK, 4998 operations
43 Correct 7 ms 344 KB [n = 2000, m = 8100], OK: No solution
44 Correct 8 ms 348 KB [n = 2000, m = 8100], OK, 4998 operations
45 Correct 9 ms 348 KB [n = 2000, m = 8100], OK, 4998 operations
46 Correct 8 ms 348 KB [n = 2000, m = 6100], OK, 4998 operations
47 Correct 8 ms 348 KB [n = 1999, m = 6100], OK, 4995 operations
48 Correct 8 ms 344 KB [n = 1998, m = 6100], OK, 4990 operations
49 Correct 9 ms 348 KB [n = 1997, m = 6100], OK, 4992 operations
50 Correct 9 ms 344 KB [n = 1996, m = 6100], OK, 4987 operations
51 Correct 9 ms 348 KB [n = 2000, m = 6100], OK, 4999 operations
52 Correct 8 ms 348 KB [n = 2000, m = 6100], OK, 4999 operations
53 Correct 8 ms 436 KB [n = 2000, m = 6100], OK: No solution
54 Correct 8 ms 444 KB [n = 2000, m = 6100], OK, 4999 operations
55 Correct 8 ms 344 KB [n = 2000, m = 6100], OK, 4997 operations
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB [n = 1, m = 10000], OK, 2 operations
2 Correct 1 ms 608 KB [n = 2, m = 10000], OK, 3 operations
3 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 19 operations
4 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 19 operations
5 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 18 operations
6 Correct 0 ms 344 KB [n = 8, m = 10000], OK: No solution
7 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 19 operations
8 Correct 0 ms 348 KB [n = 8, m = 10000], OK, 16 operations
9 Correct 0 ms 348 KB [n = 49, m = 10000], OK, 121 operations
10 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 124 operations
11 Correct 0 ms 352 KB [n = 100, m = 10000], OK, 249 operations
12 Correct 0 ms 344 KB [n = 99, m = 10000], OK, 245 operations
13 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 124 operations
14 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 123 operations
15 Correct 0 ms 348 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 124 operations
17 Correct 0 ms 348 KB [n = 50, m = 10000], OK, 123 operations
18 Correct 3 ms 348 KB [n = 1000, m = 10000], OK, 2498 operations
19 Correct 3 ms 348 KB [n = 999, m = 10000], OK, 2497 operations
20 Correct 3 ms 348 KB [n = 998, m = 10000], OK, 2492 operations
21 Correct 2 ms 424 KB [n = 997, m = 10000], OK, 2492 operations
22 Correct 2 ms 348 KB [n = 1000, m = 10000], OK, 2499 operations
23 Correct 2 ms 348 KB [n = 1000, m = 10000], OK, 2499 operations
24 Correct 2 ms 348 KB [n = 1000, m = 10000], OK: No solution
25 Correct 3 ms 348 KB [n = 1000, m = 10000], OK, 2498 operations
26 Correct 2 ms 344 KB [n = 1000, m = 10000], OK, 2497 operations
27 Correct 9 ms 440 KB [n = 2000, m = 10000], OK, 4999 operations
28 Correct 10 ms 432 KB [n = 1999, m = 10000], OK, 4998 operations
29 Correct 8 ms 348 KB [n = 1998, m = 10000], OK, 4992 operations
30 Correct 8 ms 348 KB [n = 1997, m = 10000], OK, 4989 operations
31 Correct 8 ms 348 KB [n = 2000, m = 10000], OK, 4999 operations
32 Correct 8 ms 348 KB [n = 2000, m = 10000], OK, 4998 operations
33 Correct 8 ms 348 KB [n = 2000, m = 10000], OK: No solution
34 Correct 8 ms 348 KB [n = 2000, m = 10000], OK, 4999 operations
35 Correct 10 ms 424 KB [n = 2000, m = 10000], OK, 4998 operations
36 Correct 8 ms 348 KB [n = 2000, m = 8100], OK, 4998 operations
37 Correct 10 ms 348 KB [n = 1999, m = 8100], OK, 4996 operations
38 Correct 9 ms 348 KB [n = 1998, m = 8100], OK, 4992 operations
39 Correct 9 ms 344 KB [n = 1997, m = 8100], OK, 4992 operations
40 Correct 8 ms 348 KB [n = 1996, m = 8100], OK, 4988 operations
41 Correct 8 ms 348 KB [n = 2000, m = 8100], OK, 4999 operations
42 Correct 8 ms 344 KB [n = 2000, m = 8100], OK, 4998 operations
43 Correct 7 ms 344 KB [n = 2000, m = 8100], OK: No solution
44 Correct 8 ms 348 KB [n = 2000, m = 8100], OK, 4998 operations
45 Correct 9 ms 348 KB [n = 2000, m = 8100], OK, 4998 operations
46 Correct 8 ms 348 KB [n = 2000, m = 6100], OK, 4998 operations
47 Correct 8 ms 348 KB [n = 1999, m = 6100], OK, 4995 operations
48 Correct 8 ms 344 KB [n = 1998, m = 6100], OK, 4990 operations
49 Correct 9 ms 348 KB [n = 1997, m = 6100], OK, 4992 operations
50 Correct 9 ms 344 KB [n = 1996, m = 6100], OK, 4987 operations
51 Correct 9 ms 348 KB [n = 2000, m = 6100], OK, 4999 operations
52 Correct 8 ms 348 KB [n = 2000, m = 6100], OK, 4999 operations
53 Correct 8 ms 436 KB [n = 2000, m = 6100], OK: No solution
54 Correct 8 ms 444 KB [n = 2000, m = 6100], OK, 4999 operations
55 Correct 8 ms 344 KB [n = 2000, m = 6100], OK, 4997 operations
56 Correct 11 ms 344 KB [n = 2000, m = 5100], OK, 4998 operations
57 Correct 8 ms 344 KB [n = 1999, m = 5100], OK, 4995 operations
58 Correct 8 ms 344 KB [n = 1998, m = 5100], OK, 4991 operations
59 Correct 9 ms 344 KB [n = 1997, m = 5100], OK, 4993 operations
60 Correct 8 ms 344 KB [n = 1996, m = 5100], OK, 4986 operations
61 Correct 8 ms 348 KB [n = 1995, m = 5100], OK, 4988 operations
62 Correct 8 ms 348 KB [n = 1994, m = 5100], OK, 4983 operations
63 Correct 8 ms 348 KB [n = 2000, m = 5100], OK, 4998 operations
64 Correct 8 ms 348 KB [n = 2000, m = 5100], OK, 4999 operations
65 Correct 10 ms 344 KB [n = 2000, m = 5100], OK, 4998 operations
66 Correct 8 ms 344 KB [n = 2000, m = 5100], OK: No solution
67 Correct 8 ms 440 KB [n = 2000, m = 5100], OK, 4999 operations