Submission #282866

# Submission time Handle Problem Language Result Execution time Memory
282866 2020-08-25T05:38:53 Z 최은수(#5745) Lock Puzzle (innopolis2018_final_A) C++17
0 / 100
0 ms 384 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;
    {
        string s1=s,t1=t;
        sort(all(s1));
        sort(all(t1));
        if(s1!=t1)
            return cout<<-1<<endl,0;
    }
    for(int i=0;i+1<n;i+=2)
    {
        int p1=-1;
        int p2=-1;
        for(int j=n-i-1;j>=0;j--)
        {
            if(s[j]==t[i])
            {
                p1=j;
                break;
            }
        }
        for(int j=n-i-1;j>=0;j--)
        {
            if(j!=p1&&s[j]==t[i+1])
            {
                p2=j;
                break;
            }
        }
        if(p1<p2)
        {
            int s1=p1;
            int s2=p2-p1-1;
            int s3=n-i-1-p2;
            int s4=i;
            oper(s1+1+s2+1);
            oper(s4+s3+1);
            oper(1+s2);
            oper(s1+s3+s4+1+1);
        }
        else
        {
            int s1=p2;
            int s2=p1-p2-1;
            int s3=n-i-1-p1;
            int s4=i;
            oper(s1+1);
            oper(s4+s3);
            oper(1+s1+s2);
            oper(s3+s4+1+1);
        }
    }
    if(n%2==1)
    {
        oper(0);
        oper(n-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 0 ms 384 KB [n = 1, m = 10000], OK, 3 operations
2 Correct 0 ms 384 KB [n = 2, m = 10000], OK, 4 operations
3 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 16 operations
4 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 16 operations
5 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 16 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, 16 operations
8 Incorrect 0 ms 384 KB S is not equal after all operations: S = pgujnxpk, T = kgujnxpp
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB [n = 1, m = 10000], OK, 3 operations
2 Correct 0 ms 384 KB [n = 2, m = 10000], OK, 4 operations
3 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 16 operations
4 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 16 operations
5 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 16 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, 16 operations
8 Incorrect 0 ms 384 KB S is not equal after all operations: S = pgujnxpk, T = kgujnxpp
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB [n = 1, m = 10000], OK, 3 operations
2 Correct 0 ms 384 KB [n = 2, m = 10000], OK, 4 operations
3 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 16 operations
4 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 16 operations
5 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 16 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, 16 operations
8 Incorrect 0 ms 384 KB S is not equal after all operations: S = pgujnxpk, T = kgujnxpp
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB [n = 1, m = 10000], OK, 3 operations
2 Correct 0 ms 384 KB [n = 2, m = 10000], OK, 4 operations
3 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 16 operations
4 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 16 operations
5 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 16 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, 16 operations
8 Incorrect 0 ms 384 KB S is not equal after all operations: S = pgujnxpk, T = kgujnxpp
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB [n = 1, m = 10000], OK, 3 operations
2 Correct 0 ms 384 KB [n = 2, m = 10000], OK, 4 operations
3 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 16 operations
4 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 16 operations
5 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 16 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, 16 operations
8 Incorrect 0 ms 384 KB S is not equal after all operations: S = pgujnxpk, T = kgujnxpp
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB [n = 1, m = 10000], OK, 3 operations
2 Correct 0 ms 384 KB [n = 2, m = 10000], OK, 4 operations
3 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 16 operations
4 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 16 operations
5 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 16 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, 16 operations
8 Incorrect 0 ms 384 KB S is not equal after all operations: S = pgujnxpk, T = kgujnxpp
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB [n = 1, m = 10000], OK, 3 operations
2 Correct 0 ms 384 KB [n = 2, m = 10000], OK, 4 operations
3 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 16 operations
4 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 16 operations
5 Correct 0 ms 384 KB [n = 8, m = 10000], OK, 16 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, 16 operations
8 Incorrect 0 ms 384 KB S is not equal after all operations: S = pgujnxpk, T = kgujnxpp