Submission #648598

# Submission time Handle Problem Language Result Execution time Memory
648598 2022-10-07T06:45:03 Z mychecksedad Joker (BOI20_joker) C++17
39 / 100
364 ms 36076 KB
/* Author : Mychecksdead */
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define PI 3.1415926535
#define pb push_back
#define setp() cout << setprecision(15)
#define all(x) x.begin(), x.end()
#define oset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define debug(x) cerr << #x << " is " << x << '\n';
const int N = 1e6+100, M = 2e5+10, F = 2147483646, K = 20;


int n, m, q, l, r;
bool ok;
vector<pair<int, int>> g[N];
bitset<M> vis, pos;
void dfs(int v, int p, bool c){
    vis[v] = 1;
    pos[v] = c;
    for(auto k: g[v]){
        int u = k.first;
        if(l <= k.second && k.second <= r) continue;
        if(u != p){
            if(vis[u])
                ok |= pos[v] == pos[u];
            else
                dfs(u, v, !c);
        }
    }
}
void solve(){
    cin >> n >> m >> q;
    for(int i = 0; i < m; ++i){
        int u, v; cin >> u >> v;
        g[u].pb({v, i + 1});
        g[v].pb({u, i + 1});
    }
    if(n <= 2000 || q <= 1000){
        for(int i = 0; i < q; ++i){
            cin >> l >> r;
            vis = 0;
            ok = 0;
            for(int v = 1; v <= n; ++v) if(!ok && !vis[v]) dfs(v, v, 0);
            if(ok) cout << "YES\n";
            else cout << "NO\n";
        }
    }
    else{
        int lb = 1, rb = m, lim = 0;
        while(lb <= rb){
            int mid = (lb + rb) >> 1;
            l = 1, r = mid;
            vis = 0;
            ok = 0;
            for(int v = 1; v <= n; ++v) if(!ok && !vis[v]) dfs(v, v, 0);
            if(ok){
                lim = mid;
                lb = mid + 1;
            }else{
                rb = mid - 1;
            }
        }
        for(int i = 1; i <= q; ++i){
            cin >> l >> r;
            cout << (r <= lim ? "YES": "NO") << '\n';
        }
       }
}





int main(){
    cin.tie(0); ios::sync_with_stdio(0);
    int T = 1, aa;
    // cin >> T;aa=T;
    while(T--){
        // cout << "Case #" << aa-T << ": ";
        solve();
        cout << '\n';
    }
    return 0;
 
}

Compilation message

Joker.cpp: In function 'int main()':
Joker.cpp:82:16: warning: unused variable 'aa' [-Wunused-variable]
   82 |     int T = 1, aa;
      |                ^~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 13 ms 23764 KB Output is correct
3 Correct 12 ms 23764 KB Output is correct
4 Correct 12 ms 23764 KB Output is correct
5 Correct 12 ms 23764 KB Output is correct
6 Correct 15 ms 23764 KB Output is correct
7 Correct 15 ms 23764 KB Output is correct
8 Correct 14 ms 23780 KB Output is correct
9 Correct 14 ms 23868 KB Output is correct
10 Correct 13 ms 23764 KB Output is correct
11 Correct 13 ms 23764 KB Output is correct
12 Correct 13 ms 23764 KB Output is correct
13 Correct 12 ms 23780 KB Output is correct
14 Correct 13 ms 23784 KB Output is correct
15 Correct 13 ms 23764 KB Output is correct
16 Correct 13 ms 23840 KB Output is correct
17 Correct 12 ms 23764 KB Output is correct
18 Correct 14 ms 23764 KB Output is correct
19 Correct 13 ms 23868 KB Output is correct
20 Correct 13 ms 23764 KB Output is correct
21 Correct 13 ms 23864 KB Output is correct
22 Correct 13 ms 23756 KB Output is correct
23 Correct 13 ms 23764 KB Output is correct
24 Correct 14 ms 23812 KB Output is correct
25 Correct 14 ms 23764 KB Output is correct
26 Correct 16 ms 23768 KB Output is correct
27 Correct 13 ms 23868 KB Output is correct
28 Correct 15 ms 23784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 13 ms 23764 KB Output is correct
3 Correct 12 ms 23764 KB Output is correct
4 Correct 12 ms 23764 KB Output is correct
5 Correct 12 ms 23764 KB Output is correct
6 Correct 15 ms 23764 KB Output is correct
7 Correct 15 ms 23764 KB Output is correct
8 Correct 14 ms 23780 KB Output is correct
9 Correct 14 ms 23868 KB Output is correct
10 Correct 13 ms 23764 KB Output is correct
11 Correct 13 ms 23764 KB Output is correct
12 Correct 13 ms 23764 KB Output is correct
13 Correct 12 ms 23780 KB Output is correct
14 Correct 13 ms 23784 KB Output is correct
15 Correct 13 ms 23764 KB Output is correct
16 Correct 13 ms 23840 KB Output is correct
17 Correct 12 ms 23764 KB Output is correct
18 Correct 14 ms 23764 KB Output is correct
19 Correct 13 ms 23868 KB Output is correct
20 Correct 13 ms 23764 KB Output is correct
21 Correct 13 ms 23864 KB Output is correct
22 Correct 13 ms 23756 KB Output is correct
23 Correct 13 ms 23764 KB Output is correct
24 Correct 14 ms 23812 KB Output is correct
25 Correct 14 ms 23764 KB Output is correct
26 Correct 16 ms 23768 KB Output is correct
27 Correct 13 ms 23868 KB Output is correct
28 Correct 15 ms 23784 KB Output is correct
29 Correct 95 ms 23892 KB Output is correct
30 Correct 97 ms 23940 KB Output is correct
31 Correct 107 ms 23968 KB Output is correct
32 Correct 87 ms 23952 KB Output is correct
33 Correct 79 ms 23944 KB Output is correct
34 Correct 100 ms 23952 KB Output is correct
35 Correct 117 ms 23964 KB Output is correct
36 Correct 47 ms 23892 KB Output is correct
37 Correct 91 ms 23936 KB Output is correct
38 Correct 100 ms 23936 KB Output is correct
39 Correct 93 ms 23964 KB Output is correct
40 Correct 92 ms 23972 KB Output is correct
41 Correct 84 ms 23968 KB Output is correct
42 Correct 89 ms 23988 KB Output is correct
43 Correct 78 ms 23892 KB Output is correct
44 Correct 109 ms 23892 KB Output is correct
45 Correct 120 ms 23952 KB Output is correct
46 Correct 122 ms 23952 KB Output is correct
47 Correct 91 ms 23944 KB Output is correct
48 Correct 92 ms 24012 KB Output is correct
49 Correct 95 ms 23964 KB Output is correct
50 Correct 94 ms 23936 KB Output is correct
51 Correct 79 ms 23952 KB Output is correct
52 Correct 93 ms 23980 KB Output is correct
53 Correct 106 ms 23992 KB Output is correct
54 Correct 132 ms 23956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 13 ms 23764 KB Output is correct
3 Correct 211 ms 34472 KB Output is correct
4 Correct 333 ms 34252 KB Output is correct
5 Correct 220 ms 32972 KB Output is correct
6 Correct 261 ms 34200 KB Output is correct
7 Correct 267 ms 34060 KB Output is correct
8 Correct 301 ms 33508 KB Output is correct
9 Correct 335 ms 34528 KB Output is correct
10 Correct 350 ms 33408 KB Output is correct
11 Correct 272 ms 33224 KB Output is correct
12 Correct 255 ms 32208 KB Output is correct
13 Correct 137 ms 31300 KB Output is correct
14 Correct 273 ms 33340 KB Output is correct
15 Correct 364 ms 34356 KB Output is correct
16 Correct 326 ms 33252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 13 ms 23764 KB Output is correct
3 Correct 12 ms 23764 KB Output is correct
4 Correct 12 ms 23764 KB Output is correct
5 Correct 12 ms 23764 KB Output is correct
6 Correct 15 ms 23764 KB Output is correct
7 Correct 15 ms 23764 KB Output is correct
8 Correct 14 ms 23780 KB Output is correct
9 Correct 14 ms 23868 KB Output is correct
10 Correct 13 ms 23764 KB Output is correct
11 Correct 13 ms 23764 KB Output is correct
12 Correct 13 ms 23764 KB Output is correct
13 Correct 12 ms 23780 KB Output is correct
14 Correct 13 ms 23784 KB Output is correct
15 Correct 13 ms 23764 KB Output is correct
16 Correct 13 ms 23840 KB Output is correct
17 Correct 12 ms 23764 KB Output is correct
18 Correct 14 ms 23764 KB Output is correct
19 Correct 13 ms 23868 KB Output is correct
20 Correct 13 ms 23764 KB Output is correct
21 Correct 13 ms 23864 KB Output is correct
22 Correct 13 ms 23756 KB Output is correct
23 Correct 13 ms 23764 KB Output is correct
24 Correct 14 ms 23812 KB Output is correct
25 Correct 14 ms 23764 KB Output is correct
26 Correct 16 ms 23768 KB Output is correct
27 Correct 13 ms 23868 KB Output is correct
28 Correct 15 ms 23784 KB Output is correct
29 Correct 211 ms 34472 KB Output is correct
30 Correct 333 ms 34252 KB Output is correct
31 Correct 220 ms 32972 KB Output is correct
32 Correct 261 ms 34200 KB Output is correct
33 Correct 267 ms 34060 KB Output is correct
34 Correct 301 ms 33508 KB Output is correct
35 Correct 335 ms 34528 KB Output is correct
36 Correct 350 ms 33408 KB Output is correct
37 Correct 272 ms 33224 KB Output is correct
38 Correct 255 ms 32208 KB Output is correct
39 Correct 137 ms 31300 KB Output is correct
40 Correct 273 ms 33340 KB Output is correct
41 Correct 364 ms 34356 KB Output is correct
42 Correct 326 ms 33252 KB Output is correct
43 Incorrect 253 ms 34172 KB Output isn't correct
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 13 ms 23764 KB Output is correct
3 Correct 12 ms 23764 KB Output is correct
4 Correct 12 ms 23764 KB Output is correct
5 Correct 12 ms 23764 KB Output is correct
6 Correct 15 ms 23764 KB Output is correct
7 Correct 15 ms 23764 KB Output is correct
8 Correct 14 ms 23780 KB Output is correct
9 Correct 14 ms 23868 KB Output is correct
10 Correct 13 ms 23764 KB Output is correct
11 Correct 13 ms 23764 KB Output is correct
12 Correct 13 ms 23764 KB Output is correct
13 Correct 12 ms 23780 KB Output is correct
14 Correct 13 ms 23784 KB Output is correct
15 Correct 13 ms 23764 KB Output is correct
16 Correct 13 ms 23840 KB Output is correct
17 Correct 12 ms 23764 KB Output is correct
18 Correct 14 ms 23764 KB Output is correct
19 Correct 13 ms 23868 KB Output is correct
20 Correct 13 ms 23764 KB Output is correct
21 Correct 13 ms 23864 KB Output is correct
22 Correct 13 ms 23756 KB Output is correct
23 Correct 13 ms 23764 KB Output is correct
24 Correct 14 ms 23812 KB Output is correct
25 Correct 14 ms 23764 KB Output is correct
26 Correct 16 ms 23768 KB Output is correct
27 Correct 13 ms 23868 KB Output is correct
28 Correct 15 ms 23784 KB Output is correct
29 Correct 95 ms 23892 KB Output is correct
30 Correct 97 ms 23940 KB Output is correct
31 Correct 107 ms 23968 KB Output is correct
32 Correct 87 ms 23952 KB Output is correct
33 Correct 79 ms 23944 KB Output is correct
34 Correct 100 ms 23952 KB Output is correct
35 Correct 117 ms 23964 KB Output is correct
36 Correct 47 ms 23892 KB Output is correct
37 Correct 91 ms 23936 KB Output is correct
38 Correct 100 ms 23936 KB Output is correct
39 Correct 93 ms 23964 KB Output is correct
40 Correct 92 ms 23972 KB Output is correct
41 Correct 84 ms 23968 KB Output is correct
42 Correct 89 ms 23988 KB Output is correct
43 Correct 78 ms 23892 KB Output is correct
44 Correct 109 ms 23892 KB Output is correct
45 Correct 120 ms 23952 KB Output is correct
46 Correct 122 ms 23952 KB Output is correct
47 Correct 91 ms 23944 KB Output is correct
48 Correct 92 ms 24012 KB Output is correct
49 Correct 95 ms 23964 KB Output is correct
50 Correct 94 ms 23936 KB Output is correct
51 Correct 79 ms 23952 KB Output is correct
52 Correct 93 ms 23980 KB Output is correct
53 Correct 106 ms 23992 KB Output is correct
54 Correct 132 ms 23956 KB Output is correct
55 Incorrect 172 ms 36076 KB Output isn't correct
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 13 ms 23764 KB Output is correct
3 Correct 12 ms 23764 KB Output is correct
4 Correct 12 ms 23764 KB Output is correct
5 Correct 12 ms 23764 KB Output is correct
6 Correct 15 ms 23764 KB Output is correct
7 Correct 15 ms 23764 KB Output is correct
8 Correct 14 ms 23780 KB Output is correct
9 Correct 14 ms 23868 KB Output is correct
10 Correct 13 ms 23764 KB Output is correct
11 Correct 13 ms 23764 KB Output is correct
12 Correct 13 ms 23764 KB Output is correct
13 Correct 12 ms 23780 KB Output is correct
14 Correct 13 ms 23784 KB Output is correct
15 Correct 13 ms 23764 KB Output is correct
16 Correct 13 ms 23840 KB Output is correct
17 Correct 12 ms 23764 KB Output is correct
18 Correct 14 ms 23764 KB Output is correct
19 Correct 13 ms 23868 KB Output is correct
20 Correct 13 ms 23764 KB Output is correct
21 Correct 13 ms 23864 KB Output is correct
22 Correct 13 ms 23756 KB Output is correct
23 Correct 13 ms 23764 KB Output is correct
24 Correct 14 ms 23812 KB Output is correct
25 Correct 14 ms 23764 KB Output is correct
26 Correct 16 ms 23768 KB Output is correct
27 Correct 13 ms 23868 KB Output is correct
28 Correct 15 ms 23784 KB Output is correct
29 Correct 95 ms 23892 KB Output is correct
30 Correct 97 ms 23940 KB Output is correct
31 Correct 107 ms 23968 KB Output is correct
32 Correct 87 ms 23952 KB Output is correct
33 Correct 79 ms 23944 KB Output is correct
34 Correct 100 ms 23952 KB Output is correct
35 Correct 117 ms 23964 KB Output is correct
36 Correct 47 ms 23892 KB Output is correct
37 Correct 91 ms 23936 KB Output is correct
38 Correct 100 ms 23936 KB Output is correct
39 Correct 93 ms 23964 KB Output is correct
40 Correct 92 ms 23972 KB Output is correct
41 Correct 84 ms 23968 KB Output is correct
42 Correct 89 ms 23988 KB Output is correct
43 Correct 78 ms 23892 KB Output is correct
44 Correct 109 ms 23892 KB Output is correct
45 Correct 120 ms 23952 KB Output is correct
46 Correct 122 ms 23952 KB Output is correct
47 Correct 91 ms 23944 KB Output is correct
48 Correct 92 ms 24012 KB Output is correct
49 Correct 95 ms 23964 KB Output is correct
50 Correct 94 ms 23936 KB Output is correct
51 Correct 79 ms 23952 KB Output is correct
52 Correct 93 ms 23980 KB Output is correct
53 Correct 106 ms 23992 KB Output is correct
54 Correct 132 ms 23956 KB Output is correct
55 Correct 211 ms 34472 KB Output is correct
56 Correct 333 ms 34252 KB Output is correct
57 Correct 220 ms 32972 KB Output is correct
58 Correct 261 ms 34200 KB Output is correct
59 Correct 267 ms 34060 KB Output is correct
60 Correct 301 ms 33508 KB Output is correct
61 Correct 335 ms 34528 KB Output is correct
62 Correct 350 ms 33408 KB Output is correct
63 Correct 272 ms 33224 KB Output is correct
64 Correct 255 ms 32208 KB Output is correct
65 Correct 137 ms 31300 KB Output is correct
66 Correct 273 ms 33340 KB Output is correct
67 Correct 364 ms 34356 KB Output is correct
68 Correct 326 ms 33252 KB Output is correct
69 Incorrect 253 ms 34172 KB Output isn't correct
70 Halted 0 ms 0 KB -