Submission #930570

# Submission time Handle Problem Language Result Execution time Memory
930570 2024-02-20T06:54:17 Z UmairAhmadMirza Joker (BOI20_joker) C++14
0 / 100
415 ms 20052 KB
#include <bits/stdc++.h>
using namespace std;
int const N=2e5+5;
vector<int> adj[N];
bool dep[N];
int rep[N];
vector<int> com[N];
bool merge(int a,int b){
  // cout<<a<<' '<<b<<endl;
  if(rep[a]==rep[b]){
    if(dep[a]==dep[b])
      return 0;
    return 1;
  }
  if(com[a].size()>com[b].size())
    swap(a,b);
  bool sw=0;
  if(dep[a]==dep[b])
    sw=1;
  for(auto i:com[a]){
    com[b].push_back(i);
    rep[i]=b;
    dep[i]^=sw;
  }
  com[a].clear();
  return 1;
}
int main() 
{
    int n,m,q;
    cin>>n>>m>>q;
    for(int i=1;i<=n;i++){
      com[i].push_back(i);
      rep[i]=i;
    }
    for(int i=0;i<m;i++){
      int a,b;
      cin>>a>>b;
      if(a>b)
        swap(a,b);
      adj[a].push_back(b);
    }
    int k=0;
    for(int node=n-1;node>=1;node--){
      for(auto i:adj[node]){
        if(merge(i,node)==0){
          k=node;
          break;
        }
      }
    }
    for(int i=0;i<q;i++){
      int l,r;
      cin>>l>>r;
      if(r<=k)
        cout<<"YES"<<endl;
      else
        cout<<"NO"<<endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 10588 KB Output is correct
2 Correct 3 ms 10788 KB Output is correct
3 Incorrect 2 ms 10584 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 10588 KB Output is correct
2 Correct 3 ms 10788 KB Output is correct
3 Incorrect 2 ms 10584 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 10588 KB Output is correct
2 Correct 3 ms 10788 KB Output is correct
3 Incorrect 415 ms 20052 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 10588 KB Output is correct
2 Correct 3 ms 10788 KB Output is correct
3 Incorrect 2 ms 10584 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 10588 KB Output is correct
2 Correct 3 ms 10788 KB Output is correct
3 Incorrect 2 ms 10584 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 10588 KB Output is correct
2 Correct 3 ms 10788 KB Output is correct
3 Incorrect 2 ms 10584 KB Output isn't correct
4 Halted 0 ms 0 KB -