-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1230D.cpp
More file actions
39 lines (37 loc) · 801 Bytes
/
1230D.cpp
File metadata and controls
39 lines (37 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
while(t--){
int n;
cin>>n;
string s,p;
cin>>s>>p;
unordered_map<char,int>um;
multimap<char,int>um2;
for(int i=0;i<s.length();i++){
um[s[i]]++;
}
for(int j=0;j<n;j++){
um[p[j]]--;
um2.insert({p[j],j});
}
int f=0;
for(auto i=um.begin();i!=um.end();i++){
if(!i->second){
f=1;
}
}
if(f){
cout<<"-1\n";
continue;
}
int p=0;
for(int i=0;i<n;i++){
if(p>um2[s[i]]){
c++;
p=um2[s[i]];
}
}
}
}