Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main(){
- int t;
- cin>>t;
- while(t--){
- int n, m;
- cin>>n;
- vector<int> a(n);
- for(auto &e: a)
- cin>>e;
- vector<int> b(n);
- for(auto &e: b)
- cin>>e;
- cin>>m;
- vector<int> d(m);
- for(auto &e: d)
- cin>>e;
- map<int, int> cnt1, cnt2;
- for(int i=0; i<n; i++){
- if(a[i] != b[i])
- cnt1[b[i]]++;
- }
- for(int j=0; j<m; j++)
- cnt2[d[j]]++;
- int f = 1;
- for(auto [x, y]: cnt1){
- if(cnt2[x] < y)
- f = 0;
- }
- if(count(b.begin(), b.end(), d[m-1]) == 0)
- f = 0;
- if(f) cout<<"YES\n";
- else cout<<"NO\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment