Submission #689304

# Submission time Handle Problem Language Result Execution time Memory
689304 2023-01-28T06:21:04 Z saayan007 Joker (BOI20_joker) C++17
14 / 100
2000 ms 22012 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
using vi = vector<int>;
using vl = vector<long long>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<long long, long long>>;

#define fur(i, a, b) for(ll i = a; i <= (ll)b; ++i)
#define ruf(i, a, b) for(ll i = a; i >= (ll)b; --i)
#define fr first 
#define sc second
#define mp make_pair
#define pb emplace_back
#define nl "\n"
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

const ll mxn = 2e5L + 1;
ll n, m, q;
vpl adj[mxn];
bool vis[mxn] = {};
ll dep[mxn] = {};
ll from[mxn] = {};

bool dfs(ll cur, ll src, ll l, ll r) {
    // cout << cur << ' ';
    if(vis[cur]) {
        if(src != -1 && (dep[src] + 1 - dep[cur]) % 2 == 1) {
            return 1;
        }
        return 0;
    }

    vis[cur] = 1;
    dep[cur] = (src == -1 ? 0 : dep[src] + 1);
    for(auto [ch, i] : adj[cur]) {
        if(ch != src && !(l <= i && i <= r)) {
            if(dfs(ch, cur, l, r)) {
                return 1;
            }
        }
    }
    return 0;
}

int main() 
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> m >> q;
    fur(i, 1, m) {
        ll u, v;
        cin >> u >> v;
        adj[u].pb(v, i);
        adj[v].pb(u, i);
    }

    while(q--) {
        ll l, r;
        cin >> l >> r;

        fur(i, 1, n) {
            vis[i] = 0;
        }

        bool yes = 0;
        fur(i, 1, n) {
            if(!vis[i]) {
                if(dfs(i, -1, l, r)) {
                    yes = 1;
                    // cout << nl;
                }
            }
        }

        cout << (yes ? "YES" : "NO") << nl;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 4 ms 5024 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 4 ms 4948 KB Output is correct
8 Correct 5 ms 4948 KB Output is correct
9 Correct 4 ms 4948 KB Output is correct
10 Correct 3 ms 5016 KB Output is correct
11 Correct 5 ms 4948 KB Output is correct
12 Correct 4 ms 5020 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 4 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 4 ms 5076 KB Output is correct
18 Correct 4 ms 4948 KB Output is correct
19 Correct 4 ms 4932 KB Output is correct
20 Correct 5 ms 5020 KB Output is correct
21 Correct 3 ms 5028 KB Output is correct
22 Correct 4 ms 5024 KB Output is correct
23 Correct 3 ms 4948 KB Output is correct
24 Correct 4 ms 5024 KB Output is correct
25 Correct 3 ms 4948 KB Output is correct
26 Correct 3 ms 5024 KB Output is correct
27 Correct 3 ms 4948 KB Output is correct
28 Correct 5 ms 5020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 4 ms 5024 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 4 ms 4948 KB Output is correct
8 Correct 5 ms 4948 KB Output is correct
9 Correct 4 ms 4948 KB Output is correct
10 Correct 3 ms 5016 KB Output is correct
11 Correct 5 ms 4948 KB Output is correct
12 Correct 4 ms 5020 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 4 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 4 ms 5076 KB Output is correct
18 Correct 4 ms 4948 KB Output is correct
19 Correct 4 ms 4932 KB Output is correct
20 Correct 5 ms 5020 KB Output is correct
21 Correct 3 ms 5028 KB Output is correct
22 Correct 4 ms 5024 KB Output is correct
23 Correct 3 ms 4948 KB Output is correct
24 Correct 4 ms 5024 KB Output is correct
25 Correct 3 ms 4948 KB Output is correct
26 Correct 3 ms 5024 KB Output is correct
27 Correct 3 ms 4948 KB Output is correct
28 Correct 5 ms 5020 KB Output is correct
29 Correct 65 ms 5144 KB Output is correct
30 Correct 107 ms 5176 KB Output is correct
31 Correct 92 ms 5196 KB Output is correct
32 Correct 65 ms 5188 KB Output is correct
33 Correct 40 ms 5076 KB Output is correct
34 Correct 112 ms 5204 KB Output is correct
35 Correct 110 ms 5328 KB Output is correct
36 Correct 26 ms 5112 KB Output is correct
37 Correct 74 ms 5216 KB Output is correct
38 Correct 70 ms 5196 KB Output is correct
39 Correct 84 ms 5192 KB Output is correct
40 Correct 64 ms 5192 KB Output is correct
41 Correct 59 ms 5184 KB Output is correct
42 Correct 57 ms 5192 KB Output is correct
43 Correct 35 ms 5160 KB Output is correct
44 Correct 57 ms 5204 KB Output is correct
45 Correct 92 ms 5204 KB Output is correct
46 Correct 104 ms 5192 KB Output is correct
47 Correct 70 ms 5188 KB Output is correct
48 Correct 68 ms 5076 KB Output is correct
49 Correct 87 ms 5188 KB Output is correct
50 Correct 103 ms 5216 KB Output is correct
51 Correct 52 ms 5204 KB Output is correct
52 Correct 69 ms 5168 KB Output is correct
53 Correct 89 ms 5180 KB Output is correct
54 Correct 117 ms 5200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Execution timed out 2097 ms 18032 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 4 ms 5024 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 4 ms 4948 KB Output is correct
8 Correct 5 ms 4948 KB Output is correct
9 Correct 4 ms 4948 KB Output is correct
10 Correct 3 ms 5016 KB Output is correct
11 Correct 5 ms 4948 KB Output is correct
12 Correct 4 ms 5020 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 4 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 4 ms 5076 KB Output is correct
18 Correct 4 ms 4948 KB Output is correct
19 Correct 4 ms 4932 KB Output is correct
20 Correct 5 ms 5020 KB Output is correct
21 Correct 3 ms 5028 KB Output is correct
22 Correct 4 ms 5024 KB Output is correct
23 Correct 3 ms 4948 KB Output is correct
24 Correct 4 ms 5024 KB Output is correct
25 Correct 3 ms 4948 KB Output is correct
26 Correct 3 ms 5024 KB Output is correct
27 Correct 3 ms 4948 KB Output is correct
28 Correct 5 ms 5020 KB Output is correct
29 Execution timed out 2097 ms 18032 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 4 ms 5024 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 4 ms 4948 KB Output is correct
8 Correct 5 ms 4948 KB Output is correct
9 Correct 4 ms 4948 KB Output is correct
10 Correct 3 ms 5016 KB Output is correct
11 Correct 5 ms 4948 KB Output is correct
12 Correct 4 ms 5020 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 4 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 4 ms 5076 KB Output is correct
18 Correct 4 ms 4948 KB Output is correct
19 Correct 4 ms 4932 KB Output is correct
20 Correct 5 ms 5020 KB Output is correct
21 Correct 3 ms 5028 KB Output is correct
22 Correct 4 ms 5024 KB Output is correct
23 Correct 3 ms 4948 KB Output is correct
24 Correct 4 ms 5024 KB Output is correct
25 Correct 3 ms 4948 KB Output is correct
26 Correct 3 ms 5024 KB Output is correct
27 Correct 3 ms 4948 KB Output is correct
28 Correct 5 ms 5020 KB Output is correct
29 Correct 65 ms 5144 KB Output is correct
30 Correct 107 ms 5176 KB Output is correct
31 Correct 92 ms 5196 KB Output is correct
32 Correct 65 ms 5188 KB Output is correct
33 Correct 40 ms 5076 KB Output is correct
34 Correct 112 ms 5204 KB Output is correct
35 Correct 110 ms 5328 KB Output is correct
36 Correct 26 ms 5112 KB Output is correct
37 Correct 74 ms 5216 KB Output is correct
38 Correct 70 ms 5196 KB Output is correct
39 Correct 84 ms 5192 KB Output is correct
40 Correct 64 ms 5192 KB Output is correct
41 Correct 59 ms 5184 KB Output is correct
42 Correct 57 ms 5192 KB Output is correct
43 Correct 35 ms 5160 KB Output is correct
44 Correct 57 ms 5204 KB Output is correct
45 Correct 92 ms 5204 KB Output is correct
46 Correct 104 ms 5192 KB Output is correct
47 Correct 70 ms 5188 KB Output is correct
48 Correct 68 ms 5076 KB Output is correct
49 Correct 87 ms 5188 KB Output is correct
50 Correct 103 ms 5216 KB Output is correct
51 Correct 52 ms 5204 KB Output is correct
52 Correct 69 ms 5168 KB Output is correct
53 Correct 89 ms 5180 KB Output is correct
54 Correct 117 ms 5200 KB Output is correct
55 Execution timed out 2072 ms 22012 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 4 ms 5024 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 4 ms 4948 KB Output is correct
8 Correct 5 ms 4948 KB Output is correct
9 Correct 4 ms 4948 KB Output is correct
10 Correct 3 ms 5016 KB Output is correct
11 Correct 5 ms 4948 KB Output is correct
12 Correct 4 ms 5020 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 4 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 4 ms 5076 KB Output is correct
18 Correct 4 ms 4948 KB Output is correct
19 Correct 4 ms 4932 KB Output is correct
20 Correct 5 ms 5020 KB Output is correct
21 Correct 3 ms 5028 KB Output is correct
22 Correct 4 ms 5024 KB Output is correct
23 Correct 3 ms 4948 KB Output is correct
24 Correct 4 ms 5024 KB Output is correct
25 Correct 3 ms 4948 KB Output is correct
26 Correct 3 ms 5024 KB Output is correct
27 Correct 3 ms 4948 KB Output is correct
28 Correct 5 ms 5020 KB Output is correct
29 Correct 65 ms 5144 KB Output is correct
30 Correct 107 ms 5176 KB Output is correct
31 Correct 92 ms 5196 KB Output is correct
32 Correct 65 ms 5188 KB Output is correct
33 Correct 40 ms 5076 KB Output is correct
34 Correct 112 ms 5204 KB Output is correct
35 Correct 110 ms 5328 KB Output is correct
36 Correct 26 ms 5112 KB Output is correct
37 Correct 74 ms 5216 KB Output is correct
38 Correct 70 ms 5196 KB Output is correct
39 Correct 84 ms 5192 KB Output is correct
40 Correct 64 ms 5192 KB Output is correct
41 Correct 59 ms 5184 KB Output is correct
42 Correct 57 ms 5192 KB Output is correct
43 Correct 35 ms 5160 KB Output is correct
44 Correct 57 ms 5204 KB Output is correct
45 Correct 92 ms 5204 KB Output is correct
46 Correct 104 ms 5192 KB Output is correct
47 Correct 70 ms 5188 KB Output is correct
48 Correct 68 ms 5076 KB Output is correct
49 Correct 87 ms 5188 KB Output is correct
50 Correct 103 ms 5216 KB Output is correct
51 Correct 52 ms 5204 KB Output is correct
52 Correct 69 ms 5168 KB Output is correct
53 Correct 89 ms 5180 KB Output is correct
54 Correct 117 ms 5200 KB Output is correct
55 Execution timed out 2097 ms 18032 KB Time limit exceeded
56 Halted 0 ms 0 KB -