QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#396749#7202. Easy When You Know HowftiaschAC ✓44ms8768kbC++201.6kb2024-04-23 09:43:082024-04-23 09:43:09

Judging History

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

  • [2024-04-23 09:43:09]
  • 评测
  • 测评结果:AC
  • 用时:44ms
  • 内存:8768kb
  • [2024-04-23 09:43:08]
  • 提交

answer

#include <bits/stdc++.h>
#include <experimental/type_traits>

// {{{ boilerplate

class Dsu : public std::vector<int> {
public:
  explicit Dsu(int n) : std::vector<int>(n, -1) {}

  int find(int u) {
    if ((*this)[u] == -1) {
      return u;
    }
    if ((*this)[u] != u) {
      (*this)[u] = find((*this)[u]);
    }
    return (*this)[u];
  }

  bool merge(int a, int b) {
    if (find(a) == find(b)) {
      return false;
    }
    (*this)[find(a)] = find(b);
    return true;
  }
};


// }}}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout.tie(0);
  int n, Q;
  while (std::cin >> n >> Q) {
    std::vector<std::tuple<int, int, int>> queries(Q);
    std::vector<int> count(n + 1);
    for (int i = 0, x, y, l; i < Q; i++) {
      std::cin >> x >> y >> l;
      queries[i] = {x - 1, y - 1, l};
      count[l]++;
    }
    for (int i = 1; i <= n; i++) {
      count[i] += count[i - 1];
    }
    std::vector<std::pair<int, int>> queue(Q);
    for (auto [x, y, l] : queries) {
      queue[--count[l]] = {x, y};
    }
    Dsu dsu(n);
    int rear{Q}, components{n};
    for (int l = n; l >= 1; l--) {
      auto head = count[l];
      for (int i = rear; i-- > head;) {
        auto [x, y] = queue[i];
        if (dsu.merge(x, y)) {
          components--;
          queue[i++] = queue[head];
          queue[head++] = {
              x + 1,
              y + 1,
          };
        }
      }
      rear = head;
    }
    int result{1};
    for (int _ = 0; _ < components; _++) {
      result = 26LL * result % 1'000'000'007;
    }
    std::cout << result << '\n';
  }
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3644kb

input:

5 5
1 1 1
2 2 1
3 3 1
4 4 1
5 5 1
8 3
1 4 3
3 4 1
4 6 3

output:

11881376
676

result:

ok 2 tokens

Test #2:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

1 1
1 1 1

output:

26

result:

ok "26"

Test #3:

score: 0
Accepted
time: 24ms
memory: 8744kb

input:

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

output:

477338365

result:

ok "477338365"

Test #4:

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

input:

200000 1
1 100000 100000

output:

834294302

result:

ok "834294302"

Test #5:

score: 0
Accepted
time: 17ms
memory: 3700kb

input:

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

output:

17576
26
11881376
308915776
676
17576
676
26
676
676
26
26
11881376
17576
676
31810120
26
676
676
26
456976
17576
26
26
676
11881376
308915776
676
676
676
456976
26
676
26
26
676
26
11881376
26
17576
676
26
26
676
676
26
17576
26
676
11881376
676
17576
26
676
308915776
26
11881376
26
676
676
17576
6...

result:

ok 20000 tokens

Test #6:

score: 0
Accepted
time: 15ms
memory: 3644kb

input:

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

output:

26
676
676
26
26
17576
676
676
26
17576
17576
676
26
26
456976
26
676
676
26
676
26
676
26
676
26
26
676
26
26
26
26
26
456976
26
676
676
456976
26
26
26
11881376
17576
26
26
26
26
676
11881376
676
26
17576
17576
17576
676
676
26
26
26
676
26
676
676
26
676
26
26
676
26
456976
676
676
17576
676
4569...

result:

ok 20000 tokens

Test #7:

score: 0
Accepted
time: 17ms
memory: 3588kb

input:

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

output:

17576
26
676
26
26
26
26
26
26
26
26
26
676
17576
26
26
26
26
26
26
17576
26
26
676
26
26
676
26
26
26
26
676
26
26
26
26
26
456976
26
26
26
676
26
26
26
26
26
17576
26
26
676
26
26
26
26
676
308915776
26
26
26
26
26
26
676
676
26
26
676
26
676
26
676
17576
17576
676
26
26
676
26
26
26
11881376
3089...

result:

ok 20000 tokens

Test #8:

score: 0
Accepted
time: 13ms
memory: 3844kb

input:

100 200
8 93 1
100 96 1
65 84 15
17 42 54
60 12 13
68 9 25
91 74 7
84 75 5
43 12 22
54 25 43
58 39 33
16 8 30
66 98 2
57 43 7
43 64 11
75 27 21
3 43 19
99 50 2
8 93 1
40 17 15
67 39 18
90 87 6
42 11 30
57 99 2
78 45 19
22 1 72
82 74 1
32 18 14
12 16 77
26 10 11
75 69 19
28 77 13
16 70 4
77 38 7
61 3...

output:

26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
676
26
26
676
26
26
2...

result:

ok 500 tokens

Test #9:

score: 0
Accepted
time: 11ms
memory: 3648kb

input:

123 300
13 3 16
84 26 25
89 53 9
95 84 24
89 16 7
112 109 10
32 6 20
99 5 19
67 33 26
46 59 19
93 18 4
93 21 12
90 20 17
14 43 29
99 24 11
20 15 18
62 40 4
94 54 28
94 96 6
26 98 20
62 60 5
37 90 11
56 78 19
86 4 14
105 51 11
94 15 26
44 87 29
15 53 13
34 6 17
2 40 15
35 11 16
47 29 27
90 99 15
70 8...

output:

26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
676
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26...

result:

ok 400 tokens

Test #10:

score: 0
Accepted
time: 15ms
memory: 3884kb

input:

140 400
116 129 5
1 131 5
46 95 20
128 66 8
120 96 16
109 67 12
93 79 21
93 60 11
101 62 22
123 4 17
65 116 12
48 1 6
102 49 20
103 31 24
28 90 22
54 106 17
125 133 8
25 35 6
67 42 20
27 19 30
119 17 13
96 68 27
83 88 6
47 102 9
50 44 7
51 69 30
25 18 3
111 64 21
6 12 7
85 43 27
95 54 22
49 114 7
42...

output:

26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
...

result:

ok 300 tokens

Test #11:

score: 0
Accepted
time: 9ms
memory: 3880kb

input:

170 500
137 22 11
36 114 29
12 77 18
34 44 6
90 35 21
64 42 28
10 27 11
148 108 18
94 37 22
58 2 26
31 135 18
119 29 17
77 72 20
103 66 23
60 139 23
68 5 27
80 58 18
107 49 25
62 151 5
105 130 23
18 73 14
79 100 11
134 3 24
2 51 27
23 42 28
7 101 7
89 67 6
72 26 19
105 116 16
143 71 22
148 8 18
119 ...

output:

26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
...

result:

ok 200 tokens

Test #12:

score: 0
Accepted
time: 8ms
memory: 3820kb

input:

160 600
48 37 10
98 63 11
113 17 9
15 101 5
66 8 16
65 10 15
13 77 11
91 81 16
13 29 15
111 64 16
121 119 25
11 94 28
147 123 5
59 108 16
17 14 19
26 139 10
28 7 20
122 81 16
37 89 9
76 139 9
42 99 9
89 87 22
62 18 9
67 32 11
60 79 20
103 17 15
121 93 18
58 55 15
119 7 27
111 133 22
108 86 29
3 90 9...

output:

26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26

result:

ok 100 tokens

Test #13:

score: 0
Accepted
time: 25ms
memory: 3800kb

input:

1234 5678
1167 247 23
263 585 186
900 935 168
528 1 524
293 1103 126
516 591 39
546 260 588
590 975 143
641 1155 5
28 572 346
964 673 253
610 954 133
795 272 355
967 1071 78
224 84 680
547 259 441
1074 424 65
1093 233 26
36 824 214
807 274 369
781 484 161
245 1029 193
294 324 198
479 874 27
1217 116...

output:

26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26

result:

ok 35 tokens

Test #14:

score: 0
Accepted
time: 26ms
memory: 3580kb

input:

2234 1678
877 194 321
336 1562 168
1036 1668 345
465 14 781
60 1399 274
570 1508 701
1668 2051 57
1509 633 154
1758 1631 289
2183 518 6
1593 211 210
563 1059 535
1335 92 70
977 483 1221
365 678 227
632 56 739
651 633 1217
246 1961 105
1481 526 59
1278 1090 582
619 708 290
2061 1406 48
519 1449 431
8...

output:

26
26
26
26
26
676
26
676
26
26
26
26
26
26
676
26
26
26
676
26
26
26
26
676
26
26
26
26
26
26
26
26
26
26
26
26
676
26
676
26
17576
17576
26
26
26
676
26
26
26
26
26
26
26
26
26
676
26
26
676
676
676
26
26
676
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
676
26
26
26
26
26
676

result:

ok 89 tokens

Test #15:

score: 0
Accepted
time: 28ms
memory: 3760kb

input:

3234 2678
526 550 4
2547 1676 4
2693 380 6
630 1548 27
417 975 2
1529 2380 25
1121 2504 19
2270 131 25
2536 1207 23
2531 1050 28
1737 1943 46
3021 2206 23
2671 598 45
1149 2811 30
105 2845 7
27 32 28
2813 1115 7
1961 1123 20
942 507 40
3180 1435 27
2495 2814 33
749 1660 50
1805 78 7
1895 2749 46
205...

output:

676
26
26
17576
308915776
26
26
26
26
676
26
17576
26
17576
26
26
26
26
676
26
26
26
26
26
26
26
676
676
26
26
26
676
26
26
17576
26
676
26
676
26
26
676
26
17576
26
26
26
17576
26
26
26
26
26
26
26
26
26
26
26
676
26

result:

ok 61 tokens

Test #16:

score: 0
Accepted
time: 24ms
memory: 3748kb

input:

4234 3678
1679 1894 42
1954 4137 44
2593 2039 51
1471 345 52
1213 734 32
3068 3560 35
265 1058 50
800 2050 44
1729 2394 40
4111 810 33
2805 2248 40
2489 2587 37
2311 3975 39
1430 3110 36
410 4028 32
728 3515 39
2082 2281 51
324 2771 53
1713 3533 48
2841 1923 43
521 1235 35
860 1036 48
4032 2234 49
2...

output:

26
26
26
26
26
26
26
676
26
676
26
26
26
26
26
676
26
676
26
26
26
17576
26
676
26
26
26
26
26
26
26
26
26
676
26
26
456976
676
26
26
26
26
26
26
26
26
26

result:

ok 47 tokens

Test #17:

score: 0
Accepted
time: 30ms
memory: 3708kb

input:

5234 4678
3114 145 2062
2440 2959 2035
5086 4952 17
289 2845 2217
3235 1579 1661
3881 4351 651
2240 1424 2964
897 161 2791
4527 1809 409
748 3657 1505
2108 1377 1675
3583 2265 753
2770 4634 322
725 1453 2629
2908 69 732
4390 1421 378
4117 1655 129
80 2590 249
187 1170 1365
3735 1563 845
3700 3886 78...

output:

26
17576
17576
26
26
26
26
26
26
676
26
26
17576
26
26
26
676
676
676
26
26
26
26
676
26
676
676
26
26
676
26
17576
26
26
26
676
26
26

result:

ok 38 tokens

Test #18:

score: 0
Accepted
time: 20ms
memory: 3780kb

input:

10000 23023
8088 1823 767
9928 6654 45
1559 2467 4512
2252 1627 936
5161 5276 2434
4233 5305 1327
7008 5253 30
3777 1672 5710
9944 20 22
3703 1723 1072
1138 8743 1072
2345 9955 5
7085 64 2019
3674 5240 3350
6058 5247 762
7236 4360 2251
1329 3182 5846
2701 3107 1726
8398 945 154
9320 3319 215
6401 47...

output:

26
26
26
26
26
26
26
26

result:

ok 8 tokens

Test #19:

score: 0
Accepted
time: 33ms
memory: 3968kb

input:

20000 23203
5670 11604 5002
2435 6081 5001
10797 9293 5003
10024 3671 5000
3952 7101 5000
13317 5279 5003
5968 12719 5003
7241 10863 5002
11292 411 5003
12197 7075 5002
7338 10737 5002
10399 1704 5002
8695 13973 5001
1984 13112 5001
7615 11772 5001
2131 11256 5002
2766 4486 5003
14936 6421 5003
4834...

output:

26
26
26
26
26
26
26
26

result:

ok 8 tokens

Test #20:

score: 0
Accepted
time: 24ms
memory: 3996kb

input:

30000 23230
12571 28238 407
10632 13372 2582
5520 23728 4388
943 3690 5144
17632 22684 2856
12969 23171 2993
26896 29399 348
6812 5976 12974
12363 24200 774
27921 27288 1489
25740 5172 1323
18308 13918 10721
2559 18229 7945
8345 28456 1071
27479 21946 2478
16736 17323 6560
22320 1125 4810
5035 16181...

output:

26
676
676
676
26
26

result:

ok 6 tokens

Test #21:

score: 0
Accepted
time: 32ms
memory: 3748kb

input:

10000 13023
7649 2080 403
391 6331 2590
9644 717 43
2203 983 6310
4947 893 1512
4025 1084 434
2696 5382 2175
403 6277 270
5132 5420 2025
3628 4486 5324
845 4821 4543
5186 9062 171
2978 1228 4188
1016 9422 515
5669 618 270
7298 2769 401
2770 5378 1500
7892 1068 1991
2175 5387 2272
492 4528 2217
8749 ...

output:

26
26
26
676
26
26
26
26
26
26
26
26
26
26
26

result:

ok 15 tokens

Test #22:

score: 0
Accepted
time: 27ms
memory: 4088kb

input:

20000 23203
7565 399 5975
1791 9229 5584
1162 1694 5267
5720 2820 5431
4840 2859 5047
1708 8077 5140
5794 400 5411
9429 7507 5391
11147 2627 5105
11114 1823 5637
5136 8755 5695
4903 10860 5056
2318 2754 5555
12726 10982 5966
1494 9346 5941
5836 11151 5236
14309 7548 5632
10201 179 5190
9841 2529 588...

output:

26
676
26
26
26
26
26
676

result:

ok 8 tokens

Test #23:

score: 0
Accepted
time: 38ms
memory: 4108kb

input:

30000 33230
307 25278 1707
20170 20991 5440
13242 1287 3658
6399 27439 767
25141 7067 2420
18985 4688 7164
11209 29269 254
7082 25563 1472
8664 1905 2556
5292 20334 4527
6033 19094 2478
25466 12106 1795
22074 29769 15
13708 24274 2343
14764 3471 14974
13970 18914 8436
9663 11633 13045
22948 8220 313...

output:

676
26
26
26
26
676

result:

ok 6 tokens

Test #24:

score: 0
Accepted
time: 21ms
memory: 3708kb

input:

10000 23023
405 1853 45
3054 7008 1959
3075 6845 423
6452 4557 3104
5088 4025 387
5304 9582 331
4354 2892 3415
4195 2179 5056
287 6525 3021
8235 4612 1034
5401 3687 2391
3682 2172 3549
5867 4378 1811
9117 2407 201
7523 4544 750
2727 8029 100
336 9394 280
6519 8463 971
3357 7132 805
8287 8018 974
492...

output:

26
26
26
26
26
26
26
26

result:

ok 8 tokens

Test #25:

score: 0
Accepted
time: 36ms
memory: 3912kb

input:

20000 23203
1632 11718 4251
13316 13372 1083
17512 18728 119
18642 11178 244
2757 2124 10155
17589 9230 1262
5515 12855 2706
10055 9779 8571
19006 11471 371
4675 12441 3171
16099 16864 1333
12113 8331 3678
7270 6250 6185
16432 15620 1016
3308 15759 2253
13764 16509 357
540 11452 5438
1664 18715 376
...

output:

26
26
26
26
26
26
26
676

result:

ok 8 tokens

Test #26:

score: 0
Accepted
time: 25ms
memory: 4040kb

input:

30000 23230
16518 9282 6872
27686 1962 1546
16404 21946 6811
10749 3859 16820
4676 3452 9351
28789 27304 847
24774 2031 3802
16434 29171 162
22165 28121 1631
2923 4403 17164
16705 22744 607
3492 21060 3893
1889 25326 4245
11145 17694 5497
8088 15906 2525
4111 1091 3981
8197 29427 333
12007 27828 142...

output:

26
26
26
26
26
676

result:

ok 6 tokens

Test #27:

score: 0
Accepted
time: 22ms
memory: 4912kb

input:

100000 50000
40194 40710 12481
6758 67335 27011
27549 33129 17013
76179 19198 6722
55480 65353 23253
40818 38742 8918
52783 42656 37427
44156 35078 33037
27045 53632 28780
55189 58833 21764
71647 29299 3471
16277 46860 41362
10318 67282 5886
37279 42696 40963
34591 27037 34844
42858 53376 33608
3788...

output:

26
676

result:

ok 2 tokens

Test #28:

score: 0
Accepted
time: 21ms
memory: 4944kb

input:

100000 50000
14348 18098 38572
69519 38276 24860
46244 36812 11246
14659 37163 36774
52246 19089 42306
50359 18989 15558
91138 32979 3429
13270 73828 19881
36193 62745 8026
22353 40123 38242
14936 3370 11795
7741 25274 21159
2370 58936 39888
14817 6431 41448
74015 10937 5464
23577 28072 35504
11991 ...

output:

26
676

result:

ok 2 tokens

Test #29:

score: 0
Accepted
time: 25ms
memory: 4912kb

input:

100000 50000
32387 36878 36772
38343 12849 30485
21210 28202 33185
13974 64191 25942
47503 21820 40267
5229 10748 35610
56047 11467 26762
53444 38695 29172
39861 52929 41126
17437 36827 29413
10181 13252 24102
26093 20637 34659
41338 823 30495
17362 8524 39030
1731 24340 33770
4703 21039 29547
29980...

output:

26
676

result:

ok 2 tokens

Test #30:

score: 0
Accepted
time: 24ms
memory: 4908kb

input:

100000 50000
10848 18883 40537
6572 21875 33012
66716 7686 32586
43572 7504 41981
18540 22746 23658
33071 44038 34361
57581 31695 30857
13335 43070 40925
26605 59916 28095
30051 74928 23691
49393 57285 40164
55510 58051 37396
47120 59836 36196
42462 16861 39892
52000 2315 34000
60739 43281 32632
513...

output:

26
676

result:

ok 2 tokens

Test #31:

score: 0
Accepted
time: 24ms
memory: 4916kb

input:

100000 50000
1082 58622 31640
13736 37448 41848
18628 61715 25524
14587 16806 36218
1876 36022 30194
37926 46004 41174
53313 19146 39349
46873 33434 34769
17871 65002 23930
55327 19422 29181
65796 38111 27174
26780 53256 41988
29348 35492 36662
58038 53194 27285
35786 35823 40360
58606 36544 31916
7...

output:

17576
26

result:

ok 2 tokens

Test #32:

score: 0
Accepted
time: 19ms
memory: 4944kb

input:

100000 50000
32586 60004 10
52086 43998 10
86750 7464 8
24060 97758 9
7373 93205 6
83075 56231 9
40509 8904 9
64089 24943 10
26770 53781 7
38079 29148 8
57253 22636 5
61123 19312 10
18526 18334 10
66679 55655 8
18485 79000 7
57079 64988 9
64969 57074 9
21232 83146 5
31101 81112 6
36151 191 6
62464 4...

output:

683110876
487811960

result:

ok 2 tokens

Test #33:

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

input:

100000 1000
2524 33291 20
40304 67439 20
3849 48885 11
39047 36291 15
89088 72030 19
32533 60575 12
47141 35937 13
63217 1322 10
10478 90233 10
14495 65835 14
11797 96582 13
63683 12330 16
78576 52630 10
61683 83739 12
32301 1552 19
66794 41435 16
45851 32713 15
58677 42263 11
20247 90138 12
91856 5...

output:

717866257
394604221

result:

ok 2 tokens

Test #34:

score: 0
Accepted
time: 18ms
memory: 5692kb

input:

200000 50000
137318 69826 44441
125443 134105 44441
3749 36913 44441
76627 102622 44444
95399 154003 44440
118952 37385 44441
107777 20056 44444
69525 31374 44441
112926 64621 44441
55429 84542 44442
149593 23969 44443
42364 75130 44442
2525 85078 44442
59257 3522 44441
133710 79483 44440
145405 491...

output:

993679491

result:

ok "993679491"

Test #35:

score: 0
Accepted
time: 18ms
memory: 5772kb

input:

200000 50000
11187 1145 55555
25809 5892 55555
133805 128175 55551
109465 107177 55553
60712 48833 55554
110453 99144 55551
40833 96995 55550
114286 24506 55553
59204 34049 55553
71285 100911 55554
4094 453 55550
16082 117872 55550
38845 109863 55554
128273 121723 55551
77046 26333 55550
59706 58938...

output:

308915776

result:

ok "308915776"

Test #36:

score: 0
Accepted
time: 18ms
memory: 5864kb

input:

200000 50000
101987 49416 66660
82522 41422 66662
71977 101469 66661
80065 109903 66663
64257 71237 66666
20966 181 66662
28110 26655 66662
29598 33583 66663
78441 66485 66664
10891 19261 66664
114861 8617 66661
3280 27502 66663
118622 69910 66666
68441 47392 66665
5709 36766 66666
60158 117850 6666...

output:

26

result:

ok "26"

Test #37:

score: 0
Accepted
time: 42ms
memory: 8560kb

input:

200000 200000
185864 141984 513
130905 75751 579
17622 130525 553
168299 181670 582
138538 75466 583
122585 130409 577
60363 120476 559
184416 52795 510
73611 92326 522
44347 119617 537
43539 19400 527
38028 132108 571
28151 897 536
51419 90959 568
122070 114524 547
186593 140350 573
125751 29943 54...

output:

26

result:

ok "26"

Test #38:

score: 0
Accepted
time: 41ms
memory: 8608kb

input:

200000 200000
101875 16690 1489
134623 113998 1605
25000 35419 1145
77862 8861 1851
110930 196202 1507
186855 1822 1822
143780 78788 1351
80351 184691 1678
104166 129054 1885
134348 33634 1097
40739 141450 1525
103867 173902 1657
78730 126899 1061
39658 111885 1566
81294 49798 1397
47633 66405 1971
...

output:

676

result:

ok "676"

Test #39:

score: 0
Accepted
time: 12ms
memory: 5972kb

input:

100000 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
1 1 100000
...

output:

834294302

result:

ok "834294302"

Test #40:

score: 0
Accepted
time: 27ms
memory: 3708kb

input:

1000 1000
344 574 397
605 893 94
59 765 7
929 291 19
799 153 114
914 772 79
738 558 143
693 181 189
691 223 113
829 509 20
688 822 82
68 812 61
982 284 16
32 744 55
511 5 273
156 642 227
733 873 50
618 646 106
688 782 122
287 73 294
841 299 73
530 330 270
546 924 39
511 595 252
812 832 166
978 314 3...

output:

676
676
26
26
26
676
676
26
676
676
676
676
676
26
26
17576
676
26
26
676
26
17576
26
26
676
676
26
676
676
676
676
26
676
26
26
26
456976
676
456976
26
676
26
676
676
676
26
676
676
26
676
17576
26
26
26
26
26
11881376
26
26
11881376
676
17576
676
676
676
676
26
26
676
676
676
26
676
26
26
676
26
6...

result:

ok 200 tokens

Test #41:

score: 0
Accepted
time: 30ms
memory: 3608kb

input:

1000 1000
594 363 186
668 171 332
31 927 44
745 948 2
121 597 109
795 39 85
601 202 122
979 328 3
277 949 33
873 943 37
391 377 119
38 409 299
848 526 116
889 539 35
211 106 98
626 199 183
486 885 28
744 135 141
88 585 365
401 233 218
732 452 235
105 539 266
503 342 374
314 881 96
165 312 426
219 18...

output:

31810120
676
827063120
827063120
17576
503640973
11881376
308915776
17576
17576
17576
11881376
503640973
827063120
676
94665207
308915776
456976
17576
456976
17576
503640973
827063120
308915776
456976
676
676
676
26
94665207
17576
456976
503640973
676
461295368
456976
308915776
94665207
11881376
456...

result:

ok 200 tokens

Test #42:

score: 0
Accepted
time: 28ms
memory: 3644kb

input:

1000 1000
814 814 76
345 251 84
75 357 499
336 336 632
159 911 7
685 685 277
477 853 22
889 137 88
394 112 343
965 589 29
128 880 86
360 830 54
699 135 244
536 160 386
910 158 88
859 13 34
328 328 416
153 529 411
64 440 464
903 903 47
873 403 52
801 801 32
219 877 83
40 792 1
914 68 43
997 151 1
178...

output:

653318058
69785688
675900607
786756254
54959657
444606384
461295368
675900607
727331219
273485821
811308595
461295368
786756254
87183883
25973185
553913484
993679491
573415663
553243706
266780944
847223987
308915776
356672534
270134630
504696368
74364105
786756254
628985479
543301878
11881376
683110...

result:

ok 200 tokens

Test #43:

score: 0
Accepted
time: 27ms
memory: 3908kb

input:

1000 1000
988 340 3
439 115 350
417 849 117
31 787 211
411 843 136
1000 28 1
698 374 123
123 879 118
993 777 2
378 486 35
175 823 7
860 968 22
991 235 10
937 829 32
694 802 180
848 632 67
36 144 272
691 259 140
454 22 91
854 746 121
933 501 23
130 454 474
588 696 211
939 399 25
644 644 217
973 217 1...

output:

193602390
398682019
302830361
744495265
926872034
539729293
712895096
335111352
676
605918696
285188422
54327522
581388607
919731558
194489420
609277241
650848395
562930747
145834182
95327091
283066169
12648318
617965234
906450523
604953949
871412039
803251822
397465498
473178622
577138812
617965234...

result:

ok 200 tokens

Test #44:

score: 0
Accepted
time: 42ms
memory: 8608kb

input:

200000 200000
7591 28584 139948
105773 115707 16748
73359 17071 117982
104735 187259 2904
53982 81943 45180
136065 123390 48459
172588 52843 13049
77498 90527 24847
182770 3993 5363
143891 83804 18350
154505 176044 12146
57268 157136 5267
33960 55505 46464
81639 121913 51136
193064 164181 6683
16245...

output:

676

result:

ok "676"

Test #45:

score: 0
Accepted
time: 44ms
memory: 8608kb

input:

200000 200000
3792 181753 9770
148714 26921 26914
181629 48076 1800
153224 103713 36580
128950 198075 1910
116259 109854 41511
51544 67224 87200
49683 191930 2086
21943 28845 115526
14066 41380 148747
134535 83652 19766
142579 4294 21844
58497 193835 2787
126075 194416 4499
82384 71807 79179
173714 ...

output:

31810120

result:

ok "31810120"

Test #46:

score: 0
Accepted
time: 39ms
memory: 8556kb

input:

200000 200000
134530 184813 1436
23460 98903 31032
91177 65351 15691
50440 114450 70368
97415 6136 23482
64046 111776 38810
83707 191636 1941
34908 166887 27626
33967 159101 22643
72829 15109 76770
121322 116956 47220
191379 187346 8170
29504 163407 22187
150548 33924 11026
162167 152843 32699
14195...

output:

270134630

result:

ok "270134630"

Test #47:

score: 0
Accepted
time: 40ms
memory: 8768kb

input:

200000 200000
124906 180424 15320
193458 106772 78
158860 41980 39974
183376 143442 11037
195961 194987 2709
8689 100245 5394
26610 93816 28924
8145 97753 50245
73020 57436 95578
183457 26643 1481
8312 57012 46635
173749 69531 11691
193238 82202 2931
261 52857 131119
194063 162895 1970
58764 37336 8...

output:

947109271

result:

ok "947109271"

Extra Test:

score: 0
Extra Test Passed