QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#834600#8818. Colorful Graph 3GPT-ofast#AC ✓180ms40936kbPython32.8kb2024-12-27 20:52:312024-12-27 20:52:31

Judging History

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

  • [2024-12-27 20:52:31]
  • 评测
  • 测评结果:AC
  • 用时:180ms
  • 内存:40936kb
  • [2024-12-27 20:52:31]
  • 提交

answer

import sys

def main():
    tokens = sys.stdin.read().split()
    it = iter(tokens)
    def next_token():
        return next(it)

    cas = int(next_token())
    N = 10**5
    c = [0] * N
    q = [[] for _ in range(N)]
    for _ in range(cas):
        n = int(next_token())
        k = int(next_token())
        tp = -1
        op = -1
        cc = [0, 0]
        for i in range(k):
            c[i] = int(next_token())
            if c[i] >= 2:
                tp = i
            else:
                cc[c[i]] += 1
                if c[i] == 1:
                    op = i
        if tp != -1:
            print(n - 1)
            for i in range(1, n):
                print(1, i + 1, tp + 1)
            continue
        t = 0
        sp = 1
        psp = 1
        while True:
            while t == sp * (sp - 1) // 2:
                sp += 1
            if t * (k - 1) + (sp - 1) * cc[1] >= n - 1:
                break
            psp = sp
            t += 1
        rq = t * (k - 1) + (sp - 1) * cc[1] - (n - 1)
        if cc[1] == 0:
            sp = 1
        for i in range(n):
            q[i].clear()
        rs = []
        for i in range(k):
            qc = t + (sp - 1 if c[i] else 0)
            rd = min(rq, 1 + (1 if psp != sp and c[i] == 1 else 0), qc)
            if op == i:
                rd = 0
            qc -= rd
            rq -= rd
            j_start = 0 if c[i] else sp - 1
            for j in range(j_start, sp * (sp - 1) // 2):
                if qc > 0:
                    q[j].append(i)
                    qc -= 1
                else:
                    break
            rs.append((qc, i))
        rs.sort()
        assert rs[-1][0] - rs[0][0] <= 1
        ans = []
        ind = sp
        id_ = 0
        for i in range(sp):
            for j in range(i + 1, sp):
                assert len(q[id_]) > 0
                x = q[id_].pop()
                lst = i
                for y in q[id_]:
                    ans.append((lst, ind, y))
                    lst = ind
                    ind += 1
                ans.append((lst, j, x))
                id_ += 1
        while rs[-1][0] > 0:
            fst = -1
            lst = 0
            for idx in range(len(rs)):
                cn, x = rs[idx]
                if cn > 0:
                    rs[idx] = (cn - 1, x)
                    if fst == -1:
                        fst = x
                    else:
                        ans.append((lst, ind, x))
                        lst = ind
                        ind += 1
            assert fst != -1
            ans.append((lst, 0, fst))
        assert len(ans) == (n - 1 + t)
        print(len(ans))
        for x, y, v in ans:
            print(x + 1, y + 1, v + 1)

if __name__ == "__main__":
    main()

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 19ms
memory: 18472kb

input:

3
4 2
1 1
2 2
0 0
5 2
3 1

output:

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

result:

ok orz (3 test cases)

Test #2:

score: 0
Accepted
time: 138ms
memory: 19464kb

input:

4645
2 2
0 0
2 2
0 1
2 2
1 1
3 2
0 0
3 2
0 1
3 2
1 1
3 3
0 0 0
3 3
1 0 0
3 3
1 0 1
3 3
1 1 1
4 2
0 0
4 2
1 0
4 2
1 1
4 3
0 0 0
4 3
0 0 1
4 3
0 1 1
4 3
1 1 1
4 4
0 0 0 0
4 4
0 1 0 0
4 4
1 1 0 0
4 4
1 1 1 0
4 4
1 1 1 1
5 2
0 0
5 2
1 0
5 2
1 1
5 3
0 0 0
5 3
0 1 0
5 3
1 1 0
5 3
1 1 1
5 4
0 0 0 0
5 4
0 1...

output:

2
1 2 2
2 1 1
1
1 2 2
1
1 2 2
4
1 2 2
2 1 1
1 3 2
3 1 1
3
1 2 2
1 3 2
2 3 2
2
1 3 1
3 2 2
3
1 2 2
2 3 3
3 1 1
3
1 2 1
1 3 1
2 3 1
2
1 3 1
3 2 3
2
1 3 2
3 2 3
6
1 2 2
2 1 1
1 3 2
3 1 1
1 4 2
4 1 1
4
1 2 1
1 3 1
2 4 1
4 3 2
4
1 4 1
4 2 2
1 3 2
2 3 2
5
1 2 2
2 3 3
3 1 1
1 4 3
4 1 2
4
1 2 3
1 3 3
2 4 2
...

result:

ok orz (4645 test cases)

Test #3:

score: 0
Accepted
time: 113ms
memory: 19036kb

input:

2379
56 2
1 1
56 2
0 1
56 2
0 0
55 12
1 1 1 1 1 1 1 1 1 1 1 1
55 12
1 0 1 1 1 1 1 1 1 1 1 1
55 12
0 1 1 1 0 1 1 1 1 1 1 1
55 12
0 1 1 1 1 1 1 1 0 1 0 1
55 12
0 1 0 1 0 1 1 1 1 1 1 0
55 12
1 0 1 0 0 0 1 0 1 1 1 1
55 12
0 0 1 1 0 0 1 0 1 1 1 0
55 12
0 0 0 1 0 1 0 1 1 1 0 0
55 12
0 1 1 0 0 0 0 1 1 0 0 ...

output:

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

result:

ok orz (2379 test cases)

Test #4:

score: 0
Accepted
time: 112ms
memory: 18664kb

input:

1244
73 3
1 1 1
87 3
1 1 1
60 4
1 1 0 0
72 4
0 1 1 1
84 4
0 0 0 0
100 2
1 1
64 2
1 0
81 3
1 1 1
101 6
1 1 0 1 0 0
66 6
1 0 1 1 0 1
59 2
1 1
68 6
1 1 0 0 0 0
87 6
1 1 1 1 1 1
105 4
0 1 0 0
104 3
1 1 1
94 6
1 1 0 0 0 1
91 5
1 1 1 1 1
63 3
1 0 0
100 5
0 0 0 0 0
70 4
1 1 1 1
61 5
0 0 0 0 1
104 2
0 1
94 ...

output:

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

result:

ok orz (1244 test cases)

Test #5:

score: 0
Accepted
time: 127ms
memory: 18484kb

input:

739
105 2
0 0
105 2
1 0
105 2
1 1
105 3
0 0 0
105 3
0 0 1
105 3
0 1 1
105 3
1 1 1
105 4
0 0 0 0
105 4
0 1 0 0
105 4
0 1 1 0
105 4
1 0 1 1
105 4
1 1 1 1
106 2
0 0
106 2
0 1
106 2
1 1
106 3
0 0 0
106 3
1 0 0
106 3
0 1 1
106 3
1 1 1
106 4
0 0 0 0
106 4
0 0 0 1
106 4
1 0 1 0
106 4
0 1 1 1
106 4
1 1 1 1
...

output:

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

result:

ok orz (739 test cases)

Test #6:

score: 0
Accepted
time: 138ms
memory: 18644kb

input:

495
237 3
0 1 0
237 3
0 0 0
237 2
1 1
237 2
0 1
237 2
0 0
236 3
1 1 1
236 3
0 1 1
236 3
0 1 0
236 3
0 0 0
236 2
1 1
236 2
0 1
236 2
0 0
235 3
1 1 1
235 3
1 0 1
235 3
1 0 0
235 3
0 0 0
235 2
1 1
235 2
0 1
235 2
0 0
234 3
1 1 1
234 3
0 1 1
234 3
1 0 0
234 3
0 0 0
234 2
1 1
234 2
0 1
234 2
0 0
233 3
1 ...

output:

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

result:

ok orz (495 test cases)

Test #7:

score: 0
Accepted
time: 160ms
memory: 18568kb

input:

339
259 2
1 1
270 2
1 0
348 2
0 0
336 2
0 1
275 2
1 1
279 2
0 1
340 2
1 1
283 2
0 0
292 2
0 0
327 2
1 1
316 2
0 0
328 2
0 0
244 2
1 1
302 2
0 0
264 2
0 0
291 2
1 1
266 2
0 1
320 2
0 1
317 2
1 0
336 2
0 0
310 2
0 0
240 2
0 0
345 2
0 0
292 2
1 1
267 2
1 1
340 2
1 0
291 2
0 1
312 2
1 1
269 2
1 1
278 2
...

output:

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

result:

ok orz (339 test cases)

Test #8:

score: 0
Accepted
time: 105ms
memory: 19904kb

input:

15
5529 5529
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

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

result:

ok orz (15 test cases)

Test #9:

score: 0
Accepted
time: 80ms
memory: 19036kb

input:

35
2838 6
1 1 1 1 1 1
1516 73
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1974 7
1 1 1 1 1 1 1
2499 4
1 1 1 1
1520 4
1 1 1 1
2235 224
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

3365
1 35 1
35 36 2
36 37 3
37 38 4
38 39 5
39 2 6
1 40 1
40 41 2
41 42 3
42 43 4
43 44 5
44 3 6
1 45 1
45 46 2
46 47 3
47 48 4
48 49 5
49 4 6
1 50 1
50 51 2
51 52 3
52 53 4
53 54 5
54 5 6
1 55 1
55 56 2
56 57 3
57 58 4
58 59 5
59 6 6
1 60 1
60 61 2
61 62 3
62 63 4
63 64 5
64 7 6
1 65 1
65 66 2
66 6...

result:

ok orz (35 test cases)

Test #10:

score: 0
Accepted
time: 83ms
memory: 19200kb

input:

15
5017 4
1 1 1 1
5456 100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
4186 4
1 1 1 1
6624 23
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
3667...

output:

6612
1 59 1
59 60 2
60 61 3
61 2 4
1 62 1
62 63 2
63 64 3
64 3 4
1 65 1
65 66 2
66 67 3
67 4 4
1 68 1
68 69 2
69 70 3
70 5 4
1 71 1
71 72 2
72 73 3
73 6 4
1 74 1
74 75 2
75 76 3
76 7 4
1 77 1
77 78 2
78 79 3
79 8 4
1 80 1
80 81 2
81 82 3
82 9 4
1 83 1
83 84 2
84 85 3
85 10 4
1 86 1
86 87 2
87 88 3
8...

result:

ok orz (15 test cases)

Test #11:

score: 0
Accepted
time: 80ms
memory: 18980kb

input:

35
2094 90
1 0 0 0 1 0 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 1 0 1 0 1 0 0 0 0 1 1 0 0 1 0 1 0 1 1 0 0 1 1 0 0 1 1 0 1 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 1 0 0 0 1 0 0 1 1 0 1 1 0 0 0 0 0 1
1931 82
1 0 0 0 1 0 1 0 0 0 0 1 1 0 0 1 0 1 1 0 1 1 0 0 0 0 1 0 0 0 1 0 0 1 0 0 1 0 1 1 1 1 1 0 1 0 0 0 0 0 1...

output:

2114
1 9 1
9 10 5
10 11 10
11 12 13
12 13 16
13 14 20
14 15 25
15 16 29
16 17 31
17 18 33
18 19 38
19 20 39
20 21 42
21 22 44
22 23 46
23 24 47
24 25 50
25 26 51
26 27 54
27 28 55
28 29 57
29 30 62
30 31 63
31 32 67
32 33 68
33 34 73
34 35 77
35 36 80
36 37 81
37 38 83
38 39 84
39 2 90
1 40 1
40 41 ...

result:

ok orz (35 test cases)

Test #12:

score: 0
Accepted
time: 92ms
memory: 19516kb

input:

15
3844 3
0 1 0
4674 27
1 1 0 0 1 0 1 1 0 0 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0 0 1
5623 91
0 1 1 1 1 0 1 1 1 1 0 1 1 0 1 1 1 1 0 0 1 0 0 0 1 1 1 0 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 0 1 1 0 0 0 0 0 0 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 0 1 0 0 0 1 1 1 1 1 0 0
4276 340
0 1 0 1 1 0 0 1 1 1 1 1...

output:

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

result:

ok orz (15 test cases)

Test #13:

score: 0
Accepted
time: 84ms
memory: 19036kb

input:

35
2003 92
1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 1 0 1 0 0 0 0 1 1 0 0 0 0 1 0 0 1 0 1 1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 0 1 0 0 0 0 1 0 0 1 1 1 1 0 1 1 1 0 1 1 0 1 0 0 0 0 0 0 0 0
2282 24
0 1 1 1 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 1 0 1 1 1
1490 29
0 1 0 0 1 0 0 0 0 1 1 1 0 1 1 0 1 0 0 0 1...

output:

2023
1 9 1
9 10 3
10 11 10
11 12 16
12 13 20
13 14 22
14 15 24
15 16 29
16 17 30
17 18 35
18 19 38
19 20 40
20 21 41
21 22 42
22 23 51
23 24 56
24 25 61
25 26 62
26 27 64
27 28 69
28 29 72
29 30 73
30 31 74
31 32 75
32 33 77
33 34 78
34 35 79
35 36 81
36 37 82
37 2 84
1 38 1
38 39 3
39 40 10
40 41 1...

result:

ok orz (35 test cases)

Test #14:

score: 0
Accepted
time: 93ms
memory: 20004kb

input:

15
5107 312
0 1 0 1 1 1 0 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 0 1 0 0 0 1 1 0 0 1 0 1 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 1 1 1 0 1 0 0 1 1 1 1 0 1 0 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 0 1 0 0 0 ...

output:

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

result:

ok orz (15 test cases)

Test #15:

score: 0
Accepted
time: 107ms
memory: 18644kb

input:

1000
64 5
1 0 1 1 1
25 4
0 0 0 0
53 11
0 0 1 1 1 1 0 1 1 1 0
69 10
0 0 0 0 0 0 1 1 0 0
23 3
1 1 0
103 13
0 1 1 1 0 0 1 0 1 1 0 0 0
104 7
0 0 0 0 0 0 0
72 9
0 0 0 0 0 1 0 0 1
144 12
1 0 1 1 1 0 1 1 0 1 0 0
23 6
0 1 1 0 0 0
137 14
0 0 1 0 0 0 0 0 0 1 1 0 0 0
56 9
1 1 0 1 1 1 1 0 1
52 7
0 0 0 0 0 0 0
3...

output:

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

result:

ok orz (1000 test cases)

Test #16:

score: 0
Accepted
time: 103ms
memory: 18752kb

input:

300
259 9
0 0 0 0 1 0 0 1 0
68 11
1 0 1 1 1 1 1 0 1 0 1
52 9
1 0 0 1 1 0 0 1 0
339 25
1 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 1 0 1 1 1 1 0 0
871 34
1 0 0 1 1 1 0 1 1 1 1 0 1 1 0 0 0 0 1 1 0 1 0 1 1 1 1 1 1 1 1 0 0 1
152 8
0 1 1 0 0 1 0 1
199 7
1 1 1 1 1 1 1
74 9
1 1 0 0 0 1 1 1 0
258 30
0 0 1 0 0 1 1 1 0...

output:

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

result:

ok orz (300 test cases)

Test #17:

score: 0
Accepted
time: 95ms
memory: 19080kb

input:

100
1046 22
1 0 0 1 0 0 0 0 1 1 1 1 0 1 0 0 1 0 0 1 0 0
153 18
1 0 0 1 1 0 0 0 1 1 1 1 1 0 1 1 0 0
1068 30
0 1 0 1 0 1 0 1 1 1 0 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 0 1 1
326 20
1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1
927 28
0 1 1 1 0 0 1 0 1 0 0 1 0 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1
2382 56
1 1 1 1 0 0 1 1...

output:

1091
1 12 1
12 13 4
13 14 9
14 15 10
15 16 11
16 17 12
17 18 14
18 19 17
19 2 20
1 20 1
20 21 4
21 22 9
22 23 10
23 24 11
24 25 12
25 26 14
26 27 17
27 3 20
1 28 1
28 29 4
29 30 9
30 31 10
31 32 11
32 33 12
33 34 14
34 35 17
35 4 20
1 36 1
36 37 4
37 38 9
38 39 10
39 40 11
40 41 12
41 42 14
42 43 17...

result:

ok orz (100 test cases)

Test #18:

score: 0
Accepted
time: 92ms
memory: 19316kb

input:

50
1661 20
0 1 1 1 1 1 0 0 1 1 1 1 1 0 1 1 0 1 1 1
1602 45
0 0 1 0 1 1 1 1 0 1 0 0 1 1 0 1 1 0 0 0 1 0 0 0 0 1 1 1 1 1 1 1 0 1 0 0 0 1 1 0 0 0 1 0 1
124 7
0 1 0 1 1 1 1
2537 19
0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1
4030 93
1 0 0 1 0 1 0 1 0 0 0 1 1 1 0 0 1 1 1 1 0 1 0 1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 0...

output:

1738
1 15 2
15 16 3
16 17 4
17 18 5
18 19 6
19 20 9
20 21 10
21 22 11
22 23 12
23 24 13
24 25 15
25 26 16
26 27 18
27 28 19
28 2 20
1 29 2
29 30 3
30 31 4
31 32 5
32 33 6
33 34 9
34 35 10
35 36 11
36 37 12
37 38 13
38 39 15
39 40 16
40 41 18
41 42 19
42 3 20
1 43 2
43 44 3
44 45 4
45 46 5
46 47 6
47...

result:

ok orz (50 test cases)

Test #19:

score: 0
Accepted
time: 89ms
memory: 19840kb

input:

20
7855 37
1 0 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 0 0 0 1 0 1 1 1 0 1 0 1
4327 92
0 1 1 1 1 1 1 1 1 0 1 1 1 0 0 1 1 0 0 1 1 1 1 0 1 0 1 1 1 0 0 1 0 1 1 0 0 1 0 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 1 1 1 0 0 1 0 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1
4125 64
1 1 1 1 1 1 1 0...

output:

8058
1 22 1
22 23 3
23 24 4
24 25 5
25 26 7
26 27 8
27 28 10
28 29 11
29 30 12
30 31 13
31 32 14
32 33 15
33 34 16
34 35 17
35 36 18
36 37 20
37 38 22
38 39 23
39 40 24
40 41 25
41 42 29
42 43 31
43 44 32
44 45 33
45 46 35
46 2 37
1 47 1
47 48 3
48 49 4
49 50 5
50 51 7
51 52 8
52 53 10
53 54 11
54 5...

result:

ok orz (20 test cases)

Test #20:

score: 0
Accepted
time: 101ms
memory: 20916kb

input:

10
1446 13
1 0 1 0 0 0 0 0 0 0 0 0 0
19759 95
0 0 0 0 0 1 1 1 1 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 0 0
13321 134
0 0 1 0 1 0 0 1 0 1 0 1 1 1 1 1 1 1 0 0 1 1 1 0 0 0 1 ...

output:

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

result:

ok orz (10 test cases)

Test #21:

score: 0
Accepted
time: 97ms
memory: 23512kb

input:

3
41501 278
0 0 1 0 1 1 0 1 1 1 0 0 1 0 0 0 0 0 1 0 0 0 0 1 1 0 1 0 0 0 1 0 0 0 0 1 0 0 1 1 1 0 1 0 0 1 0 1 0 0 0 1 1 0 0 0 1 1 0 0 1 1 0 0 1 0 1 1 1 1 0 1 1 1 0 0 1 1 0 1 0 0 1 1 1 1 0 1 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 1 0 0 1 0 0 1 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 1 1 1 1 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 ...

output:

41643
1 19 3
19 20 5
20 21 6
21 22 8
22 23 9
23 24 10
24 25 13
25 26 19
26 27 24
27 28 25
28 29 27
29 30 31
30 31 36
31 32 39
32 33 40
33 34 41
34 35 43
35 36 46
36 37 48
37 38 52
38 39 53
39 40 57
40 41 58
41 42 61
42 43 62
43 44 65
44 45 67
45 46 68
46 47 69
47 48 70
48 49 72
49 50 73
50 51 74
51 ...

result:

ok orz (3 test cases)

Test #22:

score: 0
Accepted
time: 180ms
memory: 35684kb

input:

1
100000 2
0 0

output:

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

result:

ok orz (1 test case)

Test #23:

score: 0
Accepted
time: 180ms
memory: 40936kb

input:

1
100000 2
0 1

output:

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

result:

ok orz (1 test case)

Test #24:

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

input:

1
100000 2
1 1

output:

199108
1 447 1
447 2 2
1 448 1
448 3 2
1 449 1
449 4 2
1 450 1
450 5 2
1 451 1
451 6 2
1 452 1
452 7 2
1 453 1
453 8 2
1 454 1
454 9 2
1 455 1
455 10 2
1 456 1
456 11 2
1 457 1
457 12 2
1 458 1
458 13 2
1 459 1
459 14 2
1 460 1
460 15 2
1 461 1
461 16 2
1 462 1
462 17 2
1 463 1
463 18 2
1 464 1
464 ...

result:

ok orz (1 test case)

Test #25:

score: 0
Accepted
time: 77ms
memory: 18372kb

input:

1
100000 2
0 2

output:

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

result:

ok orz (1 test case)

Test #26:

score: 0
Accepted
time: 96ms
memory: 27088kb

input:

1
100000 100000
100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 1000...

output:

99999
1 2 100000
1 3 100000
1 4 100000
1 5 100000
1 6 100000
1 7 100000
1 8 100000
1 9 100000
1 10 100000
1 11 100000
1 12 100000
1 13 100000
1 14 100000
1 15 100000
1 16 100000
1 17 100000
1 18 100000
1 19 100000
1 20 100000
1 21 100000
1 22 100000
1 23 100000
1 24 100000
1 25 100000
1 26 100000
1 ...

result:

ok orz (1 test case)

Extra Test:

score: 0
Extra Test Passed