Submission #115433

# Submission time Handle Problem Language Result Execution time Memory
115433 2019-06-07T13:26:19 Z youngyojun Lock Puzzle (innopolis2018_final_A) C++11
100 / 100
10 ms 420 KB
#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

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 time Memory Grader output
1 Correct 2 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Correct 2 ms 256 KB [n = 2, m = 10000], OK, 4 operations
3 Correct 2 ms 256 KB [n = 8, m = 10000], OK, 16 operations
4 Correct 2 ms 256 KB [n = 8, m = 10000], OK, 16 operations
5 Correct 2 ms 256 KB [n = 8, m = 10000], OK, 16 operations
6 Correct 2 ms 384 KB [n = 8, m = 10000], OK: No solution
7 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 16 operations
8 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 16 operations
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Correct 2 ms 256 KB [n = 2, m = 10000], OK, 4 operations
3 Correct 2 ms 256 KB [n = 8, m = 10000], OK, 16 operations
4 Correct 2 ms 256 KB [n = 8, m = 10000], OK, 16 operations
5 Correct 2 ms 256 KB [n = 8, m = 10000], OK, 16 operations
6 Correct 2 ms 384 KB [n = 8, m = 10000], OK: No solution
7 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 16 operations
8 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 16 operations
9 Correct 2 ms 384 KB [n = 49, m = 10000], OK, 96 operations
10 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 100 operations
11 Correct 2 ms 384 KB [n = 100, m = 10000], OK, 200 operations
12 Correct 3 ms 256 KB [n = 99, m = 10000], OK, 196 operations
13 Correct 2 ms 256 KB [n = 50, m = 10000], OK, 100 operations
14 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 100 operations
15 Correct 2 ms 384 KB [n = 50, m = 10000], OK: No solution
16 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 100 operations
17 Correct 2 ms 256 KB [n = 50, m = 10000], OK, 100 operations
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Correct 2 ms 256 KB [n = 2, m = 10000], OK, 4 operations
3 Correct 2 ms 256 KB [n = 8, m = 10000], OK, 16 operations
4 Correct 2 ms 256 KB [n = 8, m = 10000], OK, 16 operations
5 Correct 2 ms 256 KB [n = 8, m = 10000], OK, 16 operations
6 Correct 2 ms 384 KB [n = 8, m = 10000], OK: No solution
7 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 16 operations
8 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 16 operations
9 Correct 2 ms 384 KB [n = 49, m = 10000], OK, 96 operations
10 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 100 operations
11 Correct 2 ms 384 KB [n = 100, m = 10000], OK, 200 operations
12 Correct 3 ms 256 KB [n = 99, m = 10000], OK, 196 operations
13 Correct 2 ms 256 KB [n = 50, m = 10000], OK, 100 operations
14 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 100 operations
15 Correct 2 ms 384 KB [n = 50, m = 10000], OK: No solution
16 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 100 operations
17 Correct 2 ms 256 KB [n = 50, m = 10000], OK, 100 operations
18 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
19 Correct 4 ms 256 KB [n = 999, m = 10000], OK, 1996 operations
20 Correct 3 ms 256 KB [n = 998, m = 10000], OK, 1996 operations
21 Correct 4 ms 256 KB [n = 997, m = 10000], OK, 1992 operations
22 Correct 3 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
23 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
24 Correct 3 ms 384 KB [n = 1000, m = 10000], OK: No solution
25 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
26 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Correct 2 ms 256 KB [n = 2, m = 10000], OK, 4 operations
3 Correct 2 ms 256 KB [n = 8, m = 10000], OK, 16 operations
4 Correct 2 ms 256 KB [n = 8, m = 10000], OK, 16 operations
5 Correct 2 ms 256 KB [n = 8, m = 10000], OK, 16 operations
6 Correct 2 ms 384 KB [n = 8, m = 10000], OK: No solution
7 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 16 operations
8 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 16 operations
9 Correct 2 ms 384 KB [n = 49, m = 10000], OK, 96 operations
10 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 100 operations
11 Correct 2 ms 384 KB [n = 100, m = 10000], OK, 200 operations
12 Correct 3 ms 256 KB [n = 99, m = 10000], OK, 196 operations
13 Correct 2 ms 256 KB [n = 50, m = 10000], OK, 100 operations
14 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 100 operations
15 Correct 2 ms 384 KB [n = 50, m = 10000], OK: No solution
16 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 100 operations
17 Correct 2 ms 256 KB [n = 50, m = 10000], OK, 100 operations
18 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
19 Correct 4 ms 256 KB [n = 999, m = 10000], OK, 1996 operations
20 Correct 3 ms 256 KB [n = 998, m = 10000], OK, 1996 operations
21 Correct 4 ms 256 KB [n = 997, m = 10000], OK, 1992 operations
22 Correct 3 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
23 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
24 Correct 3 ms 384 KB [n = 1000, m = 10000], OK: No solution
25 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
26 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
27 Correct 9 ms 384 KB [n = 2000, m = 10000], OK, 4000 operations
28 Correct 9 ms 384 KB [n = 1999, m = 10000], OK, 3996 operations
29 Correct 10 ms 384 KB [n = 1998, m = 10000], OK, 3996 operations
30 Correct 8 ms 384 KB [n = 1997, m = 10000], OK, 3992 operations
31 Correct 7 ms 384 KB [n = 2000, m = 10000], OK, 4000 operations
32 Correct 7 ms 384 KB [n = 2000, m = 10000], OK, 4000 operations
33 Correct 7 ms 384 KB [n = 2000, m = 10000], OK: No solution
34 Correct 8 ms 384 KB [n = 2000, m = 10000], OK, 4000 operations
35 Correct 9 ms 384 KB [n = 2000, m = 10000], OK, 4000 operations
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Correct 2 ms 256 KB [n = 2, m = 10000], OK, 4 operations
3 Correct 2 ms 256 KB [n = 8, m = 10000], OK, 16 operations
4 Correct 2 ms 256 KB [n = 8, m = 10000], OK, 16 operations
5 Correct 2 ms 256 KB [n = 8, m = 10000], OK, 16 operations
6 Correct 2 ms 384 KB [n = 8, m = 10000], OK: No solution
7 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 16 operations
8 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 16 operations
9 Correct 2 ms 384 KB [n = 49, m = 10000], OK, 96 operations
10 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 100 operations
11 Correct 2 ms 384 KB [n = 100, m = 10000], OK, 200 operations
12 Correct 3 ms 256 KB [n = 99, m = 10000], OK, 196 operations
13 Correct 2 ms 256 KB [n = 50, m = 10000], OK, 100 operations
14 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 100 operations
15 Correct 2 ms 384 KB [n = 50, m = 10000], OK: No solution
16 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 100 operations
17 Correct 2 ms 256 KB [n = 50, m = 10000], OK, 100 operations
18 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
19 Correct 4 ms 256 KB [n = 999, m = 10000], OK, 1996 operations
20 Correct 3 ms 256 KB [n = 998, m = 10000], OK, 1996 operations
21 Correct 4 ms 256 KB [n = 997, m = 10000], OK, 1992 operations
22 Correct 3 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
23 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
24 Correct 3 ms 384 KB [n = 1000, m = 10000], OK: No solution
25 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
26 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
27 Correct 9 ms 384 KB [n = 2000, m = 10000], OK, 4000 operations
28 Correct 9 ms 384 KB [n = 1999, m = 10000], OK, 3996 operations
29 Correct 10 ms 384 KB [n = 1998, m = 10000], OK, 3996 operations
30 Correct 8 ms 384 KB [n = 1997, m = 10000], OK, 3992 operations
31 Correct 7 ms 384 KB [n = 2000, m = 10000], OK, 4000 operations
32 Correct 7 ms 384 KB [n = 2000, m = 10000], OK, 4000 operations
33 Correct 7 ms 384 KB [n = 2000, m = 10000], OK: No solution
34 Correct 8 ms 384 KB [n = 2000, m = 10000], OK, 4000 operations
35 Correct 9 ms 384 KB [n = 2000, m = 10000], OK, 4000 operations
36 Correct 8 ms 384 KB [n = 2000, m = 8100], OK, 4000 operations
37 Correct 9 ms 420 KB [n = 1999, m = 8100], OK, 3996 operations
38 Correct 8 ms 384 KB [n = 1998, m = 8100], OK, 3996 operations
39 Correct 8 ms 384 KB [n = 1997, m = 8100], OK, 3992 operations
40 Correct 8 ms 384 KB [n = 1996, m = 8100], OK, 3992 operations
41 Correct 6 ms 256 KB [n = 2000, m = 8100], OK, 4000 operations
42 Correct 7 ms 384 KB [n = 2000, m = 8100], OK, 4000 operations
43 Correct 2 ms 256 KB [n = 2000, m = 8100], OK: No solution
44 Correct 6 ms 256 KB [n = 2000, m = 8100], OK, 4000 operations
45 Correct 8 ms 384 KB [n = 2000, m = 8100], OK, 4000 operations
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Correct 2 ms 256 KB [n = 2, m = 10000], OK, 4 operations
3 Correct 2 ms 256 KB [n = 8, m = 10000], OK, 16 operations
4 Correct 2 ms 256 KB [n = 8, m = 10000], OK, 16 operations
5 Correct 2 ms 256 KB [n = 8, m = 10000], OK, 16 operations
6 Correct 2 ms 384 KB [n = 8, m = 10000], OK: No solution
7 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 16 operations
8 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 16 operations
9 Correct 2 ms 384 KB [n = 49, m = 10000], OK, 96 operations
10 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 100 operations
11 Correct 2 ms 384 KB [n = 100, m = 10000], OK, 200 operations
12 Correct 3 ms 256 KB [n = 99, m = 10000], OK, 196 operations
13 Correct 2 ms 256 KB [n = 50, m = 10000], OK, 100 operations
14 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 100 operations
15 Correct 2 ms 384 KB [n = 50, m = 10000], OK: No solution
16 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 100 operations
17 Correct 2 ms 256 KB [n = 50, m = 10000], OK, 100 operations
18 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
19 Correct 4 ms 256 KB [n = 999, m = 10000], OK, 1996 operations
20 Correct 3 ms 256 KB [n = 998, m = 10000], OK, 1996 operations
21 Correct 4 ms 256 KB [n = 997, m = 10000], OK, 1992 operations
22 Correct 3 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
23 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
24 Correct 3 ms 384 KB [n = 1000, m = 10000], OK: No solution
25 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
26 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
27 Correct 9 ms 384 KB [n = 2000, m = 10000], OK, 4000 operations
28 Correct 9 ms 384 KB [n = 1999, m = 10000], OK, 3996 operations
29 Correct 10 ms 384 KB [n = 1998, m = 10000], OK, 3996 operations
30 Correct 8 ms 384 KB [n = 1997, m = 10000], OK, 3992 operations
31 Correct 7 ms 384 KB [n = 2000, m = 10000], OK, 4000 operations
32 Correct 7 ms 384 KB [n = 2000, m = 10000], OK, 4000 operations
33 Correct 7 ms 384 KB [n = 2000, m = 10000], OK: No solution
34 Correct 8 ms 384 KB [n = 2000, m = 10000], OK, 4000 operations
35 Correct 9 ms 384 KB [n = 2000, m = 10000], OK, 4000 operations
36 Correct 8 ms 384 KB [n = 2000, m = 8100], OK, 4000 operations
37 Correct 9 ms 420 KB [n = 1999, m = 8100], OK, 3996 operations
38 Correct 8 ms 384 KB [n = 1998, m = 8100], OK, 3996 operations
39 Correct 8 ms 384 KB [n = 1997, m = 8100], OK, 3992 operations
40 Correct 8 ms 384 KB [n = 1996, m = 8100], OK, 3992 operations
41 Correct 6 ms 256 KB [n = 2000, m = 8100], OK, 4000 operations
42 Correct 7 ms 384 KB [n = 2000, m = 8100], OK, 4000 operations
43 Correct 2 ms 256 KB [n = 2000, m = 8100], OK: No solution
44 Correct 6 ms 256 KB [n = 2000, m = 8100], OK, 4000 operations
45 Correct 8 ms 384 KB [n = 2000, m = 8100], OK, 4000 operations
46 Correct 7 ms 384 KB [n = 2000, m = 6100], OK, 4000 operations
47 Correct 8 ms 256 KB [n = 1999, m = 6100], OK, 3996 operations
48 Correct 8 ms 256 KB [n = 1998, m = 6100], OK, 3996 operations
49 Correct 8 ms 256 KB [n = 1997, m = 6100], OK, 3992 operations
50 Correct 8 ms 256 KB [n = 1996, m = 6100], OK, 3992 operations
51 Correct 7 ms 256 KB [n = 2000, m = 6100], OK, 4000 operations
52 Correct 7 ms 256 KB [n = 2000, m = 6100], OK, 4000 operations
53 Correct 3 ms 256 KB [n = 2000, m = 6100], OK: No solution
54 Correct 7 ms 384 KB [n = 2000, m = 6100], OK, 4000 operations
55 Correct 8 ms 256 KB [n = 2000, m = 6100], OK, 4000 operations
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Correct 2 ms 256 KB [n = 2, m = 10000], OK, 4 operations
3 Correct 2 ms 256 KB [n = 8, m = 10000], OK, 16 operations
4 Correct 2 ms 256 KB [n = 8, m = 10000], OK, 16 operations
5 Correct 2 ms 256 KB [n = 8, m = 10000], OK, 16 operations
6 Correct 2 ms 384 KB [n = 8, m = 10000], OK: No solution
7 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 16 operations
8 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 16 operations
9 Correct 2 ms 384 KB [n = 49, m = 10000], OK, 96 operations
10 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 100 operations
11 Correct 2 ms 384 KB [n = 100, m = 10000], OK, 200 operations
12 Correct 3 ms 256 KB [n = 99, m = 10000], OK, 196 operations
13 Correct 2 ms 256 KB [n = 50, m = 10000], OK, 100 operations
14 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 100 operations
15 Correct 2 ms 384 KB [n = 50, m = 10000], OK: No solution
16 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 100 operations
17 Correct 2 ms 256 KB [n = 50, m = 10000], OK, 100 operations
18 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
19 Correct 4 ms 256 KB [n = 999, m = 10000], OK, 1996 operations
20 Correct 3 ms 256 KB [n = 998, m = 10000], OK, 1996 operations
21 Correct 4 ms 256 KB [n = 997, m = 10000], OK, 1992 operations
22 Correct 3 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
23 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
24 Correct 3 ms 384 KB [n = 1000, m = 10000], OK: No solution
25 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
26 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 2000 operations
27 Correct 9 ms 384 KB [n = 2000, m = 10000], OK, 4000 operations
28 Correct 9 ms 384 KB [n = 1999, m = 10000], OK, 3996 operations
29 Correct 10 ms 384 KB [n = 1998, m = 10000], OK, 3996 operations
30 Correct 8 ms 384 KB [n = 1997, m = 10000], OK, 3992 operations
31 Correct 7 ms 384 KB [n = 2000, m = 10000], OK, 4000 operations
32 Correct 7 ms 384 KB [n = 2000, m = 10000], OK, 4000 operations
33 Correct 7 ms 384 KB [n = 2000, m = 10000], OK: No solution
34 Correct 8 ms 384 KB [n = 2000, m = 10000], OK, 4000 operations
35 Correct 9 ms 384 KB [n = 2000, m = 10000], OK, 4000 operations
36 Correct 8 ms 384 KB [n = 2000, m = 8100], OK, 4000 operations
37 Correct 9 ms 420 KB [n = 1999, m = 8100], OK, 3996 operations
38 Correct 8 ms 384 KB [n = 1998, m = 8100], OK, 3996 operations
39 Correct 8 ms 384 KB [n = 1997, m = 8100], OK, 3992 operations
40 Correct 8 ms 384 KB [n = 1996, m = 8100], OK, 3992 operations
41 Correct 6 ms 256 KB [n = 2000, m = 8100], OK, 4000 operations
42 Correct 7 ms 384 KB [n = 2000, m = 8100], OK, 4000 operations
43 Correct 2 ms 256 KB [n = 2000, m = 8100], OK: No solution
44 Correct 6 ms 256 KB [n = 2000, m = 8100], OK, 4000 operations
45 Correct 8 ms 384 KB [n = 2000, m = 8100], OK, 4000 operations
46 Correct 7 ms 384 KB [n = 2000, m = 6100], OK, 4000 operations
47 Correct 8 ms 256 KB [n = 1999, m = 6100], OK, 3996 operations
48 Correct 8 ms 256 KB [n = 1998, m = 6100], OK, 3996 operations
49 Correct 8 ms 256 KB [n = 1997, m = 6100], OK, 3992 operations
50 Correct 8 ms 256 KB [n = 1996, m = 6100], OK, 3992 operations
51 Correct 7 ms 256 KB [n = 2000, m = 6100], OK, 4000 operations
52 Correct 7 ms 256 KB [n = 2000, m = 6100], OK, 4000 operations
53 Correct 3 ms 256 KB [n = 2000, m = 6100], OK: No solution
54 Correct 7 ms 384 KB [n = 2000, m = 6100], OK, 4000 operations
55 Correct 8 ms 256 KB [n = 2000, m = 6100], OK, 4000 operations
56 Correct 8 ms 384 KB [n = 2000, m = 5100], OK, 4000 operations
57 Correct 8 ms 384 KB [n = 1999, m = 5100], OK, 3996 operations
58 Correct 8 ms 384 KB [n = 1998, m = 5100], OK, 3996 operations
59 Correct 8 ms 384 KB [n = 1997, m = 5100], OK, 3992 operations
60 Correct 8 ms 384 KB [n = 1996, m = 5100], OK, 3992 operations
61 Correct 7 ms 256 KB [n = 1995, m = 5100], OK, 3988 operations
62 Correct 8 ms 384 KB [n = 1994, m = 5100], OK, 3988 operations
63 Correct 8 ms 384 KB [n = 2000, m = 5100], OK, 4000 operations
64 Correct 7 ms 372 KB [n = 2000, m = 5100], OK, 4000 operations
65 Correct 7 ms 384 KB [n = 2000, m = 5100], OK, 4000 operations
66 Correct 3 ms 256 KB [n = 2000, m = 5100], OK: No solution
67 Correct 9 ms 384 KB [n = 2000, m = 5100], OK, 4000 operations