/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 8ms 532.0 KiB
#3 Accepted 8ms 576.0 KiB
#4 Accepted 3ms 532.0 KiB
#5 Accepted 17ms 532.0 KiB
#6 Accepted 18ms 1.27 MiB
#7 Accepted 20ms 1.27 MiB

Code

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define endl '\n'
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

void solve(){
    int n,m;
    cin>>n>>m;
    vector<int> a(n),b(m),c(10,0), d(4,0);
    for(int i=0; i<n; i++){
        cin>>a[i];
        if(a[i]<4) d[a[i]]=1;
    }
    for(int i=0; i<m; i++){
        cin>>b[i];
        c[b[i]]=1;
    }
    for(auto it: c){
        if(it==0){
            cout<<"NO"<<endl;
            return;
        }
    }
    for(auto it: d){
        if(it==0){
            cout<<"NO"<<endl;
            return;
        }
    }
    cout<<"YES"<<endl;
}

signed main(){
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    optimize();

    ll t;
    cin>>t;
    for(ll i=1; i<=t; i++){
        solve();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1153 Is Date Possible?
Contest
Happy New Year 2025
Language
C++17 (G++ 13.2.0)
Submit At
2025-01-02 14:42:01
Judged At
2025-01-02 14:42:01
Judged By
Score
100
Total Time
20ms
Peak Memory
1.27 MiB