Submission #282856

# Submission time Handle Problem Language Result Execution time Memory
282856 2020-08-25T05:03:13 Z 최은수(#5745) Lock Puzzle (innopolis2018_final_A) C++17
78 / 100
16 ms 512 KB
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
string s;
vector<int>ov;
inline void oper(int x)
{
    ov.eb((int)s.size()-x);
    string s1=s.substr(0,x);
    string s2=s.substr(x,(int)s.size()-x);
    reverse(all(s2));
    s=s2+s1;
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin>>n>>m;
    string t;
    cin>>s>>t;
    for(int i=n;i-->0;)
    {
        int pos=-1;
        for(int j=i;j>=0;j--)
        {
            if(s[j]==t[i])
            {
                pos=j;
                break;
            }
        }
        if(pos==-1)
            return cout<<-1<<endl,0;
        oper(pos+1);
        oper(0);
        oper(i+1);
        oper(0);
    }
    cout<<ov.size()<<endl;
    for(int&t:ov)
        cout<<t<<' ';
    cout<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB [n = 1, m = 10000], OK, 4 operations
2 Correct 0 ms 384 KB [n = 2, m = 10000], OK, 8 operations
3 Correct 1 ms 384 KB [n = 8, m = 10000], OK, 32 operations
4 Correct 0 ms 288 KB [n = 8, m = 10000], OK, 32 operations
5 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 32 operations
6 Correct 0 ms 384 KB [n = 8, m = 10000], OK: No solution
7 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 32 operations
8 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 32 operations
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB [n = 1, m = 10000], OK, 4 operations
2 Correct 0 ms 384 KB [n = 2, m = 10000], OK, 8 operations
3 Correct 1 ms 384 KB [n = 8, m = 10000], OK, 32 operations
4 Correct 0 ms 288 KB [n = 8, m = 10000], OK, 32 operations
5 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 32 operations
6 Correct 0 ms 384 KB [n = 8, m = 10000], OK: No solution
7 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 32 operations
8 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 32 operations
9 Correct 0 ms 384 KB [n = 49, m = 10000], OK, 196 operations
10 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 200 operations
11 Correct 1 ms 384 KB [n = 100, m = 10000], OK, 400 operations
12 Correct 1 ms 384 KB [n = 99, m = 10000], OK, 396 operations
13 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 200 operations
14 Correct 1 ms 384 KB [n = 50, m = 10000], OK, 200 operations
15 Correct 0 ms 384 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 200 operations
17 Correct 1 ms 384 KB [n = 50, m = 10000], OK, 200 operations
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB [n = 1, m = 10000], OK, 4 operations
2 Correct 0 ms 384 KB [n = 2, m = 10000], OK, 8 operations
3 Correct 1 ms 384 KB [n = 8, m = 10000], OK, 32 operations
4 Correct 0 ms 288 KB [n = 8, m = 10000], OK, 32 operations
5 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 32 operations
6 Correct 0 ms 384 KB [n = 8, m = 10000], OK: No solution
7 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 32 operations
8 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 32 operations
9 Correct 0 ms 384 KB [n = 49, m = 10000], OK, 196 operations
10 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 200 operations
11 Correct 1 ms 384 KB [n = 100, m = 10000], OK, 400 operations
12 Correct 1 ms 384 KB [n = 99, m = 10000], OK, 396 operations
13 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 200 operations
14 Correct 1 ms 384 KB [n = 50, m = 10000], OK, 200 operations
15 Correct 0 ms 384 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 200 operations
17 Correct 1 ms 384 KB [n = 50, m = 10000], OK, 200 operations
18 Correct 6 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
19 Correct 5 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 6 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
23 Correct 6 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
24 Correct 5 ms 384 KB [n = 1000, m = 10000], OK: No solution
25 Correct 5 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
26 Correct 5 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB [n = 1, m = 10000], OK, 4 operations
2 Correct 0 ms 384 KB [n = 2, m = 10000], OK, 8 operations
3 Correct 1 ms 384 KB [n = 8, m = 10000], OK, 32 operations
4 Correct 0 ms 288 KB [n = 8, m = 10000], OK, 32 operations
5 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 32 operations
6 Correct 0 ms 384 KB [n = 8, m = 10000], OK: No solution
7 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 32 operations
8 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 32 operations
9 Correct 0 ms 384 KB [n = 49, m = 10000], OK, 196 operations
10 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 200 operations
11 Correct 1 ms 384 KB [n = 100, m = 10000], OK, 400 operations
12 Correct 1 ms 384 KB [n = 99, m = 10000], OK, 396 operations
13 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 200 operations
14 Correct 1 ms 384 KB [n = 50, m = 10000], OK, 200 operations
15 Correct 0 ms 384 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 200 operations
17 Correct 1 ms 384 KB [n = 50, m = 10000], OK, 200 operations
18 Correct 6 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
19 Correct 5 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 6 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
23 Correct 6 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
24 Correct 5 ms 384 KB [n = 1000, m = 10000], OK: No solution
25 Correct 5 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
26 Correct 5 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
27 Correct 16 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
28 Correct 16 ms 384 KB [n = 1999, m = 10000], OK, 7996 operations
29 Correct 16 ms 384 KB [n = 1998, m = 10000], OK, 7992 operations
30 Correct 16 ms 384 KB [n = 1997, m = 10000], OK, 7988 operations
31 Correct 15 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
32 Correct 16 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
33 Correct 14 ms 384 KB [n = 2000, m = 10000], OK: No solution
34 Correct 15 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
35 Correct 15 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB [n = 1, m = 10000], OK, 4 operations
2 Correct 0 ms 384 KB [n = 2, m = 10000], OK, 8 operations
3 Correct 1 ms 384 KB [n = 8, m = 10000], OK, 32 operations
4 Correct 0 ms 288 KB [n = 8, m = 10000], OK, 32 operations
5 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 32 operations
6 Correct 0 ms 384 KB [n = 8, m = 10000], OK: No solution
7 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 32 operations
8 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 32 operations
9 Correct 0 ms 384 KB [n = 49, m = 10000], OK, 196 operations
10 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 200 operations
11 Correct 1 ms 384 KB [n = 100, m = 10000], OK, 400 operations
12 Correct 1 ms 384 KB [n = 99, m = 10000], OK, 396 operations
13 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 200 operations
14 Correct 1 ms 384 KB [n = 50, m = 10000], OK, 200 operations
15 Correct 0 ms 384 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 200 operations
17 Correct 1 ms 384 KB [n = 50, m = 10000], OK, 200 operations
18 Correct 6 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
19 Correct 5 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 6 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
23 Correct 6 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
24 Correct 5 ms 384 KB [n = 1000, m = 10000], OK: No solution
25 Correct 5 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
26 Correct 5 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
27 Correct 16 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
28 Correct 16 ms 384 KB [n = 1999, m = 10000], OK, 7996 operations
29 Correct 16 ms 384 KB [n = 1998, m = 10000], OK, 7992 operations
30 Correct 16 ms 384 KB [n = 1997, m = 10000], OK, 7988 operations
31 Correct 15 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
32 Correct 16 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
33 Correct 14 ms 384 KB [n = 2000, m = 10000], OK: No solution
34 Correct 15 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
35 Correct 15 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
36 Correct 16 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
37 Correct 16 ms 384 KB [n = 1999, m = 8100], OK, 7996 operations
38 Correct 16 ms 384 KB [n = 1998, m = 8100], OK, 7992 operations
39 Correct 16 ms 384 KB [n = 1997, m = 8100], OK, 7988 operations
40 Correct 16 ms 512 KB [n = 1996, m = 8100], OK, 7984 operations
41 Correct 16 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
42 Correct 16 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
43 Correct 15 ms 384 KB [n = 2000, m = 8100], OK: No solution
44 Correct 16 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
45 Correct 16 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB [n = 1, m = 10000], OK, 4 operations
2 Correct 0 ms 384 KB [n = 2, m = 10000], OK, 8 operations
3 Correct 1 ms 384 KB [n = 8, m = 10000], OK, 32 operations
4 Correct 0 ms 288 KB [n = 8, m = 10000], OK, 32 operations
5 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 32 operations
6 Correct 0 ms 384 KB [n = 8, m = 10000], OK: No solution
7 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 32 operations
8 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 32 operations
9 Correct 0 ms 384 KB [n = 49, m = 10000], OK, 196 operations
10 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 200 operations
11 Correct 1 ms 384 KB [n = 100, m = 10000], OK, 400 operations
12 Correct 1 ms 384 KB [n = 99, m = 10000], OK, 396 operations
13 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 200 operations
14 Correct 1 ms 384 KB [n = 50, m = 10000], OK, 200 operations
15 Correct 0 ms 384 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 200 operations
17 Correct 1 ms 384 KB [n = 50, m = 10000], OK, 200 operations
18 Correct 6 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
19 Correct 5 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 6 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
23 Correct 6 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
24 Correct 5 ms 384 KB [n = 1000, m = 10000], OK: No solution
25 Correct 5 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
26 Correct 5 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
27 Correct 16 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
28 Correct 16 ms 384 KB [n = 1999, m = 10000], OK, 7996 operations
29 Correct 16 ms 384 KB [n = 1998, m = 10000], OK, 7992 operations
30 Correct 16 ms 384 KB [n = 1997, m = 10000], OK, 7988 operations
31 Correct 15 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
32 Correct 16 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
33 Correct 14 ms 384 KB [n = 2000, m = 10000], OK: No solution
34 Correct 15 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
35 Correct 15 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
36 Correct 16 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
37 Correct 16 ms 384 KB [n = 1999, m = 8100], OK, 7996 operations
38 Correct 16 ms 384 KB [n = 1998, m = 8100], OK, 7992 operations
39 Correct 16 ms 384 KB [n = 1997, m = 8100], OK, 7988 operations
40 Correct 16 ms 512 KB [n = 1996, m = 8100], OK, 7984 operations
41 Correct 16 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
42 Correct 16 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
43 Correct 15 ms 384 KB [n = 2000, m = 8100], OK: No solution
44 Correct 16 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
45 Correct 16 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
46 Incorrect 16 ms 428 KB Integer 8000 violates the range [-1, 6100]
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB [n = 1, m = 10000], OK, 4 operations
2 Correct 0 ms 384 KB [n = 2, m = 10000], OK, 8 operations
3 Correct 1 ms 384 KB [n = 8, m = 10000], OK, 32 operations
4 Correct 0 ms 288 KB [n = 8, m = 10000], OK, 32 operations
5 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 32 operations
6 Correct 0 ms 384 KB [n = 8, m = 10000], OK: No solution
7 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 32 operations
8 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 32 operations
9 Correct 0 ms 384 KB [n = 49, m = 10000], OK, 196 operations
10 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 200 operations
11 Correct 1 ms 384 KB [n = 100, m = 10000], OK, 400 operations
12 Correct 1 ms 384 KB [n = 99, m = 10000], OK, 396 operations
13 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 200 operations
14 Correct 1 ms 384 KB [n = 50, m = 10000], OK, 200 operations
15 Correct 0 ms 384 KB [n = 50, m = 10000], OK: No solution
16 Correct 0 ms 384 KB [n = 50, m = 10000], OK, 200 operations
17 Correct 1 ms 384 KB [n = 50, m = 10000], OK, 200 operations
18 Correct 6 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
19 Correct 5 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 6 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
23 Correct 6 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
24 Correct 5 ms 384 KB [n = 1000, m = 10000], OK: No solution
25 Correct 5 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
26 Correct 5 ms 384 KB [n = 1000, m = 10000], OK, 4000 operations
27 Correct 16 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
28 Correct 16 ms 384 KB [n = 1999, m = 10000], OK, 7996 operations
29 Correct 16 ms 384 KB [n = 1998, m = 10000], OK, 7992 operations
30 Correct 16 ms 384 KB [n = 1997, m = 10000], OK, 7988 operations
31 Correct 15 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
32 Correct 16 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
33 Correct 14 ms 384 KB [n = 2000, m = 10000], OK: No solution
34 Correct 15 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
35 Correct 15 ms 384 KB [n = 2000, m = 10000], OK, 8000 operations
36 Correct 16 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
37 Correct 16 ms 384 KB [n = 1999, m = 8100], OK, 7996 operations
38 Correct 16 ms 384 KB [n = 1998, m = 8100], OK, 7992 operations
39 Correct 16 ms 384 KB [n = 1997, m = 8100], OK, 7988 operations
40 Correct 16 ms 512 KB [n = 1996, m = 8100], OK, 7984 operations
41 Correct 16 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
42 Correct 16 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
43 Correct 15 ms 384 KB [n = 2000, m = 8100], OK: No solution
44 Correct 16 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
45 Correct 16 ms 384 KB [n = 2000, m = 8100], OK, 8000 operations
46 Incorrect 16 ms 428 KB Integer 8000 violates the range [-1, 6100]
47 Halted 0 ms 0 KB -