Submission #649752

# Submission time Handle Problem Language Result Execution time Memory
649752 2022-10-11T10:25:10 Z welleyth Joker (BOI20_joker) C++17
6 / 100
2000 ms 14572 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define pb push_back
#define mp make_pair

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

constexpr int N = (int)2e5 + 111;
constexpr int md = (int)2e5 + 111;

mt19937 rnd(time(nullptr));

vector<int> g[N];
bool used[2][N];
bool c[2][N];

bool dfs(int v,int r,int pr = -1){
    used[r][v] = true;
    c[r][v] = true;
    for(auto& to : g[v]){
        if(pr == to)
            continue;
        if(used[r^1][to]){
            if(c[r][v]&c[r][to])
                return true;
            continue;
        }
        c[r^1][to] = true;
        if(dfs(to,r^1,v))
            return true;
    }
    return false;
}

void solve(){
    int n,m,q;
    cin >> n >> m >> q;

    vector<pair<int,int>> edges;
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        edges.pb(mp(a,b));
    }

    for(int i = 0; i < q; i++){
        int l,r;
        cin >> l >> r;
        for(int j = 0; j <= n; j++){
            used[0][j] = false;
            used[1][j] = false;
            c[0][j] = c[1][j] = 0;
            g[j].clear();
        }
        for(int j = 0; j < l-1; j++){
            auto&[a,b] = edges[j];
            g[a].pb(b);
            g[b].pb(a);
        }
        for(int j = r; j <= m-1; j++){
            auto&[a,b] = edges[j];
            g[a].pb(b);
            g[b].pb(a);
        }
        bool ok = false;
        for(int j = 1; j <= n; j++){
            for(int t = 0; t <= n; t++){
                used[0][t] = false;
                used[1][t] = false;
                c[0][t] = c[1][t] = 0;
            }
            if(!used[0][j]){
                c[0][j] = 1;
                if(dfs(j,0)){
                    cout << "YES\n";
                    ok = true;
                    break;
                }
            }
        }
        if(!ok){
            cout << "NO\n";
        }
    }

    return;
}

signed main(){
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
//    init();
    int tests = 1;
//    cin >> tests;
    for(int test = 1; test <= tests; test++){
//        cerr << "test = " << test << "\n";
        solve();
    }
    return 0;
}
/**
6 8 2
1 3
1 5
1 6
2 5
2 6
3 4
3 5
5 6
4 7
4 8

**/
# Verdict Execution time Memory Grader output
1 Correct 4 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 3 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 7 ms 4948 KB Output is correct
8 Correct 8 ms 4948 KB Output is correct
9 Correct 7 ms 4948 KB Output is correct
10 Correct 6 ms 5032 KB Output is correct
11 Correct 9 ms 4948 KB Output is correct
12 Correct 12 ms 4948 KB Output is correct
13 Correct 6 ms 4948 KB Output is correct
14 Correct 60 ms 5044 KB Output is correct
15 Correct 50 ms 5048 KB Output is correct
16 Correct 17 ms 5060 KB Output is correct
17 Correct 6 ms 4948 KB Output is correct
18 Correct 6 ms 5032 KB Output is correct
19 Correct 6 ms 5028 KB Output is correct
20 Correct 3 ms 5032 KB Output is correct
21 Correct 3 ms 4948 KB Output is correct
22 Correct 4 ms 5032 KB Output is correct
23 Correct 8 ms 5064 KB Output is correct
24 Correct 11 ms 5032 KB Output is correct
25 Correct 6 ms 5028 KB Output is correct
26 Correct 8 ms 4948 KB Output is correct
27 Correct 7 ms 4948 KB Output is correct
28 Correct 9 ms 5028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 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 3 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 7 ms 4948 KB Output is correct
8 Correct 8 ms 4948 KB Output is correct
9 Correct 7 ms 4948 KB Output is correct
10 Correct 6 ms 5032 KB Output is correct
11 Correct 9 ms 4948 KB Output is correct
12 Correct 12 ms 4948 KB Output is correct
13 Correct 6 ms 4948 KB Output is correct
14 Correct 60 ms 5044 KB Output is correct
15 Correct 50 ms 5048 KB Output is correct
16 Correct 17 ms 5060 KB Output is correct
17 Correct 6 ms 4948 KB Output is correct
18 Correct 6 ms 5032 KB Output is correct
19 Correct 6 ms 5028 KB Output is correct
20 Correct 3 ms 5032 KB Output is correct
21 Correct 3 ms 4948 KB Output is correct
22 Correct 4 ms 5032 KB Output is correct
23 Correct 8 ms 5064 KB Output is correct
24 Correct 11 ms 5032 KB Output is correct
25 Correct 6 ms 5028 KB Output is correct
26 Correct 8 ms 4948 KB Output is correct
27 Correct 7 ms 4948 KB Output is correct
28 Correct 9 ms 5028 KB Output is correct
29 Correct 1335 ms 5116 KB Output is correct
30 Correct 1478 ms 5192 KB Output is correct
31 Correct 926 ms 5308 KB Output is correct
32 Correct 357 ms 5196 KB Output is correct
33 Correct 85 ms 5176 KB Output is correct
34 Correct 674 ms 5328 KB Output is correct
35 Execution timed out 2065 ms 5220 KB Time limit exceeded
36 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Execution timed out 2076 ms 14572 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 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 3 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 7 ms 4948 KB Output is correct
8 Correct 8 ms 4948 KB Output is correct
9 Correct 7 ms 4948 KB Output is correct
10 Correct 6 ms 5032 KB Output is correct
11 Correct 9 ms 4948 KB Output is correct
12 Correct 12 ms 4948 KB Output is correct
13 Correct 6 ms 4948 KB Output is correct
14 Correct 60 ms 5044 KB Output is correct
15 Correct 50 ms 5048 KB Output is correct
16 Correct 17 ms 5060 KB Output is correct
17 Correct 6 ms 4948 KB Output is correct
18 Correct 6 ms 5032 KB Output is correct
19 Correct 6 ms 5028 KB Output is correct
20 Correct 3 ms 5032 KB Output is correct
21 Correct 3 ms 4948 KB Output is correct
22 Correct 4 ms 5032 KB Output is correct
23 Correct 8 ms 5064 KB Output is correct
24 Correct 11 ms 5032 KB Output is correct
25 Correct 6 ms 5028 KB Output is correct
26 Correct 8 ms 4948 KB Output is correct
27 Correct 7 ms 4948 KB Output is correct
28 Correct 9 ms 5028 KB Output is correct
29 Execution timed out 2076 ms 14572 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 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 3 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 7 ms 4948 KB Output is correct
8 Correct 8 ms 4948 KB Output is correct
9 Correct 7 ms 4948 KB Output is correct
10 Correct 6 ms 5032 KB Output is correct
11 Correct 9 ms 4948 KB Output is correct
12 Correct 12 ms 4948 KB Output is correct
13 Correct 6 ms 4948 KB Output is correct
14 Correct 60 ms 5044 KB Output is correct
15 Correct 50 ms 5048 KB Output is correct
16 Correct 17 ms 5060 KB Output is correct
17 Correct 6 ms 4948 KB Output is correct
18 Correct 6 ms 5032 KB Output is correct
19 Correct 6 ms 5028 KB Output is correct
20 Correct 3 ms 5032 KB Output is correct
21 Correct 3 ms 4948 KB Output is correct
22 Correct 4 ms 5032 KB Output is correct
23 Correct 8 ms 5064 KB Output is correct
24 Correct 11 ms 5032 KB Output is correct
25 Correct 6 ms 5028 KB Output is correct
26 Correct 8 ms 4948 KB Output is correct
27 Correct 7 ms 4948 KB Output is correct
28 Correct 9 ms 5028 KB Output is correct
29 Correct 1335 ms 5116 KB Output is correct
30 Correct 1478 ms 5192 KB Output is correct
31 Correct 926 ms 5308 KB Output is correct
32 Correct 357 ms 5196 KB Output is correct
33 Correct 85 ms 5176 KB Output is correct
34 Correct 674 ms 5328 KB Output is correct
35 Execution timed out 2065 ms 5220 KB Time limit exceeded
36 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 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 3 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 7 ms 4948 KB Output is correct
8 Correct 8 ms 4948 KB Output is correct
9 Correct 7 ms 4948 KB Output is correct
10 Correct 6 ms 5032 KB Output is correct
11 Correct 9 ms 4948 KB Output is correct
12 Correct 12 ms 4948 KB Output is correct
13 Correct 6 ms 4948 KB Output is correct
14 Correct 60 ms 5044 KB Output is correct
15 Correct 50 ms 5048 KB Output is correct
16 Correct 17 ms 5060 KB Output is correct
17 Correct 6 ms 4948 KB Output is correct
18 Correct 6 ms 5032 KB Output is correct
19 Correct 6 ms 5028 KB Output is correct
20 Correct 3 ms 5032 KB Output is correct
21 Correct 3 ms 4948 KB Output is correct
22 Correct 4 ms 5032 KB Output is correct
23 Correct 8 ms 5064 KB Output is correct
24 Correct 11 ms 5032 KB Output is correct
25 Correct 6 ms 5028 KB Output is correct
26 Correct 8 ms 4948 KB Output is correct
27 Correct 7 ms 4948 KB Output is correct
28 Correct 9 ms 5028 KB Output is correct
29 Correct 1335 ms 5116 KB Output is correct
30 Correct 1478 ms 5192 KB Output is correct
31 Correct 926 ms 5308 KB Output is correct
32 Correct 357 ms 5196 KB Output is correct
33 Correct 85 ms 5176 KB Output is correct
34 Correct 674 ms 5328 KB Output is correct
35 Execution timed out 2065 ms 5220 KB Time limit exceeded
36 Halted 0 ms 0 KB -