Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set<char>st;
- ll n; cin>>n;
- string s; cin>>s;
- ll x; cin>>x;
- vector<int>v;
- while(x--){
- char z; cin>>z;
- st.emplace(z);
- }
- for(auto i = st.begin(); i!= st.end(); i++){
- v.push_back(s.rfind(*i));
- }
- sort(rall(v));
- int differ;
- if(sz(v) == 1){
- if(v[0]<=0) {
- cout<<0<<nl;
- return;
- }else cout<<v[0]<<nl;
- }
- for(int i=0; i<sz(v)-1;i++){
- differ = v[i]-v[i+1];
- }
- differ = min(differ,v[sz(v)-1]);
- // for(auto&h:v) cout<<h<<' ';
- cout<<nl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement