-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathediting.cpp
More file actions
93 lines (82 loc) · 1.73 KB
/
editing.cpp
File metadata and controls
93 lines (82 loc) · 1.73 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include<iostream>
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<list>
#define ll long long
#define MOD 1000000007
#define mapi map<int,int>
#define mapll map<long long int,long long int >
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vlll vector<vll>
#define vs vector<string>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define inf 1e18
#define all(v) v.begin(),v.end()
#define R(n) for(int i=0;i<n;i++)
#define R1(n) for(int i=1;i<=n;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
using namespace std;
struct custom_hash{ size_t operator()(uint64_t x) const{
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
x ^= FIXED_RANDOM; return x ^ (x >> 16);}};
void solve() {
string s;
string t;
cin>>s>>t;
int n=s.length();
int m=t.length();
unordered_map<char,int>sp;
unordered_map<char,int>tp;
for(auto c: s){
sp[c]++;
}
for(auto c: t){
tp[c]++;
}
int i=0;
int j=0;
while(i<n && j<m){
if(s[i]==t[j]){
if(sp[s[i]]<tp[t[j]]){
break;
}
if(sp[s[i]]==tp[t[j]]){
tp[t[j]]--;
j++;
}
}
sp[s[i]]--;
i++;
}
if(j==m){
cout<<"Yes"<<endl;
}
else cout<<"No"<<endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}