# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
280345 | spdskatr | Joker (BOI20_joker) | C++14 | 83 ms | 632 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 <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
int N, M, Q, seen[2005], col[2005];
vector<pii> graph[2005];
int dfs(int x, int l, int r) {
seen[x] = 1;
for (pii p : graph[x]) {
int v = p.fi, e = p.se;
if (e < l || e > r) {
if (seen[v]) {
if (col[v] == col[x]) return 1;
} else {
col[v] = !col[x];
if (dfs(v, l, r)) return 1;
}
}
}
return 0;
}
int main() {
scanf("%d %d %d", &N, &M, &Q);
for (int i = 1; i <= M; i++) {
int a, b;
scanf("%d %d", &a, &b);
graph[a].push_back({ b, i });
graph[b].push_back({ a, i });
}
for (int q = 0; q < Q; q++) {
int l, r;
scanf("%d %d", &l, &r);
memset(seen, 0, sizeof(seen));
memset(col, 0, sizeof(col));
int nice = 0;
for (int i = 1; i <= N; i++) {
if (!seen[i]) if (dfs(i, l, r)) {
nice = 1;
break;
}
}
if (nice) printf("YES\n");
else printf("NO\n");
}
}
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... |