Submission #974533

# Submission time Handle Problem Language Result Execution time Memory
974533 2024-05-03T12:25:40 Z kl0989e Joker (BOI20_joker) C++17
14 / 100
2000 ms 22108 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define pi pair<int, int>
#define all(x) (x).begin(),(x).end()

const int maxn=2e5+10;
vector<vector<pi>> graph(maxn);
vi col(maxn,-1);

bool dfs(int cur, int prev, int color, int l, int r) {
    if (col[cur]==1-color) {
        return 0;
    }
    if (col[cur]!=-1) {
        return 1;
    }
    col[cur]=color;
    for (auto [to,ind]:graph[cur]) {
        if (l<=ind && ind<=r) {
            continue;
        }
        if (to==prev) {
            continue;
        }
        if (!dfs(to,cur,1-color,l,r)) {
            return 0;
        }
    }
    return 1;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m,q;
    cin >> n >> m >> q;
    vector<pi> vert(m);
    for (int i=0; i<m; i++) {
        cin >> vert[i].fi >> vert[i].se;
        vert[i].fi--;
        vert[i].se--;
        graph[vert[i].fi].pb({vert[i].se,i+1});
        graph[vert[i].se].pb({vert[i].fi,i+1});
    }
    int l,r;
    for (int i=0; i<q; i++) {
        cin >> l >> r;
        fill(all(col),-1);
        bool ok=1;
        for (int j=0; j<n; j++) {
            if (col[j]==-1) {
                if (!dfs(j,-1,0,l,r)) {
                    ok=0;
                    break;
                }
            }
        }
        if (ok) {
            cout << "NO\n";
        }
        else {
            cout << "YES\n";
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5724 KB Output is correct
2 Correct 3 ms 5952 KB Output is correct
3 Correct 3 ms 5724 KB Output is correct
4 Correct 2 ms 5724 KB Output is correct
5 Correct 2 ms 5724 KB Output is correct
6 Correct 3 ms 5944 KB Output is correct
7 Correct 5 ms 5724 KB Output is correct
8 Correct 6 ms 5724 KB Output is correct
9 Correct 5 ms 5720 KB Output is correct
10 Correct 4 ms 5724 KB Output is correct
11 Correct 5 ms 5724 KB Output is correct
12 Correct 5 ms 5724 KB Output is correct
13 Correct 5 ms 5724 KB Output is correct
14 Correct 5 ms 5724 KB Output is correct
15 Correct 5 ms 5724 KB Output is correct
16 Correct 5 ms 5724 KB Output is correct
17 Correct 5 ms 5720 KB Output is correct
18 Correct 5 ms 5724 KB Output is correct
19 Correct 5 ms 5724 KB Output is correct
20 Correct 5 ms 5724 KB Output is correct
21 Correct 4 ms 5724 KB Output is correct
22 Correct 5 ms 5720 KB Output is correct
23 Correct 5 ms 5892 KB Output is correct
24 Correct 4 ms 5724 KB Output is correct
25 Correct 5 ms 5928 KB Output is correct
26 Correct 4 ms 5724 KB Output is correct
27 Correct 5 ms 5724 KB Output is correct
28 Correct 5 ms 5724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5724 KB Output is correct
2 Correct 3 ms 5952 KB Output is correct
3 Correct 3 ms 5724 KB Output is correct
4 Correct 2 ms 5724 KB Output is correct
5 Correct 2 ms 5724 KB Output is correct
6 Correct 3 ms 5944 KB Output is correct
7 Correct 5 ms 5724 KB Output is correct
8 Correct 6 ms 5724 KB Output is correct
9 Correct 5 ms 5720 KB Output is correct
10 Correct 4 ms 5724 KB Output is correct
11 Correct 5 ms 5724 KB Output is correct
12 Correct 5 ms 5724 KB Output is correct
13 Correct 5 ms 5724 KB Output is correct
14 Correct 5 ms 5724 KB Output is correct
15 Correct 5 ms 5724 KB Output is correct
16 Correct 5 ms 5724 KB Output is correct
17 Correct 5 ms 5720 KB Output is correct
18 Correct 5 ms 5724 KB Output is correct
19 Correct 5 ms 5724 KB Output is correct
20 Correct 5 ms 5724 KB Output is correct
21 Correct 4 ms 5724 KB Output is correct
22 Correct 5 ms 5720 KB Output is correct
23 Correct 5 ms 5892 KB Output is correct
24 Correct 4 ms 5724 KB Output is correct
25 Correct 5 ms 5928 KB Output is correct
26 Correct 4 ms 5724 KB Output is correct
27 Correct 5 ms 5724 KB Output is correct
28 Correct 5 ms 5724 KB Output is correct
29 Correct 93 ms 5980 KB Output is correct
30 Correct 73 ms 5980 KB Output is correct
31 Correct 61 ms 6080 KB Output is correct
32 Correct 41 ms 5980 KB Output is correct
33 Correct 32 ms 5980 KB Output is correct
34 Correct 57 ms 6232 KB Output is correct
35 Correct 74 ms 5976 KB Output is correct
36 Correct 39 ms 5980 KB Output is correct
37 Correct 80 ms 5980 KB Output is correct
38 Correct 81 ms 6072 KB Output is correct
39 Correct 66 ms 5976 KB Output is correct
40 Correct 46 ms 5976 KB Output is correct
41 Correct 45 ms 5976 KB Output is correct
42 Correct 44 ms 5980 KB Output is correct
43 Correct 31 ms 5980 KB Output is correct
44 Correct 37 ms 5980 KB Output is correct
45 Correct 39 ms 5980 KB Output is correct
46 Correct 36 ms 6088 KB Output is correct
47 Correct 48 ms 6080 KB Output is correct
48 Correct 48 ms 5980 KB Output is correct
49 Correct 54 ms 5976 KB Output is correct
50 Correct 61 ms 5976 KB Output is correct
51 Correct 47 ms 5980 KB Output is correct
52 Correct 52 ms 5968 KB Output is correct
53 Correct 61 ms 5976 KB Output is correct
54 Correct 72 ms 5980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5724 KB Output is correct
2 Correct 3 ms 5952 KB Output is correct
3 Execution timed out 2041 ms 20100 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5724 KB Output is correct
2 Correct 3 ms 5952 KB Output is correct
3 Correct 3 ms 5724 KB Output is correct
4 Correct 2 ms 5724 KB Output is correct
5 Correct 2 ms 5724 KB Output is correct
6 Correct 3 ms 5944 KB Output is correct
7 Correct 5 ms 5724 KB Output is correct
8 Correct 6 ms 5724 KB Output is correct
9 Correct 5 ms 5720 KB Output is correct
10 Correct 4 ms 5724 KB Output is correct
11 Correct 5 ms 5724 KB Output is correct
12 Correct 5 ms 5724 KB Output is correct
13 Correct 5 ms 5724 KB Output is correct
14 Correct 5 ms 5724 KB Output is correct
15 Correct 5 ms 5724 KB Output is correct
16 Correct 5 ms 5724 KB Output is correct
17 Correct 5 ms 5720 KB Output is correct
18 Correct 5 ms 5724 KB Output is correct
19 Correct 5 ms 5724 KB Output is correct
20 Correct 5 ms 5724 KB Output is correct
21 Correct 4 ms 5724 KB Output is correct
22 Correct 5 ms 5720 KB Output is correct
23 Correct 5 ms 5892 KB Output is correct
24 Correct 4 ms 5724 KB Output is correct
25 Correct 5 ms 5928 KB Output is correct
26 Correct 4 ms 5724 KB Output is correct
27 Correct 5 ms 5724 KB Output is correct
28 Correct 5 ms 5724 KB Output is correct
29 Execution timed out 2041 ms 20100 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5724 KB Output is correct
2 Correct 3 ms 5952 KB Output is correct
3 Correct 3 ms 5724 KB Output is correct
4 Correct 2 ms 5724 KB Output is correct
5 Correct 2 ms 5724 KB Output is correct
6 Correct 3 ms 5944 KB Output is correct
7 Correct 5 ms 5724 KB Output is correct
8 Correct 6 ms 5724 KB Output is correct
9 Correct 5 ms 5720 KB Output is correct
10 Correct 4 ms 5724 KB Output is correct
11 Correct 5 ms 5724 KB Output is correct
12 Correct 5 ms 5724 KB Output is correct
13 Correct 5 ms 5724 KB Output is correct
14 Correct 5 ms 5724 KB Output is correct
15 Correct 5 ms 5724 KB Output is correct
16 Correct 5 ms 5724 KB Output is correct
17 Correct 5 ms 5720 KB Output is correct
18 Correct 5 ms 5724 KB Output is correct
19 Correct 5 ms 5724 KB Output is correct
20 Correct 5 ms 5724 KB Output is correct
21 Correct 4 ms 5724 KB Output is correct
22 Correct 5 ms 5720 KB Output is correct
23 Correct 5 ms 5892 KB Output is correct
24 Correct 4 ms 5724 KB Output is correct
25 Correct 5 ms 5928 KB Output is correct
26 Correct 4 ms 5724 KB Output is correct
27 Correct 5 ms 5724 KB Output is correct
28 Correct 5 ms 5724 KB Output is correct
29 Correct 93 ms 5980 KB Output is correct
30 Correct 73 ms 5980 KB Output is correct
31 Correct 61 ms 6080 KB Output is correct
32 Correct 41 ms 5980 KB Output is correct
33 Correct 32 ms 5980 KB Output is correct
34 Correct 57 ms 6232 KB Output is correct
35 Correct 74 ms 5976 KB Output is correct
36 Correct 39 ms 5980 KB Output is correct
37 Correct 80 ms 5980 KB Output is correct
38 Correct 81 ms 6072 KB Output is correct
39 Correct 66 ms 5976 KB Output is correct
40 Correct 46 ms 5976 KB Output is correct
41 Correct 45 ms 5976 KB Output is correct
42 Correct 44 ms 5980 KB Output is correct
43 Correct 31 ms 5980 KB Output is correct
44 Correct 37 ms 5980 KB Output is correct
45 Correct 39 ms 5980 KB Output is correct
46 Correct 36 ms 6088 KB Output is correct
47 Correct 48 ms 6080 KB Output is correct
48 Correct 48 ms 5980 KB Output is correct
49 Correct 54 ms 5976 KB Output is correct
50 Correct 61 ms 5976 KB Output is correct
51 Correct 47 ms 5980 KB Output is correct
52 Correct 52 ms 5968 KB Output is correct
53 Correct 61 ms 5976 KB Output is correct
54 Correct 72 ms 5980 KB Output is correct
55 Execution timed out 2094 ms 22108 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5724 KB Output is correct
2 Correct 3 ms 5952 KB Output is correct
3 Correct 3 ms 5724 KB Output is correct
4 Correct 2 ms 5724 KB Output is correct
5 Correct 2 ms 5724 KB Output is correct
6 Correct 3 ms 5944 KB Output is correct
7 Correct 5 ms 5724 KB Output is correct
8 Correct 6 ms 5724 KB Output is correct
9 Correct 5 ms 5720 KB Output is correct
10 Correct 4 ms 5724 KB Output is correct
11 Correct 5 ms 5724 KB Output is correct
12 Correct 5 ms 5724 KB Output is correct
13 Correct 5 ms 5724 KB Output is correct
14 Correct 5 ms 5724 KB Output is correct
15 Correct 5 ms 5724 KB Output is correct
16 Correct 5 ms 5724 KB Output is correct
17 Correct 5 ms 5720 KB Output is correct
18 Correct 5 ms 5724 KB Output is correct
19 Correct 5 ms 5724 KB Output is correct
20 Correct 5 ms 5724 KB Output is correct
21 Correct 4 ms 5724 KB Output is correct
22 Correct 5 ms 5720 KB Output is correct
23 Correct 5 ms 5892 KB Output is correct
24 Correct 4 ms 5724 KB Output is correct
25 Correct 5 ms 5928 KB Output is correct
26 Correct 4 ms 5724 KB Output is correct
27 Correct 5 ms 5724 KB Output is correct
28 Correct 5 ms 5724 KB Output is correct
29 Correct 93 ms 5980 KB Output is correct
30 Correct 73 ms 5980 KB Output is correct
31 Correct 61 ms 6080 KB Output is correct
32 Correct 41 ms 5980 KB Output is correct
33 Correct 32 ms 5980 KB Output is correct
34 Correct 57 ms 6232 KB Output is correct
35 Correct 74 ms 5976 KB Output is correct
36 Correct 39 ms 5980 KB Output is correct
37 Correct 80 ms 5980 KB Output is correct
38 Correct 81 ms 6072 KB Output is correct
39 Correct 66 ms 5976 KB Output is correct
40 Correct 46 ms 5976 KB Output is correct
41 Correct 45 ms 5976 KB Output is correct
42 Correct 44 ms 5980 KB Output is correct
43 Correct 31 ms 5980 KB Output is correct
44 Correct 37 ms 5980 KB Output is correct
45 Correct 39 ms 5980 KB Output is correct
46 Correct 36 ms 6088 KB Output is correct
47 Correct 48 ms 6080 KB Output is correct
48 Correct 48 ms 5980 KB Output is correct
49 Correct 54 ms 5976 KB Output is correct
50 Correct 61 ms 5976 KB Output is correct
51 Correct 47 ms 5980 KB Output is correct
52 Correct 52 ms 5968 KB Output is correct
53 Correct 61 ms 5976 KB Output is correct
54 Correct 72 ms 5980 KB Output is correct
55 Execution timed out 2041 ms 20100 KB Time limit exceeded
56 Halted 0 ms 0 KB -