# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
642314 | 2022-09-19T08:27:45 Z | dozer | Joker (BOI20_joker) | C++14 | 3 ms | 468 KB |
#include <bits/stdc++.h> using namespace std; #define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout) #define fastio() cin.tie(0), ios_base::sync_with_stdio(0) #define sp " " #define endl "\n" #define pb push_back #define pii pair<int, int> #define st first #define nd second #define N 200005 const int modulo = 1e9 + 7; int ans[N], u[N], v[N], l[N], r[N]; int find(vector<int> &root, int node) { if (node < 0) return -(find(root, -node)); if (node == root[node]) return node; return root[node] = find(root, root[node]); } int32_t main() { fileio(); fastio(); int n, m, q; cin>>n>>m>>q; vector<int> root(n + 5, 0); for (int i = 1; i <= n; i++) root[i] = i; for (int i = 1; i <= m; i++) { cin>>u[i]>>v[i]; } for (int i = m; i >= 1; i--) { if (ans[i] == 1) { ans[i - 1] = 1; continue; } int a = find(root, u[i]), b = find(root, v[i]); if (a == b) ans[i - 1] = 1; else { if (a < 0) a *= -1, b *= -1; root[a] = -b; } } for (int i = 1; i <= q; i++) { cin>>l[i]>>r[i]; if (ans[r[i]] == 1) cout<<"YES\n"; else cout<<"NO\n"; } cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 468 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 468 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 468 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 468 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 468 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 468 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |