Submission #289904

#TimeUsernameProblemLanguageResultExecution timeMemory
289904someone_aaJoker (BOI20_joker)C++17
0 / 100
2084 ms18192 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair #define pii pair<int,int> using namespace std; const int maxn = 200100; ll n, m, q; vector<pii>g[maxn]; bool visited[maxn]; int color[maxn]; bool check(int l, int r) { memset(visited, false,sizeof(visited)); memset(color, 0, sizeof(color)); bool cycle = false; for(int i=1;i<=n;i++) { if(!visited[i]) { visited[i] = true; color[i] = 1; queue<int>q; q.push(i); while(!q.empty()) { int curr = q.front(); q.pop(); for(auto i:g[curr]) { if(l <= i.second && i.second <= r) continue; if(!visited[i.first]) { visited[i.first] = true; color[i.first] = 3 - color[curr]; q.push(i.first); } else { if(color[i.first] == color[curr]) cycle = true; } } } } } return cycle; } int main() { cin>>n>>m>>q; int u, v; for(int i=1;i<=m;i++) { cin>>u>>v; g[u].pb(mp(v, i)); g[v].pb(mp(u, i)); } int rmost = 1; for(ll cekor=m/2;cekor>0;cekor/=2) { while(rmost + cekor <= m && check(1, rmost+cekor)) rmost += cekor; } if(!check(1, 1)) { for(int i=0;i<q;i++) { cout<<"NO\n"; } return 0; } int l, r; while(q--) { cin>>l>>r; if(r <= rmost) 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...