Submission #925650

# Submission time Handle Problem Language Result Execution time Memory
925650 2024-02-12T06:56:50 Z vjudge1 Joker (BOI20_joker) C++17
14 / 100
1575 ms 1208 KB
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

#define int long long
#define ff first
#define ss second
#define pb push_back
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define no1 cout<<"-1\n"

using namespace std;

const int N = 3000;
const int M = 2e5+100;
const int INF = 1e18;
const int mod = 998244353;
  
// int binpow (int a, int n) {
// 	if (n == 0)
// 		return 1;
// 	if (n % 2 == 1)
// 		return (binpow (a, n-1) * a)%mod;
// 	else {
// 		int b = binpow (a, n/2) % mod;
// 		return (b * b)%mod;
// 	}
// }

int n,m,q;
vector<int> g[N];
vector<pair<int,int>> edges;
int d[N];
bool was[N];
map<pair<int,int>,bool> del;
bool ok;

void dfs(int v, int p = 0){
    was[v] = 1;
    d[v] = d[p]+1;
    for(auto to:g[v]){
        if(del[{to,v}]) continue;
        if(!was[to]) dfs(to,v);
        if(was[to] && (d[v]-d[to])%2 == 0) ok = 1;
    }
}

void solve(){
    cin>>n>>m>>q;
    for(int i = 1;i<=m;i++){
        int u,v;
        cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
        edges.pb({u,v});
    }
    while(q--){
        int l,r;
        cin>>l>>r;
        del.clear();
        for(int i = 1;i<=n;i++){
            was[i] = 0;
            d[i] = 0;
        }
        ok = 0;
        for(int i = l-1;i<r;i++){
            del[{edges[i].ff,edges[i].ss}] = 1;
            del[{edges[i].ss,edges[i].ff}] = 1;
        }
        for(int i = 1;i<=n;i++){
            if(!was[i]){
                dfs(i);
            }
        }
        if(ok) yes;
        else no;
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    // cout.tie(nullptr);
    int t = 1; 
    // cin>>t;
    //   cout<<"";
    for(int i = 1;i<=t;i++){
        solve();
        // cout<<'\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 11 ms 348 KB Output is correct
9 Correct 12 ms 576 KB Output is correct
10 Correct 12 ms 348 KB Output is correct
11 Correct 12 ms 348 KB Output is correct
12 Correct 12 ms 348 KB Output is correct
13 Correct 13 ms 580 KB Output is correct
14 Correct 10 ms 348 KB Output is correct
15 Correct 11 ms 576 KB Output is correct
16 Correct 12 ms 348 KB Output is correct
17 Correct 12 ms 348 KB Output is correct
18 Correct 13 ms 348 KB Output is correct
19 Correct 12 ms 576 KB Output is correct
20 Correct 10 ms 348 KB Output is correct
21 Correct 11 ms 348 KB Output is correct
22 Correct 11 ms 584 KB Output is correct
23 Correct 12 ms 572 KB Output is correct
24 Correct 12 ms 348 KB Output is correct
25 Correct 12 ms 344 KB Output is correct
26 Correct 13 ms 580 KB Output is correct
27 Correct 12 ms 348 KB Output is correct
28 Correct 12 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 11 ms 348 KB Output is correct
9 Correct 12 ms 576 KB Output is correct
10 Correct 12 ms 348 KB Output is correct
11 Correct 12 ms 348 KB Output is correct
12 Correct 12 ms 348 KB Output is correct
13 Correct 13 ms 580 KB Output is correct
14 Correct 10 ms 348 KB Output is correct
15 Correct 11 ms 576 KB Output is correct
16 Correct 12 ms 348 KB Output is correct
17 Correct 12 ms 348 KB Output is correct
18 Correct 13 ms 348 KB Output is correct
19 Correct 12 ms 576 KB Output is correct
20 Correct 10 ms 348 KB Output is correct
21 Correct 11 ms 348 KB Output is correct
22 Correct 11 ms 584 KB Output is correct
23 Correct 12 ms 572 KB Output is correct
24 Correct 12 ms 348 KB Output is correct
25 Correct 12 ms 344 KB Output is correct
26 Correct 13 ms 580 KB Output is correct
27 Correct 12 ms 348 KB Output is correct
28 Correct 12 ms 348 KB Output is correct
29 Correct 593 ms 708 KB Output is correct
30 Correct 1338 ms 920 KB Output is correct
31 Correct 1522 ms 956 KB Output is correct
32 Correct 1550 ms 1104 KB Output is correct
33 Correct 1536 ms 1112 KB Output is correct
34 Correct 1510 ms 960 KB Output is correct
35 Correct 1482 ms 1208 KB Output is correct
36 Correct 1420 ms 1108 KB Output is correct
37 Correct 1365 ms 960 KB Output is correct
38 Correct 1246 ms 924 KB Output is correct
39 Correct 1497 ms 944 KB Output is correct
40 Correct 1548 ms 948 KB Output is correct
41 Correct 1558 ms 944 KB Output is correct
42 Correct 1546 ms 948 KB Output is correct
43 Correct 1352 ms 1104 KB Output is correct
44 Correct 1330 ms 940 KB Output is correct
45 Correct 1340 ms 948 KB Output is correct
46 Correct 1348 ms 964 KB Output is correct
47 Correct 1531 ms 920 KB Output is correct
48 Correct 1539 ms 932 KB Output is correct
49 Correct 1499 ms 940 KB Output is correct
50 Correct 1575 ms 1112 KB Output is correct
51 Correct 1569 ms 1108 KB Output is correct
52 Correct 1541 ms 940 KB Output is correct
53 Correct 1574 ms 860 KB Output is correct
54 Correct 1495 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 1 ms 604 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 11 ms 348 KB Output is correct
9 Correct 12 ms 576 KB Output is correct
10 Correct 12 ms 348 KB Output is correct
11 Correct 12 ms 348 KB Output is correct
12 Correct 12 ms 348 KB Output is correct
13 Correct 13 ms 580 KB Output is correct
14 Correct 10 ms 348 KB Output is correct
15 Correct 11 ms 576 KB Output is correct
16 Correct 12 ms 348 KB Output is correct
17 Correct 12 ms 348 KB Output is correct
18 Correct 13 ms 348 KB Output is correct
19 Correct 12 ms 576 KB Output is correct
20 Correct 10 ms 348 KB Output is correct
21 Correct 11 ms 348 KB Output is correct
22 Correct 11 ms 584 KB Output is correct
23 Correct 12 ms 572 KB Output is correct
24 Correct 12 ms 348 KB Output is correct
25 Correct 12 ms 344 KB Output is correct
26 Correct 13 ms 580 KB Output is correct
27 Correct 12 ms 348 KB Output is correct
28 Correct 12 ms 348 KB Output is correct
29 Runtime error 1 ms 604 KB Execution killed with signal 11
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 11 ms 348 KB Output is correct
9 Correct 12 ms 576 KB Output is correct
10 Correct 12 ms 348 KB Output is correct
11 Correct 12 ms 348 KB Output is correct
12 Correct 12 ms 348 KB Output is correct
13 Correct 13 ms 580 KB Output is correct
14 Correct 10 ms 348 KB Output is correct
15 Correct 11 ms 576 KB Output is correct
16 Correct 12 ms 348 KB Output is correct
17 Correct 12 ms 348 KB Output is correct
18 Correct 13 ms 348 KB Output is correct
19 Correct 12 ms 576 KB Output is correct
20 Correct 10 ms 348 KB Output is correct
21 Correct 11 ms 348 KB Output is correct
22 Correct 11 ms 584 KB Output is correct
23 Correct 12 ms 572 KB Output is correct
24 Correct 12 ms 348 KB Output is correct
25 Correct 12 ms 344 KB Output is correct
26 Correct 13 ms 580 KB Output is correct
27 Correct 12 ms 348 KB Output is correct
28 Correct 12 ms 348 KB Output is correct
29 Correct 593 ms 708 KB Output is correct
30 Correct 1338 ms 920 KB Output is correct
31 Correct 1522 ms 956 KB Output is correct
32 Correct 1550 ms 1104 KB Output is correct
33 Correct 1536 ms 1112 KB Output is correct
34 Correct 1510 ms 960 KB Output is correct
35 Correct 1482 ms 1208 KB Output is correct
36 Correct 1420 ms 1108 KB Output is correct
37 Correct 1365 ms 960 KB Output is correct
38 Correct 1246 ms 924 KB Output is correct
39 Correct 1497 ms 944 KB Output is correct
40 Correct 1548 ms 948 KB Output is correct
41 Correct 1558 ms 944 KB Output is correct
42 Correct 1546 ms 948 KB Output is correct
43 Correct 1352 ms 1104 KB Output is correct
44 Correct 1330 ms 940 KB Output is correct
45 Correct 1340 ms 948 KB Output is correct
46 Correct 1348 ms 964 KB Output is correct
47 Correct 1531 ms 920 KB Output is correct
48 Correct 1539 ms 932 KB Output is correct
49 Correct 1499 ms 940 KB Output is correct
50 Correct 1575 ms 1112 KB Output is correct
51 Correct 1569 ms 1108 KB Output is correct
52 Correct 1541 ms 940 KB Output is correct
53 Correct 1574 ms 860 KB Output is correct
54 Correct 1495 ms 1108 KB Output is correct
55 Runtime error 1 ms 604 KB Execution killed with signal 11
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 11 ms 348 KB Output is correct
9 Correct 12 ms 576 KB Output is correct
10 Correct 12 ms 348 KB Output is correct
11 Correct 12 ms 348 KB Output is correct
12 Correct 12 ms 348 KB Output is correct
13 Correct 13 ms 580 KB Output is correct
14 Correct 10 ms 348 KB Output is correct
15 Correct 11 ms 576 KB Output is correct
16 Correct 12 ms 348 KB Output is correct
17 Correct 12 ms 348 KB Output is correct
18 Correct 13 ms 348 KB Output is correct
19 Correct 12 ms 576 KB Output is correct
20 Correct 10 ms 348 KB Output is correct
21 Correct 11 ms 348 KB Output is correct
22 Correct 11 ms 584 KB Output is correct
23 Correct 12 ms 572 KB Output is correct
24 Correct 12 ms 348 KB Output is correct
25 Correct 12 ms 344 KB Output is correct
26 Correct 13 ms 580 KB Output is correct
27 Correct 12 ms 348 KB Output is correct
28 Correct 12 ms 348 KB Output is correct
29 Correct 593 ms 708 KB Output is correct
30 Correct 1338 ms 920 KB Output is correct
31 Correct 1522 ms 956 KB Output is correct
32 Correct 1550 ms 1104 KB Output is correct
33 Correct 1536 ms 1112 KB Output is correct
34 Correct 1510 ms 960 KB Output is correct
35 Correct 1482 ms 1208 KB Output is correct
36 Correct 1420 ms 1108 KB Output is correct
37 Correct 1365 ms 960 KB Output is correct
38 Correct 1246 ms 924 KB Output is correct
39 Correct 1497 ms 944 KB Output is correct
40 Correct 1548 ms 948 KB Output is correct
41 Correct 1558 ms 944 KB Output is correct
42 Correct 1546 ms 948 KB Output is correct
43 Correct 1352 ms 1104 KB Output is correct
44 Correct 1330 ms 940 KB Output is correct
45 Correct 1340 ms 948 KB Output is correct
46 Correct 1348 ms 964 KB Output is correct
47 Correct 1531 ms 920 KB Output is correct
48 Correct 1539 ms 932 KB Output is correct
49 Correct 1499 ms 940 KB Output is correct
50 Correct 1575 ms 1112 KB Output is correct
51 Correct 1569 ms 1108 KB Output is correct
52 Correct 1541 ms 940 KB Output is correct
53 Correct 1574 ms 860 KB Output is correct
54 Correct 1495 ms 1108 KB Output is correct
55 Runtime error 1 ms 604 KB Execution killed with signal 11
56 Halted 0 ms 0 KB -