Submission #1104314

# Submission time Handle Problem Language Result Execution time Memory
1104314 2024-10-23T12:41:09 Z Ciprian Colors (RMI18_colors) C++14
0 / 100
2 ms 592 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long 

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin>>t;
    for(int i=0; i<t; i++){
        int n,m;
        cin>>n>>m;
        vector<int> adj[n+3], deg(n+3), a(n+2), b(n+1);
        for(int j=1; j<=n; j++){
            cin>>a[j];
            
        }for(int j=1; j<=n; j++){
            cin>>b[j];
            
            
        }bool check=true;
        for(int j=1; j<=n; j++){
            cin>>b[j];
            if(b[j]>a[j]){
                check=false;
        
            }
            
        }
        for(int j=0; j<m; j++){
            int u,v;
            cin>>u>>v;
            adj[u].push_back(v);
            adj[v].push_back(u);
            deg[u]++;
            deg[v]++;
            
        }int r=0;
        for(int j=1; j<=n; j++){
            if(deg[j]==n-1){
                r=j;
                break;
            }
        }set<int> c;
        for(int j=1; j<=n; j++){
            if(j!=r){
                if(a[j]<=a[r] &&b[r]<=a[j]){
                    c.insert(a[j]);
                }
            }
        }if(!check){
            cout<<0<<endl;
        }else{
            bool res=true;
            for(int j=1; j<=n; j++){
                if(j!=r){
                    if(c.find(b[j])==c.end()){
                        res=false;
                        break;
                    }
                }
            }if(res)cout<<1<<endl;
            else cout<<0<<endl;
        }
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 592 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 592 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 592 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -