# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1093893 | Wjsc | Joker (BOI20_joker) | C++14 | 22 ms | 9044 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define pi pair<int, int>
#define fi first
#define se second
#define all(v) v.begin(), v.end()
const int N = 2e5 + 5;
int n, m, q;
pi edge[N];
vector<int> ad[N];
namespace sub1 {
bool ok = 0;
int col[N];
void dfs(int u, int c) {
col[u] = c;
for(auto v : ad[u]) {
if(col[v] == col[u]) ok = 1;
if(col[v] == -1) dfs(v, c ^ 1);
}
}
void solve() {
while(q--) {
int l, r; cin >> l >> r;
for(int i = 1; i <= n; ++i) ad[i].clear();
for(int i = 1; i < l; ++i) {
int u, v; tie(u, v) = edge[i];
ad[u].push_back(v);
ad[v].push_back(u);
}
for(int i = r + 1; i <= m; ++i) {
int u, v; tie(u, v) = edge[i];
ad[u].push_back(v);
ad[v].push_back(u);
}
for(int i = 1; i <= n; ++i) col[i] = -1;
ok = 0;
for(int i = 1; i <= n; ++i)
if(col[i] == -1) dfs(i, 0);
cout << (ok ? "YES\n" : "NO\n");
}
}
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
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};
}
if(n <= 200 && m <= 200 && q <= 200) sub1 :: solve();
}
Compilation message (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... |