Submission #6998578


Source Code Expand

Copy
#include <bits/stdc++.h>

using namespace std;

int main(){
    string s,t;
    cin>>s>>t;
    vector<vector<int>> ms(26);
    for (int i = 0; i < s.size(); ++i) {
        ms[s[i]-'a'].emplace_back(i);
    }
    int ind=0;
    long long ans=0;
    int sind=-1;
    while(ind<t.size()){
        sind=-1;
        while(ind<t.size()){
            if(ms[t[ind]-'a'].size()==0){
                cout<<-1<<endl;
                return 0;
            }
            auto itu=upper_bound(ms[t[ind]-'a'].begin(),ms[t[ind]-'a'].end(),sind);
            if(itu==ms[t[ind]-'a'].end())break;
            else {
                ++ind;
                sind=*itu;
            }
        }
        if(ind<t.size()-1)++ans;
    }
    cout<<s.size()*ans+sind+1<<endl;
    return 0;
}

Submission Info

Submission Time
Task E - Strings of Impurity
User wakuwinmail
Language C++14 (GCC 5.4.1)
Score 0
Code Size 794 Byte
Status WA
Exec Time 14 ms
Memory 1216 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 3
AC × 30
WA × 15
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45
Case Name Status Exec Time Memory
a01 AC 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
b04 AC 1 ms 256 KB
b05 AC 1 ms 256 KB
b06 AC 1 ms 256 KB
b07 AC 1 ms 256 KB
b08 WA 1 ms 256 KB
b09 AC 1 ms 256 KB
b10 AC 14 ms 1216 KB
b11 WA 9 ms 1216 KB
b12 WA 9 ms 1216 KB
b13 WA 9 ms 1216 KB
b14 WA 14 ms 1216 KB
b15 AC 14 ms 1216 KB
b16 AC 14 ms 1216 KB
b17 AC 13 ms 896 KB
b18 AC 13 ms 896 KB
b19 AC 14 ms 896 KB
b20 WA 9 ms 896 KB
b21 AC 9 ms 896 KB
b22 AC 9 ms 896 KB
b23 AC 9 ms 896 KB
b24 AC 9 ms 1024 KB
b25 AC 13 ms 1024 KB
b26 AC 13 ms 1024 KB
b27 AC 12 ms 1024 KB
b28 AC 11 ms 1024 KB
b29 WA 10 ms 1024 KB
b30 AC 10 ms 1024 KB
b31 AC 8 ms 1024 KB
b32 WA 6 ms 512 KB
b33 AC 5 ms 512 KB
b34 AC 5 ms 1020 KB
b35 AC 5 ms 768 KB
b36 AC 10 ms 1216 KB
b37 WA 9 ms 1216 KB
b38 WA 9 ms 1216 KB
b39 WA 9 ms 1216 KB
b40 WA 9 ms 1216 KB
b41 WA 9 ms 1216 KB
b42 AC 8 ms 1216 KB
b43 AC 8 ms 1024 KB
b44 WA 9 ms 1216 KB
b45 WA 9 ms 1216 KB