# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1093543 | zNatsumi | Joker (BOI20_joker) | C++17 | 2061 ms | 5724 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ii pair<int, int>
#define fi first
#define se second
const int N = 2e5 + 5;
int n, m, q;
int pa[N], sz[N], lz[N];
ii edge[N];
int fset(int i, int &c){
c ^= lz[i];
return i == pa[i] ? i : fset(pa[i], c);
}
bool uset(int u, int v){
int cu = 0, cv = 0;
u = fset(u, cu);
v = fset(v, cv);
if(u == v){
if(cu == cv) return true;
return false;
}
if(sz[u] < sz[v]) swap(u, v);
pa[v] = u;
sz[u] += sz[v];
if(cu == cv) lz[v] ^= 1;
return false;
}
int32_t main(){
cin.tie(0)->sync_with_stdio(0);
#define task "test"
if(fopen(task ".inp", "r")){
freopen(task ".inp", "r", stdin);
freopen(task ".out", "w", stdout);
}
cin >> n >> m >> q;
for(int i = 1; i <= m; i++){
int u, v; cin >> u >> v;
edge[i] = {u, v};
}
for(int t = 1; t <= q; t++){
int l, r; cin >> l >> r;
for(int i = 1; i <= n; i++){
pa[i] = i;
sz[i] = 1;
lz[i] = 0;
}
bool ok = false;
for(int i = 1; i <= m; i++){
if(l <= i && i <= r) continue;
if(uset(edge[i].fi, edge[i].se)){
ok = true;
break;
}
}
cout << (ok ? "YES\n" : "NO\n");
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |