Submission #1096337

#TimeUsernameProblemLanguageResultExecution timeMemory
1096337laureJoker (BOI20_joker)C++14
14 / 100
40 ms676 KiB
#include<bits/stdc++.h> #define int long long using namespace std; int n,m,q,l,r; bool b; vector<pair<int,int>>adj[2005]; bool vis[2005]; int d[2005]; void dfs(int node,int par,int de) { if(b)return; d[node]=de; vis[node]=1; for(auto u:adj[node]) { if(u.second>=l&&u.second<=r)continue; if(u.first==par)continue; if(vis[u.first]&&(de-d[u.first])%2==0){b=1;break;} if(!vis[u.first]) { dfs(u.first,node,de+1); } } } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>m>>q; for(int i=1;i<=m;i++) { int a,b; cin>>a>>b; adj[a].push_back({b,i}); adj[b].push_back({a,i}); } while(q--) { b=0; memset(vis,0,sizeof(vis)); memset(d,0,sizeof(d)); cin>>l>>r; for(int i=1;i<n;i++) { if(!vis[i])dfs(i,i,1); if(b)break; } if(b)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...