Submission #113253

# Submission time Handle Problem Language Result Execution time Memory
113253 2019-05-24T12:51:17 Z 김세빈(#2857) Lock Puzzle (innopolis2018_final_A) C++14
89 / 100
14 ms 512 KB
#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 + n - p, A + n);
}

int main()
{
	int i, j;
	
	scanf("%d%d", &n, &m);
	scanf("%s%s", A, B);
	
	for(i=0; i<n; i++){
		reverse(D, D + i);
		D[i] = i;
	}
	
	for(i=0; i<n; i++){
		E[D[i]] = i;
	}
	
	for(i=0; i<n; i++){
		for(j=i; j<n; j++){
			if(A[j] == B[E[i]]) break;
		}
		
		if(j >= n){
			printf("-1\n");
			return 0;
		}
		
		V.push_back(j + 1); shift(j + 1);
		V.push_back(n - j - 1 + i); shift(n - j - 1 + i);
		V.push_back(n - i); shift(n - i);
	}
	
	printf("%d\n", 3 * n);
	
	for(int &t: V) printf("%d ", n - t);
	
	printf("\n");
	
	return 0;
}

Compilation message

A.cpp: In function 'int main()':
A.cpp:20: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:21: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 time Memory Grader output
1 Correct 2 ms 384 KB [n = 1, m = 10000], OK, 3 operations
2 Correct 2 ms 384 KB [n = 2, m = 10000], OK, 6 operations
3 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 operations
4 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 operations
5 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 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, 24 operations
8 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 operations
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB [n = 1, m = 10000], OK, 3 operations
2 Correct 2 ms 384 KB [n = 2, m = 10000], OK, 6 operations
3 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 operations
4 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 operations
5 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 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, 24 operations
8 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 operations
9 Correct 2 ms 384 KB [n = 49, m = 10000], OK, 147 operations
10 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
11 Correct 2 ms 512 KB [n = 100, m = 10000], OK, 300 operations
12 Correct 2 ms 384 KB [n = 99, m = 10000], OK, 297 operations
13 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
14 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
15 Correct 6 ms 256 KB [n = 50, m = 10000], OK: No solution
16 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
17 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB [n = 1, m = 10000], OK, 3 operations
2 Correct 2 ms 384 KB [n = 2, m = 10000], OK, 6 operations
3 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 operations
4 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 operations
5 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 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, 24 operations
8 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 operations
9 Correct 2 ms 384 KB [n = 49, m = 10000], OK, 147 operations
10 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
11 Correct 2 ms 512 KB [n = 100, m = 10000], OK, 300 operations
12 Correct 2 ms 384 KB [n = 99, m = 10000], OK, 297 operations
13 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
14 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
15 Correct 6 ms 256 KB [n = 50, m = 10000], OK: No solution
16 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
17 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
18 Correct 5 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
19 Correct 5 ms 384 KB [n = 999, m = 10000], OK, 2997 operations
20 Correct 4 ms 384 KB [n = 998, m = 10000], OK, 2994 operations
21 Correct 4 ms 384 KB [n = 997, m = 10000], OK, 2991 operations
22 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
23 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
24 Correct 4 ms 512 KB [n = 1000, m = 10000], OK: No solution
25 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
26 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB [n = 1, m = 10000], OK, 3 operations
2 Correct 2 ms 384 KB [n = 2, m = 10000], OK, 6 operations
3 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 operations
4 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 operations
5 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 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, 24 operations
8 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 operations
9 Correct 2 ms 384 KB [n = 49, m = 10000], OK, 147 operations
10 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
11 Correct 2 ms 512 KB [n = 100, m = 10000], OK, 300 operations
12 Correct 2 ms 384 KB [n = 99, m = 10000], OK, 297 operations
13 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
14 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
15 Correct 6 ms 256 KB [n = 50, m = 10000], OK: No solution
16 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
17 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
18 Correct 5 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
19 Correct 5 ms 384 KB [n = 999, m = 10000], OK, 2997 operations
20 Correct 4 ms 384 KB [n = 998, m = 10000], OK, 2994 operations
21 Correct 4 ms 384 KB [n = 997, m = 10000], OK, 2991 operations
22 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
23 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
24 Correct 4 ms 512 KB [n = 1000, m = 10000], OK: No solution
25 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
26 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
27 Correct 11 ms 384 KB [n = 2000, m = 10000], OK, 6000 operations
28 Correct 10 ms 384 KB [n = 1999, m = 10000], OK, 5997 operations
29 Correct 11 ms 384 KB [n = 1998, m = 10000], OK, 5994 operations
30 Correct 11 ms 384 KB [n = 1997, m = 10000], OK, 5991 operations
31 Correct 11 ms 384 KB [n = 2000, m = 10000], OK, 6000 operations
32 Correct 11 ms 384 KB [n = 2000, m = 10000], OK, 6000 operations
33 Correct 10 ms 384 KB [n = 2000, m = 10000], OK: No solution
34 Correct 12 ms 504 KB [n = 2000, m = 10000], OK, 6000 operations
35 Correct 11 ms 512 KB [n = 2000, m = 10000], OK, 6000 operations
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB [n = 1, m = 10000], OK, 3 operations
2 Correct 2 ms 384 KB [n = 2, m = 10000], OK, 6 operations
3 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 operations
4 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 operations
5 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 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, 24 operations
8 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 operations
9 Correct 2 ms 384 KB [n = 49, m = 10000], OK, 147 operations
10 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
11 Correct 2 ms 512 KB [n = 100, m = 10000], OK, 300 operations
12 Correct 2 ms 384 KB [n = 99, m = 10000], OK, 297 operations
13 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
14 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
15 Correct 6 ms 256 KB [n = 50, m = 10000], OK: No solution
16 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
17 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
18 Correct 5 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
19 Correct 5 ms 384 KB [n = 999, m = 10000], OK, 2997 operations
20 Correct 4 ms 384 KB [n = 998, m = 10000], OK, 2994 operations
21 Correct 4 ms 384 KB [n = 997, m = 10000], OK, 2991 operations
22 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
23 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
24 Correct 4 ms 512 KB [n = 1000, m = 10000], OK: No solution
25 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
26 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
27 Correct 11 ms 384 KB [n = 2000, m = 10000], OK, 6000 operations
28 Correct 10 ms 384 KB [n = 1999, m = 10000], OK, 5997 operations
29 Correct 11 ms 384 KB [n = 1998, m = 10000], OK, 5994 operations
30 Correct 11 ms 384 KB [n = 1997, m = 10000], OK, 5991 operations
31 Correct 11 ms 384 KB [n = 2000, m = 10000], OK, 6000 operations
32 Correct 11 ms 384 KB [n = 2000, m = 10000], OK, 6000 operations
33 Correct 10 ms 384 KB [n = 2000, m = 10000], OK: No solution
34 Correct 12 ms 504 KB [n = 2000, m = 10000], OK, 6000 operations
35 Correct 11 ms 512 KB [n = 2000, m = 10000], OK, 6000 operations
36 Correct 14 ms 384 KB [n = 2000, m = 8100], OK, 6000 operations
37 Correct 10 ms 384 KB [n = 1999, m = 8100], OK, 5997 operations
38 Correct 12 ms 384 KB [n = 1998, m = 8100], OK, 5994 operations
39 Correct 11 ms 384 KB [n = 1997, m = 8100], OK, 5991 operations
40 Correct 11 ms 384 KB [n = 1996, m = 8100], OK, 5988 operations
41 Correct 11 ms 384 KB [n = 2000, m = 8100], OK, 6000 operations
42 Correct 11 ms 384 KB [n = 2000, m = 8100], OK, 6000 operations
43 Correct 10 ms 384 KB [n = 2000, m = 8100], OK: No solution
44 Correct 12 ms 384 KB [n = 2000, m = 8100], OK, 6000 operations
45 Correct 11 ms 448 KB [n = 2000, m = 8100], OK, 6000 operations
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB [n = 1, m = 10000], OK, 3 operations
2 Correct 2 ms 384 KB [n = 2, m = 10000], OK, 6 operations
3 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 operations
4 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 operations
5 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 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, 24 operations
8 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 operations
9 Correct 2 ms 384 KB [n = 49, m = 10000], OK, 147 operations
10 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
11 Correct 2 ms 512 KB [n = 100, m = 10000], OK, 300 operations
12 Correct 2 ms 384 KB [n = 99, m = 10000], OK, 297 operations
13 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
14 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
15 Correct 6 ms 256 KB [n = 50, m = 10000], OK: No solution
16 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
17 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
18 Correct 5 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
19 Correct 5 ms 384 KB [n = 999, m = 10000], OK, 2997 operations
20 Correct 4 ms 384 KB [n = 998, m = 10000], OK, 2994 operations
21 Correct 4 ms 384 KB [n = 997, m = 10000], OK, 2991 operations
22 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
23 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
24 Correct 4 ms 512 KB [n = 1000, m = 10000], OK: No solution
25 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
26 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
27 Correct 11 ms 384 KB [n = 2000, m = 10000], OK, 6000 operations
28 Correct 10 ms 384 KB [n = 1999, m = 10000], OK, 5997 operations
29 Correct 11 ms 384 KB [n = 1998, m = 10000], OK, 5994 operations
30 Correct 11 ms 384 KB [n = 1997, m = 10000], OK, 5991 operations
31 Correct 11 ms 384 KB [n = 2000, m = 10000], OK, 6000 operations
32 Correct 11 ms 384 KB [n = 2000, m = 10000], OK, 6000 operations
33 Correct 10 ms 384 KB [n = 2000, m = 10000], OK: No solution
34 Correct 12 ms 504 KB [n = 2000, m = 10000], OK, 6000 operations
35 Correct 11 ms 512 KB [n = 2000, m = 10000], OK, 6000 operations
36 Correct 14 ms 384 KB [n = 2000, m = 8100], OK, 6000 operations
37 Correct 10 ms 384 KB [n = 1999, m = 8100], OK, 5997 operations
38 Correct 12 ms 384 KB [n = 1998, m = 8100], OK, 5994 operations
39 Correct 11 ms 384 KB [n = 1997, m = 8100], OK, 5991 operations
40 Correct 11 ms 384 KB [n = 1996, m = 8100], OK, 5988 operations
41 Correct 11 ms 384 KB [n = 2000, m = 8100], OK, 6000 operations
42 Correct 11 ms 384 KB [n = 2000, m = 8100], OK, 6000 operations
43 Correct 10 ms 384 KB [n = 2000, m = 8100], OK: No solution
44 Correct 12 ms 384 KB [n = 2000, m = 8100], OK, 6000 operations
45 Correct 11 ms 448 KB [n = 2000, m = 8100], OK, 6000 operations
46 Correct 13 ms 384 KB [n = 2000, m = 6100], OK, 6000 operations
47 Correct 10 ms 384 KB [n = 1999, m = 6100], OK, 5997 operations
48 Correct 11 ms 396 KB [n = 1998, m = 6100], OK, 5994 operations
49 Correct 11 ms 384 KB [n = 1997, m = 6100], OK, 5991 operations
50 Correct 11 ms 384 KB [n = 1996, m = 6100], OK, 5988 operations
51 Correct 10 ms 384 KB [n = 2000, m = 6100], OK, 6000 operations
52 Correct 11 ms 384 KB [n = 2000, m = 6100], OK, 6000 operations
53 Correct 11 ms 384 KB [n = 2000, m = 6100], OK: No solution
54 Correct 11 ms 384 KB [n = 2000, m = 6100], OK, 6000 operations
55 Correct 12 ms 384 KB [n = 2000, m = 6100], OK, 6000 operations
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB [n = 1, m = 10000], OK, 3 operations
2 Correct 2 ms 384 KB [n = 2, m = 10000], OK, 6 operations
3 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 operations
4 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 operations
5 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 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, 24 operations
8 Correct 2 ms 384 KB [n = 8, m = 10000], OK, 24 operations
9 Correct 2 ms 384 KB [n = 49, m = 10000], OK, 147 operations
10 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
11 Correct 2 ms 512 KB [n = 100, m = 10000], OK, 300 operations
12 Correct 2 ms 384 KB [n = 99, m = 10000], OK, 297 operations
13 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
14 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
15 Correct 6 ms 256 KB [n = 50, m = 10000], OK: No solution
16 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
17 Correct 2 ms 384 KB [n = 50, m = 10000], OK, 150 operations
18 Correct 5 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
19 Correct 5 ms 384 KB [n = 999, m = 10000], OK, 2997 operations
20 Correct 4 ms 384 KB [n = 998, m = 10000], OK, 2994 operations
21 Correct 4 ms 384 KB [n = 997, m = 10000], OK, 2991 operations
22 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
23 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
24 Correct 4 ms 512 KB [n = 1000, m = 10000], OK: No solution
25 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
26 Correct 4 ms 384 KB [n = 1000, m = 10000], OK, 3000 operations
27 Correct 11 ms 384 KB [n = 2000, m = 10000], OK, 6000 operations
28 Correct 10 ms 384 KB [n = 1999, m = 10000], OK, 5997 operations
29 Correct 11 ms 384 KB [n = 1998, m = 10000], OK, 5994 operations
30 Correct 11 ms 384 KB [n = 1997, m = 10000], OK, 5991 operations
31 Correct 11 ms 384 KB [n = 2000, m = 10000], OK, 6000 operations
32 Correct 11 ms 384 KB [n = 2000, m = 10000], OK, 6000 operations
33 Correct 10 ms 384 KB [n = 2000, m = 10000], OK: No solution
34 Correct 12 ms 504 KB [n = 2000, m = 10000], OK, 6000 operations
35 Correct 11 ms 512 KB [n = 2000, m = 10000], OK, 6000 operations
36 Correct 14 ms 384 KB [n = 2000, m = 8100], OK, 6000 operations
37 Correct 10 ms 384 KB [n = 1999, m = 8100], OK, 5997 operations
38 Correct 12 ms 384 KB [n = 1998, m = 8100], OK, 5994 operations
39 Correct 11 ms 384 KB [n = 1997, m = 8100], OK, 5991 operations
40 Correct 11 ms 384 KB [n = 1996, m = 8100], OK, 5988 operations
41 Correct 11 ms 384 KB [n = 2000, m = 8100], OK, 6000 operations
42 Correct 11 ms 384 KB [n = 2000, m = 8100], OK, 6000 operations
43 Correct 10 ms 384 KB [n = 2000, m = 8100], OK: No solution
44 Correct 12 ms 384 KB [n = 2000, m = 8100], OK, 6000 operations
45 Correct 11 ms 448 KB [n = 2000, m = 8100], OK, 6000 operations
46 Correct 13 ms 384 KB [n = 2000, m = 6100], OK, 6000 operations
47 Correct 10 ms 384 KB [n = 1999, m = 6100], OK, 5997 operations
48 Correct 11 ms 396 KB [n = 1998, m = 6100], OK, 5994 operations
49 Correct 11 ms 384 KB [n = 1997, m = 6100], OK, 5991 operations
50 Correct 11 ms 384 KB [n = 1996, m = 6100], OK, 5988 operations
51 Correct 10 ms 384 KB [n = 2000, m = 6100], OK, 6000 operations
52 Correct 11 ms 384 KB [n = 2000, m = 6100], OK, 6000 operations
53 Correct 11 ms 384 KB [n = 2000, m = 6100], OK: No solution
54 Correct 11 ms 384 KB [n = 2000, m = 6100], OK, 6000 operations
55 Correct 12 ms 384 KB [n = 2000, m = 6100], OK, 6000 operations
56 Incorrect 11 ms 384 KB Integer 6000 violates the range [-1, 5100]
57 Halted 0 ms 0 KB -