Submission #1093543

# Submission time Handle Problem Language Result Execution time Memory
1093543 2024-09-27T02:51:54 Z zNatsumi Joker (BOI20_joker) C++17
14 / 100
2000 ms 5724 KB
#include <bits/stdc++.h>

using namespace std;

#define ii pair<int, int>
#define fi first
#define se second

const int N = 2e5 + 5;

int n, m, q;
int pa[N], sz[N], lz[N];
ii edge[N];

int fset(int i, int &c){
  c ^= lz[i];
  return i == pa[i] ? i : fset(pa[i], c);
}

bool uset(int u, int v){
  int cu = 0, cv = 0;
  u = fset(u, cu);
  v = fset(v, cv);
  if(u == v){
    if(cu == cv) return true;
    return false;
  }
  if(sz[u] < sz[v]) swap(u, v);
  pa[v] = u;
  sz[u] += sz[v];
  if(cu == cv) lz[v] ^= 1;
  return false;
}

int32_t main(){
  cin.tie(0)->sync_with_stdio(0);
  #define task "test"
  if(fopen(task ".inp", "r")){
    freopen(task ".inp", "r", stdin);
    freopen(task ".out", "w", stdout);
  }

  cin >> n >> m >> q;
  for(int i = 1; i <= m; i++){
    int u, v; cin >> u >> v;
    edge[i] = {u, v};
  }
  for(int t = 1; t <= q; t++){
    int l, r; cin >> l >> r;

    for(int i = 1; i <= n; i++){
      pa[i] = i;
      sz[i] = 1;
      lz[i] = 0;
    }
    bool ok = false;
    for(int i = 1; i <= m; i++){
      if(l <= i && i <= r) continue;

      if(uset(edge[i].fi, edge[i].se)){
        ok = true;
        break;
      }
    }
    cout << (ok ? "YES\n" : "NO\n");
  }

  return 0;
}

Compilation message

Joker.cpp: In function 'int32_t main()':
Joker.cpp:39:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     freopen(task ".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Joker.cpp:40:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |     freopen(task ".out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 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 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 488 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 468 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 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 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 488 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 468 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 13 ms 348 KB Output is correct
30 Correct 17 ms 552 KB Output is correct
31 Correct 15 ms 344 KB Output is correct
32 Correct 9 ms 348 KB Output is correct
33 Correct 5 ms 348 KB Output is correct
34 Correct 13 ms 344 KB Output is correct
35 Correct 19 ms 348 KB Output is correct
36 Correct 14 ms 348 KB Output is correct
37 Correct 26 ms 556 KB Output is correct
38 Correct 52 ms 348 KB Output is correct
39 Correct 17 ms 556 KB Output is correct
40 Correct 12 ms 348 KB Output is correct
41 Correct 14 ms 552 KB Output is correct
42 Correct 11 ms 548 KB Output is correct
43 Correct 14 ms 348 KB Output is correct
44 Correct 14 ms 348 KB Output is correct
45 Correct 14 ms 348 KB Output is correct
46 Correct 15 ms 568 KB Output is correct
47 Correct 13 ms 348 KB Output is correct
48 Correct 14 ms 544 KB Output is correct
49 Correct 15 ms 424 KB Output is correct
50 Correct 17 ms 348 KB Output is correct
51 Correct 13 ms 348 KB Output is correct
52 Correct 14 ms 548 KB Output is correct
53 Correct 15 ms 552 KB Output is correct
54 Correct 18 ms 600 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 Execution timed out 2047 ms 5724 KB Time limit exceeded
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 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 488 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 468 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Execution timed out 2047 ms 5724 KB Time limit exceeded
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 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 488 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 468 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 13 ms 348 KB Output is correct
30 Correct 17 ms 552 KB Output is correct
31 Correct 15 ms 344 KB Output is correct
32 Correct 9 ms 348 KB Output is correct
33 Correct 5 ms 348 KB Output is correct
34 Correct 13 ms 344 KB Output is correct
35 Correct 19 ms 348 KB Output is correct
36 Correct 14 ms 348 KB Output is correct
37 Correct 26 ms 556 KB Output is correct
38 Correct 52 ms 348 KB Output is correct
39 Correct 17 ms 556 KB Output is correct
40 Correct 12 ms 348 KB Output is correct
41 Correct 14 ms 552 KB Output is correct
42 Correct 11 ms 548 KB Output is correct
43 Correct 14 ms 348 KB Output is correct
44 Correct 14 ms 348 KB Output is correct
45 Correct 14 ms 348 KB Output is correct
46 Correct 15 ms 568 KB Output is correct
47 Correct 13 ms 348 KB Output is correct
48 Correct 14 ms 544 KB Output is correct
49 Correct 15 ms 424 KB Output is correct
50 Correct 17 ms 348 KB Output is correct
51 Correct 13 ms 348 KB Output is correct
52 Correct 14 ms 548 KB Output is correct
53 Correct 15 ms 552 KB Output is correct
54 Correct 18 ms 600 KB Output is correct
55 Execution timed out 2061 ms 5516 KB Time limit exceeded
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 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 488 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 468 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 13 ms 348 KB Output is correct
30 Correct 17 ms 552 KB Output is correct
31 Correct 15 ms 344 KB Output is correct
32 Correct 9 ms 348 KB Output is correct
33 Correct 5 ms 348 KB Output is correct
34 Correct 13 ms 344 KB Output is correct
35 Correct 19 ms 348 KB Output is correct
36 Correct 14 ms 348 KB Output is correct
37 Correct 26 ms 556 KB Output is correct
38 Correct 52 ms 348 KB Output is correct
39 Correct 17 ms 556 KB Output is correct
40 Correct 12 ms 348 KB Output is correct
41 Correct 14 ms 552 KB Output is correct
42 Correct 11 ms 548 KB Output is correct
43 Correct 14 ms 348 KB Output is correct
44 Correct 14 ms 348 KB Output is correct
45 Correct 14 ms 348 KB Output is correct
46 Correct 15 ms 568 KB Output is correct
47 Correct 13 ms 348 KB Output is correct
48 Correct 14 ms 544 KB Output is correct
49 Correct 15 ms 424 KB Output is correct
50 Correct 17 ms 348 KB Output is correct
51 Correct 13 ms 348 KB Output is correct
52 Correct 14 ms 548 KB Output is correct
53 Correct 15 ms 552 KB Output is correct
54 Correct 18 ms 600 KB Output is correct
55 Execution timed out 2047 ms 5724 KB Time limit exceeded
56 Halted 0 ms 0 KB -