Submission #1006947

# Submission time Handle Problem Language Result Execution time Memory
1006947 2024-06-24T10:11:25 Z underwaterkillerwhale Joker (BOI20_joker) C++17
14 / 100
2000 ms 28040 KB
//#ifdef ONLINE_JUDGE
//    #include "cyberland.h"
//#endif

#include <bits/stdc++.h>
#define se              second
#define fs              first
#define mp              make_pair
#define pb              push_back
#define ll              long long
#define ii              pair<ll,ll>
#define ld              long double
#define SZ(v)           (int)v.size()
#define ALL(v)          v.begin(), v.end()
#define bit(msk, i)     ((msk >> i) & 1)
#define iter(id, v)     for(auto id : v)
#define rep(i,m,n)      for(int i=(m); i<=(n); i++)
#define reb(i,m,n)      for(int i=(m); i>=(n); i--)

using namespace std;

mt19937_64 rd(chrono :: steady_clock :: now().time_since_epoch().count());
ll Rand(ll l, ll r) { return uniform_int_distribution<ll> (l, r)(rd); }

const int N  = 3e5 + 2;
const ll Mod = 998244353;
const int szBL = 50;
const int INF = 1e9 + 7;
const int BASE = 137;

struct Query {
    int L, R;
};

int n, m, Q;
pair<int,int> edges[N];
Query qr[N];

namespace sub3 {
    vector<pair<int,int>> ke[N];
    int num[N], high[N];

    int time_dfs = 0, res = 0;
    void dfs (int u, int p, int L, int R) {
        num[u] = 1;
        high[u] = high[p] + 1;
        iter (&id, ke[u])  {
            int v, idx;
            tie (v, idx) = id;
            if (v == p || (idx >= L && idx <= R)) continue;
            if (!num[v]) {
                dfs (v, u, L, R);
            }
            else res = max(res, (high[u] - high[v] + 1) % 2);
        }
    }
    void solution() {
        rep (i, 1, m) {
            int u, v;
            tie(u, v) = edges[i];
            ke[u].push_back({v, i});
            ke[v].push_back({u, i});
        }
        rep (q, 1, Q) {
            int L = qr[q].L, R = qr[q].R;
            rep (u, 1, n) num[u] = 0;
            res = 0;
            rep (u, 1, n) {
                if (num[u]) continue;
                time_dfs = 0;
                dfs (u, 0, L, R);
            }
            if (res) cout << "YES\n";
            else cout <<"NO\n";
        }
    }
}

void solution() {
    cin >> n >> m >> Q;
    rep (i, 1, m) {
        cin >> edges[i].fs >> edges[i].se;
    }
    rep (i, 1, Q) {
        cin >> qr[i].L >> qr[i].R;
    }
    sub3 :: solution();

}
#define file(name) freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout);
int main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//    file ("PAINT");
    int num_Test = 1;
//    cin >> num_Test;
    while (num_Test--)
        solution();
}

/*
5 7
11011
query 1 2
query 1 2
query 1 2
query 3 4
toggle 3
query 3 4
query 1 2



3 2
0 1 5
0 2 5
1
1 2

*/
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12636 KB Output is correct
2 Correct 2 ms 12636 KB Output is correct
3 Correct 2 ms 12716 KB Output is correct
4 Correct 2 ms 12636 KB Output is correct
5 Correct 2 ms 12636 KB Output is correct
6 Correct 2 ms 12636 KB Output is correct
7 Correct 2 ms 12636 KB Output is correct
8 Correct 2 ms 12636 KB Output is correct
9 Correct 2 ms 12636 KB Output is correct
10 Correct 2 ms 12636 KB Output is correct
11 Correct 3 ms 12636 KB Output is correct
12 Correct 2 ms 12636 KB Output is correct
13 Correct 2 ms 12636 KB Output is correct
14 Correct 2 ms 12636 KB Output is correct
15 Correct 2 ms 12636 KB Output is correct
16 Correct 2 ms 12636 KB Output is correct
17 Correct 2 ms 12636 KB Output is correct
18 Correct 2 ms 12636 KB Output is correct
19 Correct 2 ms 12888 KB Output is correct
20 Correct 2 ms 12636 KB Output is correct
21 Correct 2 ms 12784 KB Output is correct
22 Correct 2 ms 12636 KB Output is correct
23 Correct 2 ms 12636 KB Output is correct
24 Correct 2 ms 12636 KB Output is correct
25 Correct 2 ms 12636 KB Output is correct
26 Correct 3 ms 12636 KB Output is correct
27 Correct 2 ms 12784 KB Output is correct
28 Correct 2 ms 12636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12636 KB Output is correct
2 Correct 2 ms 12636 KB Output is correct
3 Correct 2 ms 12716 KB Output is correct
4 Correct 2 ms 12636 KB Output is correct
5 Correct 2 ms 12636 KB Output is correct
6 Correct 2 ms 12636 KB Output is correct
7 Correct 2 ms 12636 KB Output is correct
8 Correct 2 ms 12636 KB Output is correct
9 Correct 2 ms 12636 KB Output is correct
10 Correct 2 ms 12636 KB Output is correct
11 Correct 3 ms 12636 KB Output is correct
12 Correct 2 ms 12636 KB Output is correct
13 Correct 2 ms 12636 KB Output is correct
14 Correct 2 ms 12636 KB Output is correct
15 Correct 2 ms 12636 KB Output is correct
16 Correct 2 ms 12636 KB Output is correct
17 Correct 2 ms 12636 KB Output is correct
18 Correct 2 ms 12636 KB Output is correct
19 Correct 2 ms 12888 KB Output is correct
20 Correct 2 ms 12636 KB Output is correct
21 Correct 2 ms 12784 KB Output is correct
22 Correct 2 ms 12636 KB Output is correct
23 Correct 2 ms 12636 KB Output is correct
24 Correct 2 ms 12636 KB Output is correct
25 Correct 2 ms 12636 KB Output is correct
26 Correct 3 ms 12636 KB Output is correct
27 Correct 2 ms 12784 KB Output is correct
28 Correct 2 ms 12636 KB Output is correct
29 Correct 34 ms 12636 KB Output is correct
30 Correct 74 ms 12900 KB Output is correct
31 Correct 75 ms 12892 KB Output is correct
32 Correct 57 ms 12892 KB Output is correct
33 Correct 45 ms 12892 KB Output is correct
34 Correct 79 ms 12892 KB Output is correct
35 Correct 82 ms 12892 KB Output is correct
36 Correct 28 ms 12972 KB Output is correct
37 Correct 45 ms 12892 KB Output is correct
38 Correct 37 ms 12892 KB Output is correct
39 Correct 55 ms 12892 KB Output is correct
40 Correct 51 ms 12892 KB Output is correct
41 Correct 54 ms 12936 KB Output is correct
42 Correct 51 ms 12892 KB Output is correct
43 Correct 41 ms 12892 KB Output is correct
44 Correct 59 ms 12892 KB Output is correct
45 Correct 70 ms 12892 KB Output is correct
46 Correct 61 ms 12892 KB Output is correct
47 Correct 43 ms 12892 KB Output is correct
48 Correct 51 ms 12892 KB Output is correct
49 Correct 57 ms 12904 KB Output is correct
50 Correct 59 ms 12812 KB Output is correct
51 Correct 54 ms 12892 KB Output is correct
52 Correct 64 ms 12892 KB Output is correct
53 Correct 64 ms 12892 KB Output is correct
54 Correct 81 ms 12892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12636 KB Output is correct
2 Correct 2 ms 12636 KB Output is correct
3 Execution timed out 2017 ms 27848 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12636 KB Output is correct
2 Correct 2 ms 12636 KB Output is correct
3 Correct 2 ms 12716 KB Output is correct
4 Correct 2 ms 12636 KB Output is correct
5 Correct 2 ms 12636 KB Output is correct
6 Correct 2 ms 12636 KB Output is correct
7 Correct 2 ms 12636 KB Output is correct
8 Correct 2 ms 12636 KB Output is correct
9 Correct 2 ms 12636 KB Output is correct
10 Correct 2 ms 12636 KB Output is correct
11 Correct 3 ms 12636 KB Output is correct
12 Correct 2 ms 12636 KB Output is correct
13 Correct 2 ms 12636 KB Output is correct
14 Correct 2 ms 12636 KB Output is correct
15 Correct 2 ms 12636 KB Output is correct
16 Correct 2 ms 12636 KB Output is correct
17 Correct 2 ms 12636 KB Output is correct
18 Correct 2 ms 12636 KB Output is correct
19 Correct 2 ms 12888 KB Output is correct
20 Correct 2 ms 12636 KB Output is correct
21 Correct 2 ms 12784 KB Output is correct
22 Correct 2 ms 12636 KB Output is correct
23 Correct 2 ms 12636 KB Output is correct
24 Correct 2 ms 12636 KB Output is correct
25 Correct 2 ms 12636 KB Output is correct
26 Correct 3 ms 12636 KB Output is correct
27 Correct 2 ms 12784 KB Output is correct
28 Correct 2 ms 12636 KB Output is correct
29 Execution timed out 2017 ms 27848 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12636 KB Output is correct
2 Correct 2 ms 12636 KB Output is correct
3 Correct 2 ms 12716 KB Output is correct
4 Correct 2 ms 12636 KB Output is correct
5 Correct 2 ms 12636 KB Output is correct
6 Correct 2 ms 12636 KB Output is correct
7 Correct 2 ms 12636 KB Output is correct
8 Correct 2 ms 12636 KB Output is correct
9 Correct 2 ms 12636 KB Output is correct
10 Correct 2 ms 12636 KB Output is correct
11 Correct 3 ms 12636 KB Output is correct
12 Correct 2 ms 12636 KB Output is correct
13 Correct 2 ms 12636 KB Output is correct
14 Correct 2 ms 12636 KB Output is correct
15 Correct 2 ms 12636 KB Output is correct
16 Correct 2 ms 12636 KB Output is correct
17 Correct 2 ms 12636 KB Output is correct
18 Correct 2 ms 12636 KB Output is correct
19 Correct 2 ms 12888 KB Output is correct
20 Correct 2 ms 12636 KB Output is correct
21 Correct 2 ms 12784 KB Output is correct
22 Correct 2 ms 12636 KB Output is correct
23 Correct 2 ms 12636 KB Output is correct
24 Correct 2 ms 12636 KB Output is correct
25 Correct 2 ms 12636 KB Output is correct
26 Correct 3 ms 12636 KB Output is correct
27 Correct 2 ms 12784 KB Output is correct
28 Correct 2 ms 12636 KB Output is correct
29 Correct 34 ms 12636 KB Output is correct
30 Correct 74 ms 12900 KB Output is correct
31 Correct 75 ms 12892 KB Output is correct
32 Correct 57 ms 12892 KB Output is correct
33 Correct 45 ms 12892 KB Output is correct
34 Correct 79 ms 12892 KB Output is correct
35 Correct 82 ms 12892 KB Output is correct
36 Correct 28 ms 12972 KB Output is correct
37 Correct 45 ms 12892 KB Output is correct
38 Correct 37 ms 12892 KB Output is correct
39 Correct 55 ms 12892 KB Output is correct
40 Correct 51 ms 12892 KB Output is correct
41 Correct 54 ms 12936 KB Output is correct
42 Correct 51 ms 12892 KB Output is correct
43 Correct 41 ms 12892 KB Output is correct
44 Correct 59 ms 12892 KB Output is correct
45 Correct 70 ms 12892 KB Output is correct
46 Correct 61 ms 12892 KB Output is correct
47 Correct 43 ms 12892 KB Output is correct
48 Correct 51 ms 12892 KB Output is correct
49 Correct 57 ms 12904 KB Output is correct
50 Correct 59 ms 12812 KB Output is correct
51 Correct 54 ms 12892 KB Output is correct
52 Correct 64 ms 12892 KB Output is correct
53 Correct 64 ms 12892 KB Output is correct
54 Correct 81 ms 12892 KB Output is correct
55 Execution timed out 2041 ms 28040 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12636 KB Output is correct
2 Correct 2 ms 12636 KB Output is correct
3 Correct 2 ms 12716 KB Output is correct
4 Correct 2 ms 12636 KB Output is correct
5 Correct 2 ms 12636 KB Output is correct
6 Correct 2 ms 12636 KB Output is correct
7 Correct 2 ms 12636 KB Output is correct
8 Correct 2 ms 12636 KB Output is correct
9 Correct 2 ms 12636 KB Output is correct
10 Correct 2 ms 12636 KB Output is correct
11 Correct 3 ms 12636 KB Output is correct
12 Correct 2 ms 12636 KB Output is correct
13 Correct 2 ms 12636 KB Output is correct
14 Correct 2 ms 12636 KB Output is correct
15 Correct 2 ms 12636 KB Output is correct
16 Correct 2 ms 12636 KB Output is correct
17 Correct 2 ms 12636 KB Output is correct
18 Correct 2 ms 12636 KB Output is correct
19 Correct 2 ms 12888 KB Output is correct
20 Correct 2 ms 12636 KB Output is correct
21 Correct 2 ms 12784 KB Output is correct
22 Correct 2 ms 12636 KB Output is correct
23 Correct 2 ms 12636 KB Output is correct
24 Correct 2 ms 12636 KB Output is correct
25 Correct 2 ms 12636 KB Output is correct
26 Correct 3 ms 12636 KB Output is correct
27 Correct 2 ms 12784 KB Output is correct
28 Correct 2 ms 12636 KB Output is correct
29 Correct 34 ms 12636 KB Output is correct
30 Correct 74 ms 12900 KB Output is correct
31 Correct 75 ms 12892 KB Output is correct
32 Correct 57 ms 12892 KB Output is correct
33 Correct 45 ms 12892 KB Output is correct
34 Correct 79 ms 12892 KB Output is correct
35 Correct 82 ms 12892 KB Output is correct
36 Correct 28 ms 12972 KB Output is correct
37 Correct 45 ms 12892 KB Output is correct
38 Correct 37 ms 12892 KB Output is correct
39 Correct 55 ms 12892 KB Output is correct
40 Correct 51 ms 12892 KB Output is correct
41 Correct 54 ms 12936 KB Output is correct
42 Correct 51 ms 12892 KB Output is correct
43 Correct 41 ms 12892 KB Output is correct
44 Correct 59 ms 12892 KB Output is correct
45 Correct 70 ms 12892 KB Output is correct
46 Correct 61 ms 12892 KB Output is correct
47 Correct 43 ms 12892 KB Output is correct
48 Correct 51 ms 12892 KB Output is correct
49 Correct 57 ms 12904 KB Output is correct
50 Correct 59 ms 12812 KB Output is correct
51 Correct 54 ms 12892 KB Output is correct
52 Correct 64 ms 12892 KB Output is correct
53 Correct 64 ms 12892 KB Output is correct
54 Correct 81 ms 12892 KB Output is correct
55 Execution timed out 2017 ms 27848 KB Time limit exceeded
56 Halted 0 ms 0 KB -