Submission #283696

# Submission time Handle Problem Language Result Execution time Memory
283696 2020-08-26T05:42:22 Z arnold518 Lock Puzzle (innopolis2018_final_A) C++14
78 / 100
3 ms 512 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 2000;

int N, M;
char S[MAXN+10];
char T[MAXN+10];

int cnt[30];

vector<int> V;
void f(int x)
{
	reverse(S+1, S+x+1);
	V.push_back(N-x);
	V.push_back(N-1);
}

int main()
{
	scanf("%d%d", &N, &M);
	scanf(" %s", S+1);
	scanf(" %s", T+1);

	for(int i=1; i<=N; i++) cnt[S[i]-'a']++, cnt[T[i]-'a']--;
	for(int i=0; i<26; i++) if(cnt[i]!=0) return !printf("-1\n");

	for(int i=N; i>=1; i--)
	{
		if(S[i]==T[i]) continue;
		int p;
		for(int j=1; j<i; j++) if(S[j]==T[i]) { p=j; break; }
		f(p);
		f(i);
	}
	printf("%d\n", V.size());
	for(auto it : V) printf("%d ", it);
}

Compilation message

A.cpp: In function 'int main()':
A.cpp:41:11: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   41 |  printf("%d\n", V.size());
      |          ~^     ~~~~~~~~
      |           |           |
      |           int         std::vector<int>::size_type {aka long unsigned int}
      |          %ld
A.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |  scanf("%d%d", &N, &M);
      |  ~~~~~^~~~~~~~~~~~~~~~
A.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   27 |  scanf(" %s", S+1);
      |  ~~~~~^~~~~~~~~~~~
A.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   28 |  scanf(" %s", T+1);
      |  ~~~~~^~~~~~~~~~~~
A.cpp:38:4: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
   38 |   f(p);
      |   ~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Correct 1 ms 256 KB [n = 2, m = 10000], OK, 4 operations
3 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 20 operations
4 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 4 operations
5 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 20 operations
6 Correct 1 ms 256 KB [n = 8, m = 10000], OK: No solution
7 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 8 operations
8 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 0 operations
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Correct 1 ms 256 KB [n = 2, m = 10000], OK, 4 operations
3 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 20 operations
4 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 4 operations
5 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 20 operations
6 Correct 1 ms 256 KB [n = 8, m = 10000], OK: No solution
7 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 8 operations
8 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 0 operations
9 Correct 1 ms 384 KB [n = 49, m = 10000], OK, 180 operations
10 Correct 1 ms 384 KB [n = 50, m = 10000], OK, 168 operations
11 Correct 1 ms 384 KB [n = 100, m = 10000], OK, 356 operations
12 Correct 1 ms 256 KB [n = 99, m = 10000], OK, 376 operations
13 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 32 operations
14 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 104 operations
15 Correct 0 ms 256 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 76 operations
17 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 0 operations
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Correct 1 ms 256 KB [n = 2, m = 10000], OK, 4 operations
3 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 20 operations
4 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 4 operations
5 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 20 operations
6 Correct 1 ms 256 KB [n = 8, m = 10000], OK: No solution
7 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 8 operations
8 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 0 operations
9 Correct 1 ms 384 KB [n = 49, m = 10000], OK, 180 operations
10 Correct 1 ms 384 KB [n = 50, m = 10000], OK, 168 operations
11 Correct 1 ms 384 KB [n = 100, m = 10000], OK, 356 operations
12 Correct 1 ms 256 KB [n = 99, m = 10000], OK, 376 operations
13 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 32 operations
14 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 104 operations
15 Correct 0 ms 256 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 76 operations
17 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 0 operations
18 Correct 1 ms 408 KB [n = 1000, m = 10000], OK, 3804 operations
19 Correct 1 ms 384 KB [n = 999, m = 10000], OK, 3844 operations
20 Correct 1 ms 384 KB [n = 998, m = 10000], OK, 3788 operations
21 Correct 2 ms 384 KB [n = 997, m = 10000], OK, 3764 operations
22 Correct 1 ms 384 KB [n = 1000, m = 10000], OK, 204 operations
23 Correct 1 ms 384 KB [n = 1000, m = 10000], OK, 2588 operations
24 Correct 1 ms 288 KB [n = 1000, m = 10000], OK: No solution
25 Correct 1 ms 384 KB [n = 1000, m = 10000], OK, 1788 operations
26 Correct 0 ms 256 KB [n = 1000, m = 10000], OK, 0 operations
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Correct 1 ms 256 KB [n = 2, m = 10000], OK, 4 operations
3 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 20 operations
4 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 4 operations
5 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 20 operations
6 Correct 1 ms 256 KB [n = 8, m = 10000], OK: No solution
7 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 8 operations
8 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 0 operations
9 Correct 1 ms 384 KB [n = 49, m = 10000], OK, 180 operations
10 Correct 1 ms 384 KB [n = 50, m = 10000], OK, 168 operations
11 Correct 1 ms 384 KB [n = 100, m = 10000], OK, 356 operations
12 Correct 1 ms 256 KB [n = 99, m = 10000], OK, 376 operations
13 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 32 operations
14 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 104 operations
15 Correct 0 ms 256 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 76 operations
17 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 0 operations
18 Correct 1 ms 408 KB [n = 1000, m = 10000], OK, 3804 operations
19 Correct 1 ms 384 KB [n = 999, m = 10000], OK, 3844 operations
20 Correct 1 ms 384 KB [n = 998, m = 10000], OK, 3788 operations
21 Correct 2 ms 384 KB [n = 997, m = 10000], OK, 3764 operations
22 Correct 1 ms 384 KB [n = 1000, m = 10000], OK, 204 operations
23 Correct 1 ms 384 KB [n = 1000, m = 10000], OK, 2588 operations
24 Correct 1 ms 288 KB [n = 1000, m = 10000], OK: No solution
25 Correct 1 ms 384 KB [n = 1000, m = 10000], OK, 1788 operations
26 Correct 0 ms 256 KB [n = 1000, m = 10000], OK, 0 operations
27 Correct 3 ms 384 KB [n = 2000, m = 10000], OK, 7696 operations
28 Correct 3 ms 384 KB [n = 1999, m = 10000], OK, 7564 operations
29 Correct 3 ms 512 KB [n = 1998, m = 10000], OK, 7620 operations
30 Correct 3 ms 384 KB [n = 1997, m = 10000], OK, 7672 operations
31 Correct 1 ms 256 KB [n = 2000, m = 10000], OK, 668 operations
32 Correct 2 ms 384 KB [n = 2000, m = 10000], OK, 5428 operations
33 Correct 1 ms 256 KB [n = 2000, m = 10000], OK: No solution
34 Correct 3 ms 384 KB [n = 2000, m = 10000], OK, 4316 operations
35 Correct 1 ms 384 KB [n = 2000, m = 10000], OK, 0 operations
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Correct 1 ms 256 KB [n = 2, m = 10000], OK, 4 operations
3 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 20 operations
4 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 4 operations
5 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 20 operations
6 Correct 1 ms 256 KB [n = 8, m = 10000], OK: No solution
7 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 8 operations
8 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 0 operations
9 Correct 1 ms 384 KB [n = 49, m = 10000], OK, 180 operations
10 Correct 1 ms 384 KB [n = 50, m = 10000], OK, 168 operations
11 Correct 1 ms 384 KB [n = 100, m = 10000], OK, 356 operations
12 Correct 1 ms 256 KB [n = 99, m = 10000], OK, 376 operations
13 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 32 operations
14 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 104 operations
15 Correct 0 ms 256 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 76 operations
17 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 0 operations
18 Correct 1 ms 408 KB [n = 1000, m = 10000], OK, 3804 operations
19 Correct 1 ms 384 KB [n = 999, m = 10000], OK, 3844 operations
20 Correct 1 ms 384 KB [n = 998, m = 10000], OK, 3788 operations
21 Correct 2 ms 384 KB [n = 997, m = 10000], OK, 3764 operations
22 Correct 1 ms 384 KB [n = 1000, m = 10000], OK, 204 operations
23 Correct 1 ms 384 KB [n = 1000, m = 10000], OK, 2588 operations
24 Correct 1 ms 288 KB [n = 1000, m = 10000], OK: No solution
25 Correct 1 ms 384 KB [n = 1000, m = 10000], OK, 1788 operations
26 Correct 0 ms 256 KB [n = 1000, m = 10000], OK, 0 operations
27 Correct 3 ms 384 KB [n = 2000, m = 10000], OK, 7696 operations
28 Correct 3 ms 384 KB [n = 1999, m = 10000], OK, 7564 operations
29 Correct 3 ms 512 KB [n = 1998, m = 10000], OK, 7620 operations
30 Correct 3 ms 384 KB [n = 1997, m = 10000], OK, 7672 operations
31 Correct 1 ms 256 KB [n = 2000, m = 10000], OK, 668 operations
32 Correct 2 ms 384 KB [n = 2000, m = 10000], OK, 5428 operations
33 Correct 1 ms 256 KB [n = 2000, m = 10000], OK: No solution
34 Correct 3 ms 384 KB [n = 2000, m = 10000], OK, 4316 operations
35 Correct 1 ms 384 KB [n = 2000, m = 10000], OK, 0 operations
36 Correct 3 ms 384 KB [n = 2000, m = 8100], OK, 7604 operations
37 Correct 3 ms 384 KB [n = 1999, m = 8100], OK, 7700 operations
38 Correct 3 ms 384 KB [n = 1998, m = 8100], OK, 7688 operations
39 Correct 3 ms 384 KB [n = 1997, m = 8100], OK, 7676 operations
40 Correct 3 ms 384 KB [n = 1996, m = 8100], OK, 7680 operations
41 Correct 1 ms 384 KB [n = 2000, m = 8100], OK, 668 operations
42 Correct 2 ms 384 KB [n = 2000, m = 8100], OK, 5624 operations
43 Correct 1 ms 256 KB [n = 2000, m = 8100], OK: No solution
44 Correct 3 ms 384 KB [n = 2000, m = 8100], OK, 4040 operations
45 Correct 1 ms 256 KB [n = 2000, m = 8100], OK, 0 operations
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Correct 1 ms 256 KB [n = 2, m = 10000], OK, 4 operations
3 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 20 operations
4 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 4 operations
5 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 20 operations
6 Correct 1 ms 256 KB [n = 8, m = 10000], OK: No solution
7 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 8 operations
8 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 0 operations
9 Correct 1 ms 384 KB [n = 49, m = 10000], OK, 180 operations
10 Correct 1 ms 384 KB [n = 50, m = 10000], OK, 168 operations
11 Correct 1 ms 384 KB [n = 100, m = 10000], OK, 356 operations
12 Correct 1 ms 256 KB [n = 99, m = 10000], OK, 376 operations
13 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 32 operations
14 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 104 operations
15 Correct 0 ms 256 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 76 operations
17 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 0 operations
18 Correct 1 ms 408 KB [n = 1000, m = 10000], OK, 3804 operations
19 Correct 1 ms 384 KB [n = 999, m = 10000], OK, 3844 operations
20 Correct 1 ms 384 KB [n = 998, m = 10000], OK, 3788 operations
21 Correct 2 ms 384 KB [n = 997, m = 10000], OK, 3764 operations
22 Correct 1 ms 384 KB [n = 1000, m = 10000], OK, 204 operations
23 Correct 1 ms 384 KB [n = 1000, m = 10000], OK, 2588 operations
24 Correct 1 ms 288 KB [n = 1000, m = 10000], OK: No solution
25 Correct 1 ms 384 KB [n = 1000, m = 10000], OK, 1788 operations
26 Correct 0 ms 256 KB [n = 1000, m = 10000], OK, 0 operations
27 Correct 3 ms 384 KB [n = 2000, m = 10000], OK, 7696 operations
28 Correct 3 ms 384 KB [n = 1999, m = 10000], OK, 7564 operations
29 Correct 3 ms 512 KB [n = 1998, m = 10000], OK, 7620 operations
30 Correct 3 ms 384 KB [n = 1997, m = 10000], OK, 7672 operations
31 Correct 1 ms 256 KB [n = 2000, m = 10000], OK, 668 operations
32 Correct 2 ms 384 KB [n = 2000, m = 10000], OK, 5428 operations
33 Correct 1 ms 256 KB [n = 2000, m = 10000], OK: No solution
34 Correct 3 ms 384 KB [n = 2000, m = 10000], OK, 4316 operations
35 Correct 1 ms 384 KB [n = 2000, m = 10000], OK, 0 operations
36 Correct 3 ms 384 KB [n = 2000, m = 8100], OK, 7604 operations
37 Correct 3 ms 384 KB [n = 1999, m = 8100], OK, 7700 operations
38 Correct 3 ms 384 KB [n = 1998, m = 8100], OK, 7688 operations
39 Correct 3 ms 384 KB [n = 1997, m = 8100], OK, 7676 operations
40 Correct 3 ms 384 KB [n = 1996, m = 8100], OK, 7680 operations
41 Correct 1 ms 384 KB [n = 2000, m = 8100], OK, 668 operations
42 Correct 2 ms 384 KB [n = 2000, m = 8100], OK, 5624 operations
43 Correct 1 ms 256 KB [n = 2000, m = 8100], OK: No solution
44 Correct 3 ms 384 KB [n = 2000, m = 8100], OK, 4040 operations
45 Correct 1 ms 256 KB [n = 2000, m = 8100], OK, 0 operations
46 Incorrect 3 ms 384 KB Integer 7708 violates the range [-1, 6100]
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Correct 1 ms 256 KB [n = 2, m = 10000], OK, 4 operations
3 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 20 operations
4 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 4 operations
5 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 20 operations
6 Correct 1 ms 256 KB [n = 8, m = 10000], OK: No solution
7 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 8 operations
8 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 0 operations
9 Correct 1 ms 384 KB [n = 49, m = 10000], OK, 180 operations
10 Correct 1 ms 384 KB [n = 50, m = 10000], OK, 168 operations
11 Correct 1 ms 384 KB [n = 100, m = 10000], OK, 356 operations
12 Correct 1 ms 256 KB [n = 99, m = 10000], OK, 376 operations
13 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 32 operations
14 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 104 operations
15 Correct 0 ms 256 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 76 operations
17 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 0 operations
18 Correct 1 ms 408 KB [n = 1000, m = 10000], OK, 3804 operations
19 Correct 1 ms 384 KB [n = 999, m = 10000], OK, 3844 operations
20 Correct 1 ms 384 KB [n = 998, m = 10000], OK, 3788 operations
21 Correct 2 ms 384 KB [n = 997, m = 10000], OK, 3764 operations
22 Correct 1 ms 384 KB [n = 1000, m = 10000], OK, 204 operations
23 Correct 1 ms 384 KB [n = 1000, m = 10000], OK, 2588 operations
24 Correct 1 ms 288 KB [n = 1000, m = 10000], OK: No solution
25 Correct 1 ms 384 KB [n = 1000, m = 10000], OK, 1788 operations
26 Correct 0 ms 256 KB [n = 1000, m = 10000], OK, 0 operations
27 Correct 3 ms 384 KB [n = 2000, m = 10000], OK, 7696 operations
28 Correct 3 ms 384 KB [n = 1999, m = 10000], OK, 7564 operations
29 Correct 3 ms 512 KB [n = 1998, m = 10000], OK, 7620 operations
30 Correct 3 ms 384 KB [n = 1997, m = 10000], OK, 7672 operations
31 Correct 1 ms 256 KB [n = 2000, m = 10000], OK, 668 operations
32 Correct 2 ms 384 KB [n = 2000, m = 10000], OK, 5428 operations
33 Correct 1 ms 256 KB [n = 2000, m = 10000], OK: No solution
34 Correct 3 ms 384 KB [n = 2000, m = 10000], OK, 4316 operations
35 Correct 1 ms 384 KB [n = 2000, m = 10000], OK, 0 operations
36 Correct 3 ms 384 KB [n = 2000, m = 8100], OK, 7604 operations
37 Correct 3 ms 384 KB [n = 1999, m = 8100], OK, 7700 operations
38 Correct 3 ms 384 KB [n = 1998, m = 8100], OK, 7688 operations
39 Correct 3 ms 384 KB [n = 1997, m = 8100], OK, 7676 operations
40 Correct 3 ms 384 KB [n = 1996, m = 8100], OK, 7680 operations
41 Correct 1 ms 384 KB [n = 2000, m = 8100], OK, 668 operations
42 Correct 2 ms 384 KB [n = 2000, m = 8100], OK, 5624 operations
43 Correct 1 ms 256 KB [n = 2000, m = 8100], OK: No solution
44 Correct 3 ms 384 KB [n = 2000, m = 8100], OK, 4040 operations
45 Correct 1 ms 256 KB [n = 2000, m = 8100], OK, 0 operations
46 Incorrect 3 ms 384 KB Integer 7708 violates the range [-1, 6100]
47 Halted 0 ms 0 KB -