-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Needle_in_a_Haystack.cpp
More file actions
43 lines (41 loc) · 905 Bytes
/
A_Needle_in_a_Haystack.cpp
File metadata and controls
43 lines (41 loc) · 905 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
40
41
42
43
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;cin>>t;
while(t--){
string s,t;cin>>s>>t;
map<char,int>mpt;
for (int i = 0; i < (int)t.size(); i++)
{
mpt[t[i]]++;
}
bool isok=true;
for (int i = 0; i < (int)s.size(); i++)
{
if(mpt[s[i]]<1){
isok=false;
break;
}
}
if(!isok){
cout<<"Impossible"<<endl;
}else{
cout<<t<<endl;
}
sort(t.begin(),t.end());
// int l=0,r=0;
// string ans;
// while (l<s.size() || r<t.size())
// {
// if(s[l]<=t[r]){
// ans.push_back(s[l]);
// l++;
// }else{
// ans.push_back(t[r]);
// r++;
// }
// }
}
return 0;
}