Submission #1093510

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

using namespace std;

#define ii pair<int, int>
#define fi first
#define se second
#define all(x) x.begin(), x.end()

const int N = 2e5 + 5;

int n, m, q;
vector<ii> ad[N], que;

namespace sub1{
  int val[N];

  void solve(){
    for(auto x : que){
      int l, r; tie(l, r) = x;

      for(int i = 1; i <= n; i++) val[i] = -1;

      bool ok = false;
      for(int i = 1; i <= n; i++) if(val[i] == -1){
        queue<int> q;
        q.push(i);
        val[i] = 0;

        while(q.size()){
          auto u = q.front(); q.pop();

          for(auto [v, idx] : ad[u]){
            if(l <= idx && idx <= r) continue;
            if(val[v] == -1){
              q.push(v);
              val[v] = val[u] ^ 1;
            }
            else if(val[v] == val[u]){
              ok = true;
              break;
            }
          }
        }
        if(ok) break;
      }
      cout << (ok ? "YES\n" : "NO\n");
    }
  }
}

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;
    ad[u].push_back({v, i});
    ad[v].push_back({u, i});
  }
  for(int i = 1; i <= q; i++){
    int l, r; cin >> l >> r;
    que.push_back({l, r});
  }

  sub1::solve();


  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 4952 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 3 ms 5048 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 3 ms 4956 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 3 ms 4952 KB Output is correct
12 Correct 3 ms 4952 KB Output is correct
13 Correct 2 ms 5212 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 2 ms 4956 KB Output is correct
16 Correct 3 ms 4956 KB Output is correct
17 Correct 3 ms 5036 KB Output is correct
18 Correct 3 ms 4952 KB Output is correct
19 Correct 3 ms 4952 KB Output is correct
20 Correct 4 ms 4956 KB Output is correct
21 Correct 4 ms 4980 KB Output is correct
22 Correct 3 ms 4956 KB Output is correct
23 Correct 2 ms 4956 KB Output is correct
24 Correct 2 ms 5160 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 2 ms 4956 KB Output is correct
27 Correct 3 ms 4956 KB Output is correct
28 Correct 3 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 4952 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 3 ms 5048 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 3 ms 4956 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 3 ms 4952 KB Output is correct
12 Correct 3 ms 4952 KB Output is correct
13 Correct 2 ms 5212 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 2 ms 4956 KB Output is correct
16 Correct 3 ms 4956 KB Output is correct
17 Correct 3 ms 5036 KB Output is correct
18 Correct 3 ms 4952 KB Output is correct
19 Correct 3 ms 4952 KB Output is correct
20 Correct 4 ms 4956 KB Output is correct
21 Correct 4 ms 4980 KB Output is correct
22 Correct 3 ms 4956 KB Output is correct
23 Correct 2 ms 4956 KB Output is correct
24 Correct 2 ms 5160 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 2 ms 4956 KB Output is correct
27 Correct 3 ms 4956 KB Output is correct
28 Correct 3 ms 4956 KB Output is correct
29 Correct 101 ms 5248 KB Output is correct
30 Correct 84 ms 5208 KB Output is correct
31 Correct 81 ms 5280 KB Output is correct
32 Correct 64 ms 5208 KB Output is correct
33 Correct 37 ms 5208 KB Output is correct
34 Correct 84 ms 5208 KB Output is correct
35 Correct 97 ms 5208 KB Output is correct
36 Correct 21 ms 5292 KB Output is correct
37 Correct 71 ms 5212 KB Output is correct
38 Correct 49 ms 5288 KB Output is correct
39 Correct 81 ms 5212 KB Output is correct
40 Correct 60 ms 5288 KB Output is correct
41 Correct 58 ms 5208 KB Output is correct
42 Correct 59 ms 5212 KB Output is correct
43 Correct 28 ms 5296 KB Output is correct
44 Correct 46 ms 5284 KB Output is correct
45 Correct 65 ms 5208 KB Output is correct
46 Correct 66 ms 5172 KB Output is correct
47 Correct 47 ms 5276 KB Output is correct
48 Correct 62 ms 5208 KB Output is correct
49 Correct 65 ms 5280 KB Output is correct
50 Correct 77 ms 5212 KB Output is correct
51 Correct 48 ms 5208 KB Output is correct
52 Correct 63 ms 5296 KB Output is correct
53 Correct 79 ms 5212 KB Output is correct
54 Correct 92 ms 5212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Execution timed out 2047 ms 15808 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 4952 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 3 ms 5048 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 3 ms 4956 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 3 ms 4952 KB Output is correct
12 Correct 3 ms 4952 KB Output is correct
13 Correct 2 ms 5212 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 2 ms 4956 KB Output is correct
16 Correct 3 ms 4956 KB Output is correct
17 Correct 3 ms 5036 KB Output is correct
18 Correct 3 ms 4952 KB Output is correct
19 Correct 3 ms 4952 KB Output is correct
20 Correct 4 ms 4956 KB Output is correct
21 Correct 4 ms 4980 KB Output is correct
22 Correct 3 ms 4956 KB Output is correct
23 Correct 2 ms 4956 KB Output is correct
24 Correct 2 ms 5160 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 2 ms 4956 KB Output is correct
27 Correct 3 ms 4956 KB Output is correct
28 Correct 3 ms 4956 KB Output is correct
29 Execution timed out 2047 ms 15808 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 4952 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 3 ms 5048 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 3 ms 4956 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 3 ms 4952 KB Output is correct
12 Correct 3 ms 4952 KB Output is correct
13 Correct 2 ms 5212 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 2 ms 4956 KB Output is correct
16 Correct 3 ms 4956 KB Output is correct
17 Correct 3 ms 5036 KB Output is correct
18 Correct 3 ms 4952 KB Output is correct
19 Correct 3 ms 4952 KB Output is correct
20 Correct 4 ms 4956 KB Output is correct
21 Correct 4 ms 4980 KB Output is correct
22 Correct 3 ms 4956 KB Output is correct
23 Correct 2 ms 4956 KB Output is correct
24 Correct 2 ms 5160 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 2 ms 4956 KB Output is correct
27 Correct 3 ms 4956 KB Output is correct
28 Correct 3 ms 4956 KB Output is correct
29 Correct 101 ms 5248 KB Output is correct
30 Correct 84 ms 5208 KB Output is correct
31 Correct 81 ms 5280 KB Output is correct
32 Correct 64 ms 5208 KB Output is correct
33 Correct 37 ms 5208 KB Output is correct
34 Correct 84 ms 5208 KB Output is correct
35 Correct 97 ms 5208 KB Output is correct
36 Correct 21 ms 5292 KB Output is correct
37 Correct 71 ms 5212 KB Output is correct
38 Correct 49 ms 5288 KB Output is correct
39 Correct 81 ms 5212 KB Output is correct
40 Correct 60 ms 5288 KB Output is correct
41 Correct 58 ms 5208 KB Output is correct
42 Correct 59 ms 5212 KB Output is correct
43 Correct 28 ms 5296 KB Output is correct
44 Correct 46 ms 5284 KB Output is correct
45 Correct 65 ms 5208 KB Output is correct
46 Correct 66 ms 5172 KB Output is correct
47 Correct 47 ms 5276 KB Output is correct
48 Correct 62 ms 5208 KB Output is correct
49 Correct 65 ms 5280 KB Output is correct
50 Correct 77 ms 5212 KB Output is correct
51 Correct 48 ms 5208 KB Output is correct
52 Correct 63 ms 5296 KB Output is correct
53 Correct 79 ms 5212 KB Output is correct
54 Correct 92 ms 5212 KB Output is correct
55 Execution timed out 2036 ms 12600 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 4952 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 3 ms 5048 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 3 ms 4956 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 3 ms 4952 KB Output is correct
12 Correct 3 ms 4952 KB Output is correct
13 Correct 2 ms 5212 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 2 ms 4956 KB Output is correct
16 Correct 3 ms 4956 KB Output is correct
17 Correct 3 ms 5036 KB Output is correct
18 Correct 3 ms 4952 KB Output is correct
19 Correct 3 ms 4952 KB Output is correct
20 Correct 4 ms 4956 KB Output is correct
21 Correct 4 ms 4980 KB Output is correct
22 Correct 3 ms 4956 KB Output is correct
23 Correct 2 ms 4956 KB Output is correct
24 Correct 2 ms 5160 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 2 ms 4956 KB Output is correct
27 Correct 3 ms 4956 KB Output is correct
28 Correct 3 ms 4956 KB Output is correct
29 Correct 101 ms 5248 KB Output is correct
30 Correct 84 ms 5208 KB Output is correct
31 Correct 81 ms 5280 KB Output is correct
32 Correct 64 ms 5208 KB Output is correct
33 Correct 37 ms 5208 KB Output is correct
34 Correct 84 ms 5208 KB Output is correct
35 Correct 97 ms 5208 KB Output is correct
36 Correct 21 ms 5292 KB Output is correct
37 Correct 71 ms 5212 KB Output is correct
38 Correct 49 ms 5288 KB Output is correct
39 Correct 81 ms 5212 KB Output is correct
40 Correct 60 ms 5288 KB Output is correct
41 Correct 58 ms 5208 KB Output is correct
42 Correct 59 ms 5212 KB Output is correct
43 Correct 28 ms 5296 KB Output is correct
44 Correct 46 ms 5284 KB Output is correct
45 Correct 65 ms 5208 KB Output is correct
46 Correct 66 ms 5172 KB Output is correct
47 Correct 47 ms 5276 KB Output is correct
48 Correct 62 ms 5208 KB Output is correct
49 Correct 65 ms 5280 KB Output is correct
50 Correct 77 ms 5212 KB Output is correct
51 Correct 48 ms 5208 KB Output is correct
52 Correct 63 ms 5296 KB Output is correct
53 Correct 79 ms 5212 KB Output is correct
54 Correct 92 ms 5212 KB Output is correct
55 Execution timed out 2047 ms 15808 KB Time limit exceeded
56 Halted 0 ms 0 KB -