Submission #1100853

#TimeUsernameProblemLanguageResultExecution timeMemory
1100853imarnCurtains (NOI23_curtains)C++14
0 / 100
1 ms468 KiB
#include<bits/stdc++.h> #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define plx pair<ll,int> #define f first #define s second #define pb push_back #define all(x) x.begin(),x.end() #define vi vector<int> #define vl vector<ll> #define vvi vector<vi> using namespace std; const int mxn=5e5+5; int pr[mxn]{0}; int get(int r){ return pr[r]==r?r:pr[r]=get(pr[r]); } int main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n,m,q;cin>>n>>m>>q; iota(pr,pr+n+2,0); for(int i=1;i<=m;i++){ int l,r;cin>>l>>r;r++; pr[get(r)]=pr[get(l)]; } while(q--){ int s,e;cin>>s>>e;e++; if(get(s)==get(e))cout<<"YES\n"; else cout<<"NO\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...