Submission #877230

# Submission time Handle Problem Language Result Execution time Memory
877230 2023-11-23T04:09:41 Z huutuan Joker (BOI20_joker) C++14
49 / 100
2000 ms 13324 KB
#include<bits/stdc++.h>
#define taskname "nohome"

using namespace std;

struct DSU{
   vector<int> lab, val;
   bool ans=1;
   void init(int n){
      lab.assign(n+1, -1);
      val.assign(n+1, 0);
   }
   pair<int, int> find_set(int u){
      if (lab[u]<0) return {u, 0};
      auto p=find_set(lab[u]);
      lab[u]=p.first;
      val[u]^=p.second;
      return {lab[u], val[u]};
   }
   void union_sets(int u, int v){
      auto pu=find_set(u), pv=find_set(v);
      if (pu.first!=pv.first){
         if (lab[pu.first]>lab[pv.first]) swap(pu, pv), swap(u, v);
         lab[pu.first]+=lab[pv.first];
         val[pu.first]=0;
         lab[pv.first]=pu.first;
         val[pv.first]=pu.second^pv.second^1;
      }else
         ans&=pu.second^pv.second;
   }
};

const int N=2e5+1;
int n, m, q, ans[N];
pair<int, int> edge[N];
vector<pair<int, int>> qq[N];

int32_t main(){
   ios_base::sync_with_stdio(false);
   cin.tie(nullptr);
   // freopen(taskname".inp", "r", stdin);
   // freopen(taskname".out", "w", stdout);
   cin >> n >> m >> q;
   for (int i=1; i<=m; ++i){
      int x, y; cin >> x >> y;
      edge[i]={x, y};
   }
   for (int i=1; i<=q; ++i){
      int l, r; cin >> l >> r;
      qq[l].emplace_back(r, i);
   }
   DSU dsu;
   dsu.init(n);
   for (int i=1; i<=m; ++i){
      if (qq[i].size()){
         DSU dsu2=dsu;
         sort(qq[i].rbegin(), qq[i].rend());
         int cur=m;
         for (auto &j:qq[i]){
            while (cur>j.first){
               dsu2.union_sets(edge[cur].first, edge[cur].second);
               --cur;
            }
            ans[j.second]=!dsu2.ans;
         }
      }
      dsu.union_sets(edge[i].first, edge[i].second);
   }
   for (int i=1; i<=q; ++i) cout << (ans[i]?"YES\n":"NO\n");
   return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 2 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 2 ms 6552 KB Output is correct
9 Correct 2 ms 6748 KB Output is correct
10 Correct 2 ms 6748 KB Output is correct
11 Correct 1 ms 6748 KB Output is correct
12 Correct 2 ms 6748 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 1 ms 6748 KB Output is correct
15 Correct 2 ms 6748 KB Output is correct
16 Correct 1 ms 6748 KB Output is correct
17 Correct 2 ms 6748 KB Output is correct
18 Correct 1 ms 6748 KB Output is correct
19 Correct 1 ms 6748 KB Output is correct
20 Correct 1 ms 6748 KB Output is correct
21 Correct 2 ms 6760 KB Output is correct
22 Correct 2 ms 6748 KB Output is correct
23 Correct 1 ms 6748 KB Output is correct
24 Correct 1 ms 6748 KB Output is correct
25 Correct 1 ms 6748 KB Output is correct
26 Correct 1 ms 6748 KB Output is correct
27 Correct 1 ms 6748 KB Output is correct
28 Correct 1 ms 6748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 2 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 2 ms 6552 KB Output is correct
9 Correct 2 ms 6748 KB Output is correct
10 Correct 2 ms 6748 KB Output is correct
11 Correct 1 ms 6748 KB Output is correct
12 Correct 2 ms 6748 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 1 ms 6748 KB Output is correct
15 Correct 2 ms 6748 KB Output is correct
16 Correct 1 ms 6748 KB Output is correct
17 Correct 2 ms 6748 KB Output is correct
18 Correct 1 ms 6748 KB Output is correct
19 Correct 1 ms 6748 KB Output is correct
20 Correct 1 ms 6748 KB Output is correct
21 Correct 2 ms 6760 KB Output is correct
22 Correct 2 ms 6748 KB Output is correct
23 Correct 1 ms 6748 KB Output is correct
24 Correct 1 ms 6748 KB Output is correct
25 Correct 1 ms 6748 KB Output is correct
26 Correct 1 ms 6748 KB Output is correct
27 Correct 1 ms 6748 KB Output is correct
28 Correct 1 ms 6748 KB Output is correct
29 Correct 6 ms 6748 KB Output is correct
30 Correct 5 ms 6864 KB Output is correct
31 Correct 5 ms 6748 KB Output is correct
32 Correct 4 ms 6748 KB Output is correct
33 Correct 4 ms 6792 KB Output is correct
34 Correct 5 ms 6748 KB Output is correct
35 Correct 5 ms 6748 KB Output is correct
36 Correct 4 ms 6748 KB Output is correct
37 Correct 7 ms 6748 KB Output is correct
38 Correct 7 ms 6744 KB Output is correct
39 Correct 3 ms 6744 KB Output is correct
40 Correct 4 ms 6748 KB Output is correct
41 Correct 4 ms 6748 KB Output is correct
42 Correct 4 ms 6744 KB Output is correct
43 Correct 8 ms 6744 KB Output is correct
44 Correct 8 ms 6748 KB Output is correct
45 Correct 9 ms 6760 KB Output is correct
46 Correct 9 ms 6744 KB Output is correct
47 Correct 4 ms 6748 KB Output is correct
48 Correct 4 ms 6748 KB Output is correct
49 Correct 5 ms 6744 KB Output is correct
50 Correct 6 ms 6748 KB Output is correct
51 Correct 4 ms 6748 KB Output is correct
52 Correct 4 ms 6748 KB Output is correct
53 Correct 5 ms 6748 KB Output is correct
54 Correct 5 ms 6748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 2 ms 6748 KB Output is correct
3 Correct 63 ms 11208 KB Output is correct
4 Correct 72 ms 12744 KB Output is correct
5 Correct 75 ms 12464 KB Output is correct
6 Correct 75 ms 11208 KB Output is correct
7 Correct 79 ms 11204 KB Output is correct
8 Correct 74 ms 10768 KB Output is correct
9 Correct 70 ms 11256 KB Output is correct
10 Correct 80 ms 12964 KB Output is correct
11 Correct 79 ms 11208 KB Output is correct
12 Correct 76 ms 12484 KB Output is correct
13 Correct 69 ms 9920 KB Output is correct
14 Correct 72 ms 10568 KB Output is correct
15 Correct 76 ms 11668 KB Output is correct
16 Correct 78 ms 12744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 2 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 2 ms 6552 KB Output is correct
9 Correct 2 ms 6748 KB Output is correct
10 Correct 2 ms 6748 KB Output is correct
11 Correct 1 ms 6748 KB Output is correct
12 Correct 2 ms 6748 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 1 ms 6748 KB Output is correct
15 Correct 2 ms 6748 KB Output is correct
16 Correct 1 ms 6748 KB Output is correct
17 Correct 2 ms 6748 KB Output is correct
18 Correct 1 ms 6748 KB Output is correct
19 Correct 1 ms 6748 KB Output is correct
20 Correct 1 ms 6748 KB Output is correct
21 Correct 2 ms 6760 KB Output is correct
22 Correct 2 ms 6748 KB Output is correct
23 Correct 1 ms 6748 KB Output is correct
24 Correct 1 ms 6748 KB Output is correct
25 Correct 1 ms 6748 KB Output is correct
26 Correct 1 ms 6748 KB Output is correct
27 Correct 1 ms 6748 KB Output is correct
28 Correct 1 ms 6748 KB Output is correct
29 Correct 63 ms 11208 KB Output is correct
30 Correct 72 ms 12744 KB Output is correct
31 Correct 75 ms 12464 KB Output is correct
32 Correct 75 ms 11208 KB Output is correct
33 Correct 79 ms 11204 KB Output is correct
34 Correct 74 ms 10768 KB Output is correct
35 Correct 70 ms 11256 KB Output is correct
36 Correct 80 ms 12964 KB Output is correct
37 Correct 79 ms 11208 KB Output is correct
38 Correct 76 ms 12484 KB Output is correct
39 Correct 69 ms 9920 KB Output is correct
40 Correct 72 ms 10568 KB Output is correct
41 Correct 76 ms 11668 KB Output is correct
42 Correct 78 ms 12744 KB Output is correct
43 Correct 511 ms 11244 KB Output is correct
44 Correct 799 ms 13084 KB Output is correct
45 Correct 789 ms 12856 KB Output is correct
46 Correct 810 ms 11228 KB Output is correct
47 Correct 861 ms 11820 KB Output is correct
48 Correct 780 ms 11536 KB Output is correct
49 Correct 1045 ms 13324 KB Output is correct
50 Correct 737 ms 11240 KB Output is correct
51 Correct 800 ms 12024 KB Output is correct
52 Correct 837 ms 13044 KB Output is correct
53 Correct 340 ms 10632 KB Output is correct
54 Correct 739 ms 11000 KB Output is correct
55 Correct 939 ms 11980 KB Output is correct
56 Correct 1054 ms 13196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 2 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 2 ms 6552 KB Output is correct
9 Correct 2 ms 6748 KB Output is correct
10 Correct 2 ms 6748 KB Output is correct
11 Correct 1 ms 6748 KB Output is correct
12 Correct 2 ms 6748 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 1 ms 6748 KB Output is correct
15 Correct 2 ms 6748 KB Output is correct
16 Correct 1 ms 6748 KB Output is correct
17 Correct 2 ms 6748 KB Output is correct
18 Correct 1 ms 6748 KB Output is correct
19 Correct 1 ms 6748 KB Output is correct
20 Correct 1 ms 6748 KB Output is correct
21 Correct 2 ms 6760 KB Output is correct
22 Correct 2 ms 6748 KB Output is correct
23 Correct 1 ms 6748 KB Output is correct
24 Correct 1 ms 6748 KB Output is correct
25 Correct 1 ms 6748 KB Output is correct
26 Correct 1 ms 6748 KB Output is correct
27 Correct 1 ms 6748 KB Output is correct
28 Correct 1 ms 6748 KB Output is correct
29 Correct 6 ms 6748 KB Output is correct
30 Correct 5 ms 6864 KB Output is correct
31 Correct 5 ms 6748 KB Output is correct
32 Correct 4 ms 6748 KB Output is correct
33 Correct 4 ms 6792 KB Output is correct
34 Correct 5 ms 6748 KB Output is correct
35 Correct 5 ms 6748 KB Output is correct
36 Correct 4 ms 6748 KB Output is correct
37 Correct 7 ms 6748 KB Output is correct
38 Correct 7 ms 6744 KB Output is correct
39 Correct 3 ms 6744 KB Output is correct
40 Correct 4 ms 6748 KB Output is correct
41 Correct 4 ms 6748 KB Output is correct
42 Correct 4 ms 6744 KB Output is correct
43 Correct 8 ms 6744 KB Output is correct
44 Correct 8 ms 6748 KB Output is correct
45 Correct 9 ms 6760 KB Output is correct
46 Correct 9 ms 6744 KB Output is correct
47 Correct 4 ms 6748 KB Output is correct
48 Correct 4 ms 6748 KB Output is correct
49 Correct 5 ms 6744 KB Output is correct
50 Correct 6 ms 6748 KB Output is correct
51 Correct 4 ms 6748 KB Output is correct
52 Correct 4 ms 6748 KB Output is correct
53 Correct 5 ms 6748 KB Output is correct
54 Correct 5 ms 6748 KB Output is correct
55 Correct 1097 ms 9136 KB Output is correct
56 Execution timed out 2043 ms 12896 KB Time limit exceeded
57 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 2 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 2 ms 6552 KB Output is correct
9 Correct 2 ms 6748 KB Output is correct
10 Correct 2 ms 6748 KB Output is correct
11 Correct 1 ms 6748 KB Output is correct
12 Correct 2 ms 6748 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 1 ms 6748 KB Output is correct
15 Correct 2 ms 6748 KB Output is correct
16 Correct 1 ms 6748 KB Output is correct
17 Correct 2 ms 6748 KB Output is correct
18 Correct 1 ms 6748 KB Output is correct
19 Correct 1 ms 6748 KB Output is correct
20 Correct 1 ms 6748 KB Output is correct
21 Correct 2 ms 6760 KB Output is correct
22 Correct 2 ms 6748 KB Output is correct
23 Correct 1 ms 6748 KB Output is correct
24 Correct 1 ms 6748 KB Output is correct
25 Correct 1 ms 6748 KB Output is correct
26 Correct 1 ms 6748 KB Output is correct
27 Correct 1 ms 6748 KB Output is correct
28 Correct 1 ms 6748 KB Output is correct
29 Correct 6 ms 6748 KB Output is correct
30 Correct 5 ms 6864 KB Output is correct
31 Correct 5 ms 6748 KB Output is correct
32 Correct 4 ms 6748 KB Output is correct
33 Correct 4 ms 6792 KB Output is correct
34 Correct 5 ms 6748 KB Output is correct
35 Correct 5 ms 6748 KB Output is correct
36 Correct 4 ms 6748 KB Output is correct
37 Correct 7 ms 6748 KB Output is correct
38 Correct 7 ms 6744 KB Output is correct
39 Correct 3 ms 6744 KB Output is correct
40 Correct 4 ms 6748 KB Output is correct
41 Correct 4 ms 6748 KB Output is correct
42 Correct 4 ms 6744 KB Output is correct
43 Correct 8 ms 6744 KB Output is correct
44 Correct 8 ms 6748 KB Output is correct
45 Correct 9 ms 6760 KB Output is correct
46 Correct 9 ms 6744 KB Output is correct
47 Correct 4 ms 6748 KB Output is correct
48 Correct 4 ms 6748 KB Output is correct
49 Correct 5 ms 6744 KB Output is correct
50 Correct 6 ms 6748 KB Output is correct
51 Correct 4 ms 6748 KB Output is correct
52 Correct 4 ms 6748 KB Output is correct
53 Correct 5 ms 6748 KB Output is correct
54 Correct 5 ms 6748 KB Output is correct
55 Correct 63 ms 11208 KB Output is correct
56 Correct 72 ms 12744 KB Output is correct
57 Correct 75 ms 12464 KB Output is correct
58 Correct 75 ms 11208 KB Output is correct
59 Correct 79 ms 11204 KB Output is correct
60 Correct 74 ms 10768 KB Output is correct
61 Correct 70 ms 11256 KB Output is correct
62 Correct 80 ms 12964 KB Output is correct
63 Correct 79 ms 11208 KB Output is correct
64 Correct 76 ms 12484 KB Output is correct
65 Correct 69 ms 9920 KB Output is correct
66 Correct 72 ms 10568 KB Output is correct
67 Correct 76 ms 11668 KB Output is correct
68 Correct 78 ms 12744 KB Output is correct
69 Correct 511 ms 11244 KB Output is correct
70 Correct 799 ms 13084 KB Output is correct
71 Correct 789 ms 12856 KB Output is correct
72 Correct 810 ms 11228 KB Output is correct
73 Correct 861 ms 11820 KB Output is correct
74 Correct 780 ms 11536 KB Output is correct
75 Correct 1045 ms 13324 KB Output is correct
76 Correct 737 ms 11240 KB Output is correct
77 Correct 800 ms 12024 KB Output is correct
78 Correct 837 ms 13044 KB Output is correct
79 Correct 340 ms 10632 KB Output is correct
80 Correct 739 ms 11000 KB Output is correct
81 Correct 939 ms 11980 KB Output is correct
82 Correct 1054 ms 13196 KB Output is correct
83 Correct 1097 ms 9136 KB Output is correct
84 Execution timed out 2043 ms 12896 KB Time limit exceeded
85 Halted 0 ms 0 KB -