QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#110198#6526. CanvasFu_suAC ✓343ms63576kbC++175.5kb2023-06-01 03:12:022023-06-01 03:12:03

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-01 03:12:03]
  • 评测
  • 测评结果:AC
  • 用时:343ms
  • 内存:63576kb
  • [2023-06-01 03:12:02]
  • 提交

answer

#include "assert.h"
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>

const int maxn = 500005;

int T;

struct OP {
  int l, x, r, y;
};

typedef long long int ll;
std::vector<std::pair<int, int>> e1[maxn];
bool ctrl[maxn];
int dfn[maxn], low[maxn], stk[maxn], ins[maxn], top, vistime, scnt, sz[maxn], bel[maxn], ind[maxn], c[maxn], inv[maxn], frstv[maxn], inid[maxn];

void clear() {
  for (auto &x : e1) x.clear();
#define clr(x) memset(x, 0, sizeof(x))
  clr(ctrl);
  clr(dfn);
  clr(low);
  clr(stk);
  clr(ins);
  clr(sz);
  clr(bel);
  clr(ind);
  clr(c);
  clr(inv);
  clr(frstv);
  clr(inid);
  top = vistime = scnt = 0;
}

void dfs(const int u) {
  low[u] = dfn[u] = ++vistime;
  ins[stk[++top] = u] = true;
  for (auto [v,id] : e1[u]) if (!ctrl[v] && dfn[v] == 0) {
    dfs(v);
    low[u] = std::min(low[u], low[v]);
  } else if (!ctrl[v] && ins[v]) {
    low[u] = std::min(low[u], low[v]);
  }
  if (low[u] == dfn[u]) {
    ++scnt; int v;
    do {
      ins[v = stk[top--]] = false;
      ++sz[bel[v] = scnt];
      frstv[scnt] = v;
    } while (u != v);
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  for (std::cin >> T; T; --T) {
    int n, m;
    std::cin >> n >> m;
   // assert(std::max(n, m) <= 100);
   // clear();
    std::vector<OP> op(m);
    std::vector<int> ans1, ans2, ans3, ans4;
    std::vector<int> prt(m + 1), vis(n + 1);
    for (int i = 0; i <= std::max(n, m); ++i) {
      e1[i].clear();
      ctrl[i] = false;
      dfn[i] = low[i] = stk[i] = ins[i] = bel[i] = sz[i] = ind[i] = c[i] = inv[i] = frstv[i] = inid[i] = 0;
    }
    top = vistime = scnt = 0;
    // e1 : 1->2, e2 : 2->1
    for (int i = 0; i < m; ++i) {
      OP &u = op[i];
      std::cin >> u.l >> u.x >> u.r >> u.y;
      if (u.x > u.y) {
        std::swap(u.x, u.y);
        std::swap(u.l, u.r);
      }
    }
    std::queue<int> Q;
    for (int u = 0; u < m; ++u) {
      OP i = op[u];
      int l = i.l, r = i.r;
      if (i.y == 2) {
        if (i.x == 1) {
          e1[l].push_back({r, u +1});
         // e2[r].push_back(l);
        } else {
          if (!ctrl[l]) {
            ctrl[l] = 1;
            Q.push(l);
          }
          if (!ctrl[r]) {
            ctrl[r] = 1;
            Q.push(r);
          }
          ans3.push_back(1 + u);
        }
      }
    }
    for (int u; !Q.empty(); Q.pop()) {
      u = Q.front();
      for (auto [v, id] : e1[u]) if (!ctrl[v]) {
        ans1.push_back(id);
        ctrl[v] = 1;
        Q.push(v);
      }
    }
    std::reverse(ans1.begin(), ans1.end());
    for (int i = 1; i <= n; ++i) if (!ctrl[i] && dfn[i] == 0) {
      dfs(i);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) if (!ctrl[i]) {
      for (auto [v,id] : e1[i]) if (!ctrl[v] && bel[i] != bel[v]) {
        ++ind[bel[v]]; inv[bel[v]] = v; inid[bel[v]] = id;
      }
    }
    for (int i = 1; i <= n; ++i) if (!ctrl[i]) {
      for (auto [v, id] : e1[i]) if (!ctrl[v]) {
        if (c[i] < 1) {
          ++ans;
          c[i] = 1;
        }
        if (c[v] < 2) {
          ans += 2 - c[v];
          c[v] = 2;
        }
      }
    }
    for (int i = 1; i <= scnt; ++i) if (!ind[i] && sz[i] > 1) {
      --ans;
    }
    for (int i = 1; i <= n; ++i) if (ctrl[i]) {
      c[i] = 2;
      ans += 2;
    }
    for (auto i : op) if ((i.y == 1) || (i.x == 1 && ctrl[i.r])) {
      if (c[i.l] == 0) {
        c[i.l] = 1;
        ++ans;
      }
      if (c[i.r] == 0) {
        c[i.r] = 1;
        ++ans;
      }
    }
    std::cout << ans << '\n';
  /*  for (int i = 0; i < m; ++i) {
      OP u = op[i];
      if (u.y == 1) {
       // ans1.push_back(i + 1);
       // prt[i + 1] = true;
      }
    }*/
    for (int i = 1; i <= scnt; ++i) if (inv[i]) {
    //  std::cerr << i << '\n';
      std::vector<int> tmp;
      vis[inv[i]] = 1;
      for (Q.push(inv[i]); !Q.empty(); Q.pop()) {
        
        for (auto [v, id] : e1[Q.front()]) if (bel[v] == i && vis[v] == 0) {
          tmp.push_back(id);
          Q.push(v);
          vis[v] = 1;
        }
      }
      std::reverse(tmp.begin(), tmp.end());
      for (auto u : tmp) ans2.push_back(u);
      ans2.push_back(inid[i]);
    } else if (sz[i] != 1) {
   //   std::cerr << frstv[i] << '\n';
     // std::cerr << ans2.size() << '\n';
      std::vector<int> tmp;
      vis[frstv[i]] = 1;
      for (Q.push(frstv[i]); !Q.empty(); Q.pop()) {
        for (auto [v, id] : e1[Q.front()]) if (bel[v] == i && vis[v] == 0) {
       //   std::cerr << Q.front() << ' ' << v << ' ' << id << '\n';
          tmp.push_back(id);
          Q.push(v);
          vis[v] = 1;
        } else {
       //   std::cerr << Q.front() << ' ' << v << '\n';
        }
      }
      std::reverse(tmp.begin(), tmp.end());
      for (auto u : tmp) ans2.push_back(u);
    }
    for (auto i : ans2) prt[i] = true;
    for (auto i : ans1) prt[i] = true;
    for (auto i : ans3) prt[i] = true;
    for (int i = 1; i <= m; ++i) if (prt[i] == false) {
      std::cout << i << ' ';
    }
   // return 0;
    for (auto i : ans2) std::cout << i << ' ';
    for (auto i : ans1) std::cout << i << ' ';
    for (auto i : ans3) std::cout << i << ' ';
    std::cout << '\n';
  }
}
/**********************************************************************
	Problem: 1011
	User: team010
	Language: C++
	Result: RE
**********************************************************************/

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 25692kb

input:

2
4 4
1 1 2 2
3 2 4 1
1 2 3 2
2 1 4 1
4 2
3 2 4 1
1 2 3 1

output:

7
2 4 1 3 
5
2 1 

result:

ok Correct. (2 test cases)

Test #2:

score: 0
Accepted
time: 3ms
memory: 17200kb

input:

1
10 13
1 1 2 2
2 1 3 2
1 2 3 1
3 1 4 2
4 1 5 2
5 1 6 2
4 2 6 1
7 1 8 2
8 1 9 2
7 2 9 1
5 2 9 1
8 2 10 2
1 1 10 1

output:

19
3 4 5 8 13 2 1 7 6 11 10 9 12 

result:

ok Correct. (1 test case)

Test #3:

score: 0
Accepted
time: 4ms
memory: 20424kb

input:

1
7 5
2 1 6 2
1 2 6 1
1 1 5 1
2 2 7 1
1 1 7 2

output:

8
2 3 1 4 5 

result:

ok Correct. (1 test case)

Test #4:

score: 0
Accepted
time: 2ms
memory: 29700kb

input:

1
7 6
2 1 7 2
2 1 4 2
1 2 4 1
2 1 6 1
1 1 6 2
2 2 6 1

output:

9
3 4 1 2 6 5 

result:

ok Correct. (1 test case)

Test #5:

score: 0
Accepted
time: 1ms
memory: 27536kb

input:

1
7 5
5 2 7 1
5 1 6 2
3 2 7 1
3 2 6 1
6 1 7 2

output:

7
1 4 3 5 2 

result:

ok Correct. (1 test case)

Test #6:

score: 0
Accepted
time: 4ms
memory: 22772kb

input:

1
7 6
1 2 5 1
2 1 7 2
1 2 7 1
2 2 7 1
1 1 5 2
1 2 3 1

output:

8
1 4 6 5 3 2 

result:

ok Correct. (1 test case)

Test #7:

score: 0
Accepted
time: 14ms
memory: 24636kb

input:

2000
15 16
2 2 3 1
12 2 15 1
3 2 9 1
6 2 14 1
2 1 15 2
5 2 6 1
7 1 10 1
9 2 15 1
2 2 3 1
4 2 12 1
2 2 9 1
5 2 8 2
3 2 13 1
12 1 13 2
9 2 13 1
5 1 14 2
15 15
5 2 11 1
1 2 8 1
8 1 15 2
6 2 8 2
8 2 9 1
1 1 6 2
6 1 9 2
2 2 5 1
2 1 10 2
7 2 10 1
1 1 15 2
5 2 15 1
7 1 11 2
1 1 2 1
5 2 9 1
15 14
3 1 5 2
1 ...

output:

23
1 6 7 9 11 13 15 10 3 14 8 2 5 4 16 12 
20
1 5 6 11 12 14 13 10 9 8 15 3 2 7 4 
21
2 6 8 11 14 10 13 3 9 12 4 7 1 5 
18
3 4 7 9 11 13 14 1 5 8 12 6 10 2 
21
1 2 3 5 6 7 11 12 16 18 14 10 13 19 9 17 8 4 15 
21
2 3 9 11 13 6 14 8 5 7 4 12 10 1 
21
2 3 7 8 11 15 1 5 14 9 6 13 4 12 10 
19
2 3 7 9 11 ...

result:

ok Correct. (2000 test cases)

Test #8:

score: 0
Accepted
time: 16ms
memory: 23992kb

input:

2000
15 18
10 1 15 2
10 1 15 2
3 2 13 1
5 1 6 2
2 1 10 2
3 2 5 2
7 1 12 2
2 2 3 1
12 1 13 2
5 2 11 1
7 1 15 2
5 1 15 2
6 1 11 2
2 1 6 1
5 1 10 2
5 2 10 1
2 1 7 2
2 1 15 2
15 17
7 2 15 1
6 2 10 1
3 2 12 1
13 2 14 1
1 1 7 2
6 2 15 1
6 2 13 2
1 2 6 1
10 2 15 1
12 2 15 1
9 1 10 2
13 1 15 2
9 2 12 1
3 1 ...

output:

20
1 2 3 5 10 11 14 16 18 9 7 13 17 15 12 4 8 6 
21
1 2 4 6 11 13 16 17 14 3 10 9 15 5 12 8 7 
21
1 2 6 8 9 10 11 13 15 16 3 5 4 17 12 18 7 14 
19
1 4 5 8 9 11 12 13 14 18 3 2 15 6 10 16 7 17 
19
1 3 4 9 11 14 15 16 7 12 10 8 5 13 2 6 
21
3 4 9 10 11 6 12 1 7 8 13 5 2 
20
2 6 8 9 13 4 1 11 7 10 12 3...

result:

ok Correct. (2000 test cases)

Test #9:

score: 0
Accepted
time: 6ms
memory: 23764kb

input:

5
27 33
18 2 23 1
13 1 23 2
2 1 7 2
4 2 7 1
2 1 4 2
9 1 27 2
26 2 27 1
3 2 11 1
2 1 4 2
12 1 18 2
4 2 7 1
25 2 26 1
12 1 17 2
5 1 27 2
5 2 22 1
13 2 25 1
2 1 4 2
4 2 7 1
2 2 26 1
4 2 7 1
2 2 7 1
2 2 17 1
19 1 26 1
3 2 24 1
11 1 24 2
3 2 24 1
3 1 9 2
18 1 22 2
9 1 11 2
5 2 23 2
12 2 17 1
2 2 7 1
4 2 ...

output:

33
2 4 5 6 8 9 10 11 15 17 18 20 21 22 23 24 26 31 32 25 29 27 13 3 16 19 12 28 7 33 1 14 30 
37
3 5 7 8 9 10 14 19 20 21 22 25 6 4 17 13 2 16 24 27 26 28 1 11 18 15 23 12 
38
2 3 5 7 12 15 16 20 21 22 24 25 26 27 28 30 31 32 33 34 23 6 14 11 29 35 10 4 9 13 19 18 8 1 36 17 
34
2 4 5 7 9 10 12 13 14...

result:

ok Correct. (5 test cases)

Test #10:

score: 0
Accepted
time: 5ms
memory: 25996kb

input:

5
27 37
10 2 25 2
18 2 22 1
18 1 22 2
2 1 24 2
14 2 26 1
4 1 27 2
15 2 25 1
24 1 27 2
7 2 20 1
11 1 18 1
2 1 14 2
15 1 25 2
10 2 15 1
9 1 16 2
24 2 27 1
24 1 27 2
10 2 12 1
10 1 15 2
9 2 14 1
6 1 15 2
7 1 27 2
24 1 27 2
6 1 22 2
16 1 20 2
15 1 24 2
4 1 27 2
24 1 27 2
2 1 4 2
24 2 27 1
7 1 26 2
24 1 ...

output:

35
3 4 5 6 7 8 10 12 13 15 16 17 20 21 22 23 26 27 29 31 32 35 36 2 33 30 9 24 14 19 11 28 37 34 25 18 1 
37
6 7 8 10 11 16 17 20 22 23 26 27 28 29 30 31 32 19 18 3 21 4 25 34 14 33 15 13 12 9 2 24 5 1 
35
1 2 11 12 13 14 17 18 19 21 22 23 25 26 27 29 33 34 10 5 15 32 7 16 31 20 6 24 4 8 9 30 3 28 
...

result:

ok Correct. (5 test cases)

Test #11:

score: 0
Accepted
time: 124ms
memory: 30980kb

input:

200
739 1933
110 1 669 2
17 2 403 1
39 1 538 2
36 2 267 1
66 2 259 1
55 2 483 1
245 2 450 1
30 1 729 2
318 1 568 2
344 1 681 2
11 2 37 1
15 2 192 1
55 2 344 1
426 2 596 1
3 2 683 1
499 1 614 1
302 1 367 2
220 1 528 1
223 2 563 1
255 2 719 1
153 2 688 1
371 2 648 1
704 2 715 1
367 2 477 1
451 2 698 2...

output:

1031
1 3 5 6 9 10 11 12 13 14 16 17 18 19 20 21 22 23 24 28 29 30 31 33 34 35 38 39 41 42 45 47 48 49 50 52 54 56 57 58 59 60 61 62 63 64 65 67 68 69 71 72 75 76 78 80 81 84 86 89 90 91 92 93 94 95 96 97 98 99 100 101 103 104 105 106 109 110 111 114 115 117 118 119 120 121 122 124 125 128 130 131 13...

result:

ok Correct. (200 test cases)

Test #12:

score: 0
Accepted
time: 126ms
memory: 34752kb

input:

200
748 1673
173 2 219 1
77 1 143 2
19 2 384 1
277 2 371 1
272 2 424 1
203 2 737 1
90 1 129 2
302 1 717 2
527 2 700 1
124 2 673 1
129 2 708 1
546 2 650 1
151 2 689 1
475 2 603 1
173 1 574 2
277 1 605 2
129 2 499 1
373 2 546 1
52 2 66 1
238 1 618 2
373 2 473 1
154 2 244 1
278 1 618 2
112 1 129 2
361 ...

output:

1066
1 2 3 4 6 7 8 9 10 11 12 13 14 16 17 18 19 20 23 24 25 26 27 28 29 30 32 33 34 35 39 40 42 43 44 45 46 47 48 49 50 51 53 54 56 57 58 62 63 65 66 67 70 71 76 78 79 80 81 82 84 85 86 87 89 91 93 94 96 97 99 100 101 102 103 104 105 106 107 111 112 115 117 119 122 123 124 125 126 127 128 129 130 13...

result:

ok Correct. (200 test cases)

Test #13:

score: 0
Accepted
time: 120ms
memory: 16208kb

input:

200
736 1822
500 2 641 1
91 1 700 2
525 2 576 1
101 2 364 1
304 1 689 2
12 2 636 1
338 2 358 1
15 2 296 1
12 2 123 1
608 1 666 2
135 2 473 1
361 1 667 2
137 2 348 1
381 1 502 2
107 1 277 2
23 1 137 2
262 1 602 2
493 1 573 2
158 2 306 1
137 1 587 2
238 2 682 1
580 2 601 1
364 2 620 1
97 2 403 1
27 1 ...

output:

999
1 3 4 9 13 15 16 17 18 19 20 22 23 24 26 28 29 30 31 33 34 36 38 39 40 41 42 44 46 47 48 50 51 53 54 57 58 59 60 62 63 64 65 66 67 68 69 71 72 73 74 75 76 77 78 79 80 81 82 83 85 86 88 89 96 98 100 101 102 104 105 108 109 110 111 112 113 114 115 116 118 119 121 122 124 125 127 128 129 130 132 13...

result:

ok Correct. (200 test cases)

Test #14:

score: 0
Accepted
time: 106ms
memory: 29688kb

input:

200
745 1668
10 1 215 2
136 2 337 1
528 1 727 2
287 1 314 2
93 1 692 2
37 2 497 1
577 2 597 1
100 1 306 2
313 1 743 2
421 1 597 2
313 1 342 2
236 2 305 1
198 1 617 2
52 1 156 2
144 2 368 1
170 1 428 2
209 1 241 2
125 1 306 2
381 2 715 1
37 1 156 2
395 2 581 1
186 2 580 1
81 1 216 2
120 1 306 2
251 2...

output:

1012
1 2 3 6 8 9 11 12 15 16 17 18 20 21 22 24 26 27 28 30 32 34 36 37 38 43 44 45 46 47 49 51 52 53 55 56 58 61 62 63 65 66 69 70 71 73 74 75 78 80 81 82 85 86 89 92 94 96 98 100 102 103 107 108 109 110 111 112 113 114 115 117 118 119 120 121 122 123 124 125 126 127 128 131 132 133 135 138 139 141 ...

result:

ok Correct. (200 test cases)

Test #15:

score: 0
Accepted
time: 173ms
memory: 31456kb

input:

4
74995 97040
23497 1 31972 2
8788 2 69397 1
51522 2 62220 1
9584 1 11674 2
13370 2 36146 1
39507 1 74477 2
1427 1 33348 2
11493 2 13101 1
32701 2 40560 1
28485 1 47620 2
17874 2 62375 1
20454 2 66633 1
13755 2 61191 1
12861 2 63188 1
52357 1 67165 2
12934 1 59450 2
14794 1 17744 2
61153 1 69340 2
8...

output:

99836
4 5 7 8 9 10 11 15 16 17 19 20 21 22 24 25 28 30 40 41 42 49 51 54 56 57 58 60 62 67 68 71 72 73 75 76 77 78 79 85 86 87 88 91 92 95 98 99 101 104 105 106 107 108 110 111 116 117 118 120 121 122 123 125 127 129 130 132 134 135 137 140 142 144 145 150 155 156 157 158 159 162 164 166 168 169 170...

result:

ok Correct. (4 test cases)

Test #16:

score: 0
Accepted
time: 181ms
memory: 40680kb

input:

4
74988 97757
6254 1 14126 2
2960 2 7884 1
264 1 26963 2
16894 1 73361 2
40794 2 62973 1
15845 1 45281 2
26578 1 61068 2
14464 2 40449 1
60333 1 73068 2
15459 2 72767 1
44940 2 46205 1
56974 1 65823 2
673 1 12086 2
31184 2 60179 1
924 1 72427 2
22116 2 30494 1
39764 1 50149 2
8984 2 34549 1
47283 1 ...

output:

99896
3 8 10 13 14 15 18 20 21 23 25 26 28 36 38 40 42 47 50 52 53 54 55 56 58 59 62 63 66 68 69 71 72 73 76 78 79 80 81 82 83 84 85 87 90 95 97 101 102 106 107 108 111 112 113 114 115 117 118 121 122 123 126 127 129 131 135 136 137 139 140 144 148 150 152 155 157 158 160 162 168 169 174 175 176 177...

result:

ok Correct. (4 test cases)

Test #17:

score: 0
Accepted
time: 181ms
memory: 46320kb

input:

2
150000 197734
56160 1 148935 2
14203 2 142849 1
141811 2 149919 1
12846 1 140822 2
32811 2 104214 1
37237 2 73067 1
39554 1 58164 2
17623 1 30566 2
45475 1 88051 2
2948 1 36363 2
121185 1 130780 2
43705 2 139248 1
105491 2 114240 1
22905 2 102102 1
52418 2 85590 1
85614 1 142446 2
145002 2 148378 ...

output:

200477
3 8 11 12 14 15 16 18 19 20 21 22 23 24 26 27 28 30 31 33 34 36 37 38 39 40 44 48 50 53 57 58 59 60 64 66 67 68 69 70 71 73 75 76 79 81 83 84 87 96 97 104 105 106 107 110 113 114 117 119 120 121 125 126 127 128 129 132 133 135 138 139 142 144 145 148 150 153 154 156 160 161 163 166 167 170 17...

result:

ok Correct. (2 test cases)

Test #18:

score: 0
Accepted
time: 187ms
memory: 42420kb

input:

2
149994 189488
105606 1 132955 2
36574 1 86107 2
101018 2 113530 1
122540 2 143227 1
16632 2 89793 1
25443 1 149904 2
99976 2 136760 1
10596 2 112318 1
84455 1 132258 2
85919 2 93042 1
42680 2 68046 1
60230 2 112109 1
30417 1 79467 2
72216 1 109099 2
24431 2 26346 1
31235 1 109427 2
100973 2 114543...

output:

198916
1 2 3 6 8 9 11 12 15 16 23 31 34 36 37 38 42 43 46 48 50 53 60 62 63 66 68 70 71 73 74 75 76 79 81 82 86 87 88 91 92 93 94 98 100 102 103 114 119 120 124 125 126 130 131 133 137 139 142 145 147 148 150 153 154 155 159 160 161 163 165 167 168 170 172 173 174 183 187 192 195 196 197 199 200 205...

result:

ok Correct. (2 test cases)

Test #19:

score: 0
Accepted
time: 250ms
memory: 53344kb

input:

1
299998 436956
66759 1 261790 2
109661 2 298655 1
46487 1 170884 2
76196 2 124936 1
70653 1 154152 2
187319 1 250381 2
131759 1 133674 2
153676 1 231765 2
95797 1 282385 2
95776 1 187606 2
6703 2 106783 1
251760 2 267115 1
54769 2 192966 1
115099 2 180310 1
192901 2 250903 1
35909 2 295379 1
22399 ...

output:

394765
2 4 6 8 9 11 14 15 16 18 21 23 27 28 29 30 33 34 36 40 43 44 45 47 48 49 52 54 55 56 59 62 64 67 69 73 77 78 80 81 82 84 90 91 92 93 96 97 102 103 104 105 106 107 111 112 114 115 116 117 120 121 122 123 124 125 126 133 135 136 137 144 145 146 150 151 153 155 156 159 160 161 163 166 168 170 17...

result:

ok Correct. (1 test case)

Test #20:

score: 0
Accepted
time: 285ms
memory: 54052kb

input:

1
299994 438245
38127 2 88766 1
59431 1 233331 2
225189 2 299437 1
76723 2 250018 1
80328 1 284489 2
135816 2 296190 1
27764 2 225748 1
57528 2 199070 1
60742 1 139855 2
129082 1 134585 2
72351 1 177898 2
6906 1 35622 2
33083 2 135388 1
92785 2 180981 1
102084 2 111670 1
116574 1 276018 2
113641 2 2...

output:

362332
1 2 3 4 6 7 13 14 15 18 19 23 26 27 28 31 34 37 38 39 43 44 46 47 48 49 53 55 57 59 62 63 64 65 67 68 69 71 75 77 78 79 80 81 82 84 85 86 87 90 92 94 96 98 99 100 101 103 104 105 106 108 109 111 112 116 117 118 120 122 123 124 125 126 128 129 130 131 133 136 139 140 141 142 143 147 148 149 15...

result:

ok Correct. (1 test case)

Test #21:

score: 0
Accepted
time: 268ms
memory: 57364kb

input:

1
299998 498452
39091 2 59969 1
15828 2 270690 1
163349 2 191051 1
42486 1 110810 2
30384 1 223902 2
75185 1 269916 2
56964 2 162885 1
98233 2 196058 1
116601 1 127054 2
85919 1 102077 2
196200 2 214656 1
54709 1 265378 2
87175 1 234557 2
15966 1 21852 2
197173 1 277230 2
48503 2 49594 1
67349 2 242...

output:

400616
1 4 5 6 7 8 9 10 11 14 15 16 19 23 24 26 30 31 33 34 35 37 39 42 43 45 48 49 53 55 56 57 58 60 62 65 66 67 68 69 70 71 73 74 76 77 78 79 81 82 83 85 86 89 90 91 92 93 97 99 100 101 102 103 104 106 108 111 113 114 117 120 122 126 129 132 137 140 141 143 145 147 148 150 154 156 157 158 160 161 ...

result:

ok Correct. (1 test case)

Test #22:

score: 0
Accepted
time: 257ms
memory: 57444kb

input:

1
299995 499550
77642 2 123304 1
18605 1 73000 2
172858 1 248852 2
232126 2 281373 1
42007 2 117419 1
223100 2 257268 1
20588 1 213881 2
221459 2 249009 1
151591 2 176060 1
192169 1 210466 2
33033 1 83266 2
149863 2 281213 1
201519 1 223370 2
166375 1 193359 2
9628 2 156701 1
174303 2 207866 1
24592...

output:

400646
1 2 5 8 10 11 12 13 14 18 19 20 23 25 26 27 28 30 31 33 34 35 36 44 45 46 47 50 54 55 56 57 58 59 63 64 65 67 70 71 72 74 77 78 81 83 84 85 89 90 92 94 98 101 102 104 106 107 112 113 115 117 118 120 121 122 123 126 127 129 131 132 133 134 136 138 141 144 150 152 153 155 156 157 158 160 162 16...

result:

ok Correct. (1 test case)

Test #23:

score: 0
Accepted
time: 317ms
memory: 63564kb

input:

1
500000 499975
309101 2 498946 1
281120 2 349107 1
196611 1 428634 2
366844 1 454632 2
99985 2 491559 1
463849 2 481265 1
15616 2 149720 1
217051 2 272193 1
170421 2 180431 1
286108 1 319941 2
35639 1 479590 2
119301 2 472138 1
143961 2 234120 1
76549 1 381510 2
308177 2 334281 1
320444 2 467256 1
...

output:

800360
3 7 20 21 31 32 34 38 42 46 56 68 70 73 77 78 80 86 91 94 100 103 104 110 117 118 120 127 140 145 155 159 160 161 168 169 170 175 179 184 188 191 193 202 205 206 208 213 221 228 234 241 250 251 253 254 257 270 277 279 280 281 282 284 290 298 301 305 322 323 324 326 329 347 355 361 369 373 374...

result:

ok Correct. (1 test case)

Test #24:

score: 0
Accepted
time: 341ms
memory: 63576kb

input:

1
500000 499909
166847 2 203459 1
216068 1 237544 2
20036 1 283572 2
307653 1 464166 2
254057 1 287554 2
71599 1 145286 2
41917 1 218529 2
9253 2 472960 1
16916 1 44764 2
139158 2 362692 1
7006 1 462308 2
207592 2 323072 1
38281 1 145367 2
152055 2 258524 1
360540 2 390042 1
199177 1 247048 2
335637...

output:

800362
7 10 15 25 27 29 39 50 61 64 67 72 74 76 82 86 95 114 120 122 124 125 129 144 169 174 177 178 182 185 192 198 205 208 212 220 222 238 242 243 255 258 262 266 271 281 289 291 293 298 300 305 307 317 318 319 326 327 330 331 344 347 361 369 374 375 379 380 383 385 387 391 394 397 405 425 428 431...

result:

ok Correct. (1 test case)

Test #25:

score: 0
Accepted
time: 257ms
memory: 57164kb

input:

1
299992 496559
131746 1 232026 2
19016 2 180433 1
64221 1 70241 2
234723 2 260569 1
215594 2 236635 1
50989 2 176563 1
122707 2 278470 1
121505 1 152774 2
50211 2 130736 1
94525 2 281655 1
173141 1 176255 2
1808 2 168157 1
225766 1 247791 2
96263 1 280574 2
87079 1 200248 2
62377 2 87304 1
40727 2 ...

output:

400632
2 3 6 8 9 10 11 12 13 14 15 16 17 20 22 23 27 28 29 32 33 34 37 38 41 42 43 44 45 51 53 54 55 60 62 65 66 68 72 73 74 76 77 79 80 81 82 83 84 85 86 87 91 92 93 94 98 99 105 106 109 110 112 115 116 118 119 120 121 122 124 126 127 128 131 132 134 138 139 140 142 145 146 148 149 151 152 154 155 ...

result:

ok Correct. (1 test case)

Test #26:

score: 0
Accepted
time: 238ms
memory: 57228kb

input:

1
299989 499616
41124 2 236629 1
1708 2 20000 1
34477 1 34685 2
97 1 78502 2
162521 2 235391 1
937 2 226181 1
158944 1 282924 2
30060 2 98585 1
86033 1 271338 2
220135 1 261253 2
31995 1 91491 2
95080 1 145427 2
80355 2 218928 1
97707 2 187312 1
99043 1 175236 2
100685 1 109409 2
40482 2 216124 1
41...

output:

400613
1 2 9 10 11 12 13 14 15 16 19 22 23 24 27 28 30 31 32 33 34 35 36 38 39 40 41 43 44 45 46 47 48 49 51 52 53 54 59 60 61 63 64 66 69 72 73 75 77 80 82 84 85 87 89 92 94 95 97 98 99 100 102 108 109 111 112 113 114 117 121 122 125 127 130 132 133 134 135 137 140 143 144 145 146 147 149 150 153 1...

result:

ok Correct. (1 test case)

Test #27:

score: 0
Accepted
time: 310ms
memory: 63464kb

input:

1
500000 499960
156495 2 222771 1
192943 1 231434 2
52394 2 129100 1
22349 1 286266 2
252684 2 449139 1
49700 2 421137 1
133905 1 189382 2
278790 2 407847 1
155574 2 156461 1
355506 2 449725 1
73782 1 314244 2
39645 2 471881 1
95343 2 321999 1
382747 2 485247 1
24729 1 481479 2
179015 1 488398 2
211...

output:

800381
1 2 3 10 12 20 21 22 42 79 83 84 90 97 100 103 104 105 108 109 110 112 113 119 125 137 146 149 153 158 161 164 170 182 193 198 202 204 214 230 231 233 234 240 242 245 249 254 256 261 263 264 266 268 270 272 275 276 277 279 280 283 292 300 303 305 314 315 317 320 324 329 334 336 342 344 346 34...

result:

ok Correct. (1 test case)

Test #28:

score: 0
Accepted
time: 343ms
memory: 63444kb

input:

1
500000 499907
85402 2 291981 1
247209 2 375781 1
121657 2 393609 1
145810 2 254554 1
278586 1 476600 2
120097 1 305154 2
134366 1 240630 2
126915 2 404476 1
163364 1 458303 2
298699 1 471885 2
60039 2 134949 1
218817 2 223093 1
76531 2 370130 1
124352 2 128371 1
65133 2 113736 1
24905 2 390647 1
4...

output:

800349
1 4 9 11 13 22 26 36 41 48 53 56 62 63 64 68 82 88 90 94 97 104 119 130 132 143 145 155 157 162 165 167 174 175 178 180 191 192 200 204 218 219 223 232 242 245 247 250 253 260 272 273 275 279 282 283 291 293 294 295 300 302 309 314 316 321 325 327 330 334 343 346 350 351 358 360 382 386 388 3...

result:

ok Correct. (1 test case)