Submission #282868

# Submission time Handle Problem Language Result Execution time Memory
282868 2020-08-25T05:42:28 Z 문홍윤(#5763) Lock Puzzle (innopolis2018_final_A) C++17
78 / 100
30 ms 436 KB
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define svec(x) sort(x.begin(), x.end())
#define press(x) x.erase(unique(x.begin(), x.end()), x.end())
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
const LL llinf=2e18;
const int inf=1e9;

int n;
char str1[2010], str2[2010];

char tmp[2010];
vector<int> ans;
void calc(int x){
    ans.eb(x);
    int re=0;
    for(int i=n; i>n-x; i--)tmp[++re]=str1[i];
    for(int i=1; i<=n-x; i++)tmp[++re]=str1[i];
    for(int i=1; i<=n; i++)str1[i]=tmp[i];
}

int main(){
    scanf("%d %*d %s %s", &n, str1+1, str2+1);
    for(int i=n; i>=1; i--){
        int nw=-1;
        for(int j=i; j>=1; j--){
            if(str2[i]==str1[j]){
                nw=j;
                break;
            }
        }
        if(nw==-1)return !printf("-1");
        calc(n-nw);
        calc(n);
        calc(n-i);
        calc(n);
    }
    printf("%d\n", ans.size());
    for(auto i:ans)printf("%d ", i);
}

Compilation message

A.cpp: In function 'int main()':
A.cpp:47:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   47 |     printf("%d\n", ans.size());
      |             ~^     ~~~~~~~~~~
      |              |             |
      |              int           std::vector<int>::size_type {aka long unsigned int}
      |             %ld
A.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   32 |     scanf("%d %*d %s %s", &n, str1+1, str2+1);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB [n = 1, m = 10000], OK, 4 operations
2 Correct 0 ms 256 KB [n = 2, m = 10000], OK, 8 operations
3 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 32 operations
4 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 32 operations
5 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 32 operations
6 Correct 0 ms 256 KB [n = 8, m = 10000], OK: No solution
7 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 32 operations
8 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 32 operations
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB [n = 1, m = 10000], OK, 4 operations
2 Correct 0 ms 256 KB [n = 2, m = 10000], OK, 8 operations
3 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 32 operations
4 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 32 operations
5 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 32 operations
6 Correct 0 ms 256 KB [n = 8, m = 10000], OK: No solution
7 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 32 operations
8 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 32 operations
9 Correct 1 ms 256 KB [n = 49, m = 10000], OK, 196 operations
10 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 200 operations
11 Correct 1 ms 256 KB [n = 100, m = 10000], OK, 400 operations
12 Correct 1 ms 256 KB [n = 99, m = 10000], OK, 396 operations
13 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 200 operations
14 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 200 operations
15 Correct 1 ms 256 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 200 operations
17 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 200 operations
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB [n = 1, m = 10000], OK, 4 operations
2 Correct 0 ms 256 KB [n = 2, m = 10000], OK, 8 operations
3 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 32 operations
4 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 32 operations
5 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 32 operations
6 Correct 0 ms 256 KB [n = 8, m = 10000], OK: No solution
7 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 32 operations
8 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 32 operations
9 Correct 1 ms 256 KB [n = 49, m = 10000], OK, 196 operations
10 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 200 operations
11 Correct 1 ms 256 KB [n = 100, m = 10000], OK, 400 operations
12 Correct 1 ms 256 KB [n = 99, m = 10000], OK, 396 operations
13 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 200 operations
14 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 200 operations
15 Correct 1 ms 256 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 200 operations
17 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 200 operations
18 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
19 Correct 7 ms 384 KB [n = 999, m = 10000], OK, 3996 operations
20 Correct 6 ms 384 KB [n = 998, m = 10000], OK, 3992 operations
21 Correct 6 ms 384 KB [n = 997, m = 10000], OK, 3988 operations
22 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
23 Correct 8 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
24 Correct 6 ms 384 KB [n = 1000, m = 10000], OK: No solution
25 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
26 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB [n = 1, m = 10000], OK, 4 operations
2 Correct 0 ms 256 KB [n = 2, m = 10000], OK, 8 operations
3 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 32 operations
4 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 32 operations
5 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 32 operations
6 Correct 0 ms 256 KB [n = 8, m = 10000], OK: No solution
7 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 32 operations
8 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 32 operations
9 Correct 1 ms 256 KB [n = 49, m = 10000], OK, 196 operations
10 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 200 operations
11 Correct 1 ms 256 KB [n = 100, m = 10000], OK, 400 operations
12 Correct 1 ms 256 KB [n = 99, m = 10000], OK, 396 operations
13 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 200 operations
14 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 200 operations
15 Correct 1 ms 256 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 200 operations
17 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 200 operations
18 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
19 Correct 7 ms 384 KB [n = 999, m = 10000], OK, 3996 operations
20 Correct 6 ms 384 KB [n = 998, m = 10000], OK, 3992 operations
21 Correct 6 ms 384 KB [n = 997, m = 10000], OK, 3988 operations
22 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
23 Correct 8 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
24 Correct 6 ms 384 KB [n = 1000, m = 10000], OK: No solution
25 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
26 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
27 Correct 25 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
28 Correct 30 ms 384 KB [n = 1999, m = 10000], OK, 7996 operations
29 Correct 24 ms 384 KB [n = 1998, m = 10000], OK, 7992 operations
30 Correct 25 ms 384 KB [n = 1997, m = 10000], OK, 7988 operations
31 Correct 24 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
32 Correct 24 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
33 Correct 23 ms 384 KB [n = 2000, m = 10000], OK: No solution
34 Correct 24 ms 432 KB [n = 2000, m = 10000], OK, 8000 operations
35 Correct 24 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB [n = 1, m = 10000], OK, 4 operations
2 Correct 0 ms 256 KB [n = 2, m = 10000], OK, 8 operations
3 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 32 operations
4 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 32 operations
5 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 32 operations
6 Correct 0 ms 256 KB [n = 8, m = 10000], OK: No solution
7 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 32 operations
8 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 32 operations
9 Correct 1 ms 256 KB [n = 49, m = 10000], OK, 196 operations
10 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 200 operations
11 Correct 1 ms 256 KB [n = 100, m = 10000], OK, 400 operations
12 Correct 1 ms 256 KB [n = 99, m = 10000], OK, 396 operations
13 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 200 operations
14 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 200 operations
15 Correct 1 ms 256 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 200 operations
17 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 200 operations
18 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
19 Correct 7 ms 384 KB [n = 999, m = 10000], OK, 3996 operations
20 Correct 6 ms 384 KB [n = 998, m = 10000], OK, 3992 operations
21 Correct 6 ms 384 KB [n = 997, m = 10000], OK, 3988 operations
22 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
23 Correct 8 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
24 Correct 6 ms 384 KB [n = 1000, m = 10000], OK: No solution
25 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
26 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
27 Correct 25 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
28 Correct 30 ms 384 KB [n = 1999, m = 10000], OK, 7996 operations
29 Correct 24 ms 384 KB [n = 1998, m = 10000], OK, 7992 operations
30 Correct 25 ms 384 KB [n = 1997, m = 10000], OK, 7988 operations
31 Correct 24 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
32 Correct 24 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
33 Correct 23 ms 384 KB [n = 2000, m = 10000], OK: No solution
34 Correct 24 ms 432 KB [n = 2000, m = 10000], OK, 8000 operations
35 Correct 24 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
36 Correct 25 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
37 Correct 25 ms 384 KB [n = 1999, m = 8100], OK, 7996 operations
38 Correct 24 ms 384 KB [n = 1998, m = 8100], OK, 7992 operations
39 Correct 29 ms 384 KB [n = 1997, m = 8100], OK, 7988 operations
40 Correct 24 ms 384 KB [n = 1996, m = 8100], OK, 7984 operations
41 Correct 24 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
42 Correct 24 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
43 Correct 24 ms 436 KB [n = 2000, m = 8100], OK: No solution
44 Correct 26 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
45 Correct 24 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB [n = 1, m = 10000], OK, 4 operations
2 Correct 0 ms 256 KB [n = 2, m = 10000], OK, 8 operations
3 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 32 operations
4 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 32 operations
5 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 32 operations
6 Correct 0 ms 256 KB [n = 8, m = 10000], OK: No solution
7 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 32 operations
8 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 32 operations
9 Correct 1 ms 256 KB [n = 49, m = 10000], OK, 196 operations
10 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 200 operations
11 Correct 1 ms 256 KB [n = 100, m = 10000], OK, 400 operations
12 Correct 1 ms 256 KB [n = 99, m = 10000], OK, 396 operations
13 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 200 operations
14 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 200 operations
15 Correct 1 ms 256 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 200 operations
17 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 200 operations
18 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
19 Correct 7 ms 384 KB [n = 999, m = 10000], OK, 3996 operations
20 Correct 6 ms 384 KB [n = 998, m = 10000], OK, 3992 operations
21 Correct 6 ms 384 KB [n = 997, m = 10000], OK, 3988 operations
22 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
23 Correct 8 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
24 Correct 6 ms 384 KB [n = 1000, m = 10000], OK: No solution
25 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
26 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
27 Correct 25 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
28 Correct 30 ms 384 KB [n = 1999, m = 10000], OK, 7996 operations
29 Correct 24 ms 384 KB [n = 1998, m = 10000], OK, 7992 operations
30 Correct 25 ms 384 KB [n = 1997, m = 10000], OK, 7988 operations
31 Correct 24 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
32 Correct 24 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
33 Correct 23 ms 384 KB [n = 2000, m = 10000], OK: No solution
34 Correct 24 ms 432 KB [n = 2000, m = 10000], OK, 8000 operations
35 Correct 24 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
36 Correct 25 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
37 Correct 25 ms 384 KB [n = 1999, m = 8100], OK, 7996 operations
38 Correct 24 ms 384 KB [n = 1998, m = 8100], OK, 7992 operations
39 Correct 29 ms 384 KB [n = 1997, m = 8100], OK, 7988 operations
40 Correct 24 ms 384 KB [n = 1996, m = 8100], OK, 7984 operations
41 Correct 24 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
42 Correct 24 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
43 Correct 24 ms 436 KB [n = 2000, m = 8100], OK: No solution
44 Correct 26 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
45 Correct 24 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
46 Incorrect 24 ms 384 KB Integer 8000 violates the range [-1, 6100]
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB [n = 1, m = 10000], OK, 4 operations
2 Correct 0 ms 256 KB [n = 2, m = 10000], OK, 8 operations
3 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 32 operations
4 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 32 operations
5 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 32 operations
6 Correct 0 ms 256 KB [n = 8, m = 10000], OK: No solution
7 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 32 operations
8 Correct 0 ms 256 KB [n = 8, m = 10000], OK, 32 operations
9 Correct 1 ms 256 KB [n = 49, m = 10000], OK, 196 operations
10 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 200 operations
11 Correct 1 ms 256 KB [n = 100, m = 10000], OK, 400 operations
12 Correct 1 ms 256 KB [n = 99, m = 10000], OK, 396 operations
13 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 200 operations
14 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 200 operations
15 Correct 1 ms 256 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 256 KB [n = 50, m = 10000], OK, 200 operations
17 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 200 operations
18 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
19 Correct 7 ms 384 KB [n = 999, m = 10000], OK, 3996 operations
20 Correct 6 ms 384 KB [n = 998, m = 10000], OK, 3992 operations
21 Correct 6 ms 384 KB [n = 997, m = 10000], OK, 3988 operations
22 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
23 Correct 8 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
24 Correct 6 ms 384 KB [n = 1000, m = 10000], OK: No solution
25 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
26 Correct 7 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
27 Correct 25 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
28 Correct 30 ms 384 KB [n = 1999, m = 10000], OK, 7996 operations
29 Correct 24 ms 384 KB [n = 1998, m = 10000], OK, 7992 operations
30 Correct 25 ms 384 KB [n = 1997, m = 10000], OK, 7988 operations
31 Correct 24 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
32 Correct 24 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
33 Correct 23 ms 384 KB [n = 2000, m = 10000], OK: No solution
34 Correct 24 ms 432 KB [n = 2000, m = 10000], OK, 8000 operations
35 Correct 24 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
36 Correct 25 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
37 Correct 25 ms 384 KB [n = 1999, m = 8100], OK, 7996 operations
38 Correct 24 ms 384 KB [n = 1998, m = 8100], OK, 7992 operations
39 Correct 29 ms 384 KB [n = 1997, m = 8100], OK, 7988 operations
40 Correct 24 ms 384 KB [n = 1996, m = 8100], OK, 7984 operations
41 Correct 24 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
42 Correct 24 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
43 Correct 24 ms 436 KB [n = 2000, m = 8100], OK: No solution
44 Correct 26 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
45 Correct 24 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
46 Incorrect 24 ms 384 KB Integer 8000 violates the range [-1, 6100]
47 Halted 0 ms 0 KB -