Submission #759299

#TimeUsernameProblemLanguageResultExecution timeMemory
759299boyliguanhanJoker (BOI20_joker)C++17
14 / 100
2056 ms17152 KiB
#include<bits/stdc++.h> using namespace std; #define N 200100 vector<int> adj[N]; int color[N]; int dfs(int x, int col) { if(color[x]) { if(col==color[x]) return 0; else return 1; } color[x] = col; for(auto i: adj[x]) if(dfs(i, 3-col)) return 1; return 0; } int a[N], b[N]; int main() { cin.sync_with_stdio(false); cin.tie(nullptr); int n, m, q; cin >> n >> m >> q; for(int i = 0; i < m; i++) cin >> a[i] >> b[i]; while(q--) { int l, r; cin >> l >> r; memset(color, 0, sizeof color); for(int i = 1; i <= n; i++) adj[i].clear(); for(int i = 0; i < l-1; i++) adj[a[i]].push_back(b[i]), adj[b[i]].push_back(a[i]); for(int i = r; i < m; i++) adj[a[i]].push_back(b[i]), adj[b[i]].push_back(a[i]); for(int i = 0; i < n; i++) { if(!color[i]){ if(dfs(i, 1)) { cout << "YES\n"; break; } } if(i==n-1) 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...