Submission #467560

#TimeUsernameProblemLanguageResultExecution timeMemory
467560MVP_HarryJoker (BOI20_joker)C++17
14 / 100
2073 ms19652 KiB
#include <bits/stdc++.h> using namespace std; #define INF 0x3f3f3f3f #define rep(i, m, n) for (int i = m; i <= n; i++) #define per(i, m, n) for (int i = m; i >= n; i--) #define sz(v) (int) v.size() #define all(v) v.begin(), v.end() #define ll long long #define pb push_back #define mp make_pair #define fi first #define se second const int maxn = 2e5 + 5; int N, M, Q, ok = 0; int vis[maxn]; vector<pair<int, int> > G[maxn]; void dfs(int u, int par, int col, int l, int r) { vis[u] = col; for (auto node : G[u]) { if (node.fi == par || (l <= node.se && node.se <= r)) continue; if (vis[node.fi] == vis[u]) ok = 1; if (!vis[node.fi]) dfs(node.fi, u, 3 - col, l, r); } } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> N >> M >> Q; rep(i, 1, M) { int u, v; cin >> u >> v; G[u].push_back(mp(v, i)); G[v].push_back(mp(u, i)); } while (Q--) { int l, r; cin >> l >> r; ok = 0; rep(i, 1, N) vis[i] = 0; rep(i, 1, N) if (!vis[i]) dfs(i, 0, 1, l, r); cout << (ok ? "YES\n" : "NO\n"); } return 0; }
#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...