QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#455338#8818. Colorful Graph 3zhoukangyangAC ✓43ms49048kbC++144.3kb2024-06-26 09:48:442024-06-26 09:48:45

Judging History

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

  • [2024-06-26 09:48:45]
  • 评测
  • 测评结果:AC
  • 用时:43ms
  • 内存:49048kb
  • [2024-06-26 09:48:44]
  • 提交

answer

#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long
#define sz(a) ((int) (a).size())
#define me(a, x) memset(a, x, sizeof(a))
#define vi vector < int > 
#define pb emplace_back
#define ld long double
using namespace std;
const int N = 1 << 20;
int n, k, a[N];
pair<int,int>pr[N];
int cnt[N];
struct edge {
	int u, v, w;
	edge (int U = 0, int V = 0, int W = 0) {
		u = U;
		v = V;
		w = W;
	}
};
int f[N], ids[N], mv[N];
inline int find(int x) {
	return f[x] == x ? x : f[x] = find(f[x]);
}
int dis[N];
vector<pair<int,int>>edd[N];
bool check(vector<edge>ans) {
	L(v, 1, k) {
		L(i, 1, n) {
			edd[i].clear();
		}
		for(auto&u:ans)
			edd[u.u].pb(u.v,u.w == v), 
			edd[u.v].pb(u.u,u.w == v);
		L(u, 1, n) {
			deque<int>q;
			vi dis(n + 1);
			L(i, 1, n) dis[i] = 1e9;
			q.push_front(u);
			dis[u] = 0;
			while(!q.empty()) {
				int u = q.front();
				q.pop_front();
				for(auto&v:edd[u]){
					int to = v.first;
					if(dis[to]>dis[u]+v.second){
						dis[to]=dis[u]+v.second;
						if(v.second==0)q.push_front(to);
						else q.push_back(to);
					}
				}
			}
			// L(i, 1, n)cout<<dis[i];
			// cout<<endl;
			L(i, 1, n) if(dis[i] > a[v]) return cerr << "cuo " << v << ' ' << u << ' ' << i << ", " << dis[i] << endl, 0;
		}
	}
	return 1;
}
mt19937 rng;
int rad(int l, int r) {
	return rng() % (r - l + 1) + l;
}
void Main() {
	n = rad(2, 20), k = rad(2, 3);
	cin >> n >> k;
	L(i, 1, k) {
		a[i] = rad(0, 1);
		cin >> a[i];
		pr[i]={a[i],i};
	}
	L(v, 1, k) {
		if(a[v] >= 2) {
			cout << n - 1 << '\n';
			L(i, 1, n - 1)cout << i << ' ' << n << ' ' << v << '\n';
			cout << '\n';
			return;
		}
	}
	cnt[0] = 0;
	cnt[1] = 0;
	cnt[2] = 0;
	sort(pr + 1, pr + k + 1);
	reverse(pr + 1, pr + k + 1);
	L(i, 1, k) 
		mv[i] = pr[i].second, 
		++cnt[pr[i].first];
	vector<edge>ans,nans;
	L(r, 0, n * 2) {
		// non-tree = y + x * (x - 1) / 2 - x
		int x = 0;
		while(x * (x - 1) / 2 <= r) {
			++x;
		}
		int y = r - (x - 1) * (x - 2) / 2;
		int es = r * cnt[0] + (x * (x - 1) / 2 + y) * cnt[1];
		if(es < n - 1 + r) {
			continue;
		}
		// cout << "r = " << r << ' ' << x << ' ' << y << ' ' << es << ' ' << (n - 1 + r) << endl;
		int xn = 1;
		if(cnt[1] > 1) {
			xn = x * (x + 1) / 2;
			vi delta(x + 1);
			delta[0] = 0;
			L(i, 1, x) {
				if(i & 1) delta[i] = i % x;
				else delta[i] = x - i;
			}
			L(i, 0, x)
				delta[i] = (delta[i] % x + x) % x;
			// L(i, 1, x)
			// 	cout << delta[i] << ", ";
			// cout << endl;
			auto id = [&] (int i, int j) -> int {
				int p = (i - 1) * x + j + 1;
				return p > xn ? 0 : p;
			};
			L(i, 1, x) 
				L(j, 0, x - 1) 
					if(id(i, j) && id(i + 1, j)) 
						ans.pb(edge(id(i, j), id(i + 1, j), 1));
			L(i, 1, x) 
				L(j, 0, x - 1) 
					if(id(i, j) && id(i + 1, (j + delta[i]) % x))
						ans.pb(edge(id(i, j), id(i + 1, (j + delta[i]) % x), 2));
		} else if(cnt[1]) {
			xn = x;
			L(i, 1, xn)
				L(j, i + 1, xn)
					ans.pb(edge(i, j, 1));
		} else {
			xn = 1;
			L(t, 1, r) {
				L(i, 1, k) ans.pb(xn + i - 1, xn + i % k, i);
				xn += k - 1;
			}
			goto ovo;
		}
		L(j, 0, sz(ans) - 1) {
			auto u = ans[j];
			if(u.w != 1) {
				nans.pb(u);
				continue;
			}
			int lst = u.u;
			L(k, 3, cnt[1]) 
				++xn, nans.pb(lst, xn, k), lst = xn;
			L(k, 1, cnt[0]) if(j >= x - 1)
				++xn, nans.pb(lst, xn, k + cnt[1]), lst = xn;
			nans.pb(edge(lst, u.v, u.w));
		}
		swap(ans,nans), nans.clear();
		L(t, 1, y) {
			L(i, 1, k) ans.pb(xn + i - 1, xn + i % k, i);
			xn += k - 1;
		}
		ovo:;
		L(i, 1, xn) 
			f[i] = i;
		L(r, 0, xn - n - 1) {
			auto u = ans[r];
			f[find(u.u)] = find(u.v);
		}
		int tot = 0;
		L(i, 1, xn) 
			if(f[i] == i) ids[i] = ++tot;
		for(auto u : ans)
			if(find(u.u) != find(u.v))
				nans.pb(ids[find(u.u)], ids[find(u.v)], u.w);
		swap(ans, nans), nans.clear();
		break;
	}
	cout << sz(ans) << '\n';
	for(auto&u:ans)
		u.w = mv[u.w], cout << u.u << ' ' << u.v << ' ' << u.w << '\n';
	// if(!check(ans)) {
	// 	cout << n << ' ' << k << endl;
	// 	L(i, 1, k)cout<<a[i];
	// 	cout<<endl;
	// 	exit(0);
	// }
}
int main() {
	ios :: sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t; cin >> t; while(t--) Main();
	return 0;
}
/*
1
6 2
1 1
*/

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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


result:

ok orz (3 test cases)

Test #2:

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

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 1
4
1 2 2
2 1 1
2 3 2
3 2 1
3
1 2 2
1 3 1
3 2 2
2
1 3 2
2 3 1
3
1 2 3
2 3 2
3 1 1
3
1 2 3
2 3 2
3 1 1
2
1 3 3
2 3 1
2
3 2 3
1 2 2
6
1 2 2
2 1 1
2 3 2
3 2 1
3 4 2
4 3 1
4
1 2 1
1 3 1
2 4 2
4 3 1
4
1 4 2
2 3 1
3 4 1
1 2 1
5
1 2 2
2 1 1
2 3 3
3 4 2
4 2 1
4
1 2 3
1 3 2
3 4 1
...

result:

ok orz (4645 test cases)

Test #3:

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

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 2
2 12 2
3 13 2
4 14 2
5 15 2
6 16 2
7 17 2
8 18 2
9 19 2
10 20 2
11 21 2
12 22 2
13 23 2
14 24 2
15 25 2
16 26 2
17 27 2
18 28 2
19 29 2
20 30 2
21 31 2
22 32 2
23 33 2
24 34 2
25 35 2
26 36 2
27 37 2
28 38 2
29 39 2
30 40 2
31 41 2
32 42 2
33 43 2
34 44 2
35 45 2
36 46 2
37 47 2
38 48 2
39...

result:

ok orz (2379 test cases)

Test #4:

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

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
36 8 3
1 37 1
37 9 3
2 38 1
38 10 3
3 39 1
39 11 3
4 40 1
40 12 3
5 41 1
41 13 3
6 42 1
42 14 3
7 43 1
43 15 3
8 44 1
44 16 3
9 45 1
45 17 3
10 46 1
46 18 3
11 47 1
47 19 3
12 48 1
48 20 3
13 49 1
49 21 3
14 50 1
50 22 3
15 51 1
51 23 3
16 52 1
52 24 3
17 53 1
53 25 3
18 54 1
54 26 3
19 55 1
55 2...

result:

ok orz (1244 test cases)

Test #5:

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

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
2 3 2
3 2 1
3 4 2
4 3 1
4 5 2
5 4 1
5 6 2
6 5 1
6 7 2
7 6 1
7 8 2
8 7 1
8 9 2
9 8 1
9 10 2
10 9 1
10 11 2
11 10 1
11 12 2
12 11 1
12 13 2
13 12 1
13 14 2
14 13 1
14 15 2
15 14 1
15 16 2
16 15 1
16 17 2
17 16 1
17 18 2
18 17 1
18 19 2
19 18 1
19 20 2
20 19 1
20 21 2
21 20 1
21 22 2
22...

result:

ok orz (739 test cases)

Test #6:

score: 0
Accepted
time: 23ms
memory: 42588kb

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 3
16 17 1
17 2 2
1 18 3
18 19 1
19 3 2
1 20 3
20 21 1
21 4 2
1 22 3
22 23 1
23 5 2
1 24 3
24 25 1
25 6 2
1 26 3
26 27 1
27 7 2
1 28 3
28 29 1
29 8 2
1 30 3
30 31 1
31 9 2
1 32 3
32 33 1
33 10 2
1 34 3
...

result:

ok orz (495 test cases)

Test #7:

score: 0
Accepted
time: 23ms
memory: 41848kb

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 2
2 24 2
3 25 2
4 26 2
5 27 2
6 28 2
7 29 2
8 30 2
9 31 2
10 32 2
11 33 2
12 34 2
13 35 2
14 36 2
15 37 2
16 38 2
17 39 2
18 40 2
19 41 2
20 42 2
21 43 2
22 44 2
23 45 2
24 46 2
25 47 2
26 48 2
27 49 2
28 50 2
29 51 2
30 52 2
31 53 2
32 54 2
33 55 2
34 56 2
35 57 2
36 58 2
37 59 2
38 60 2
3...

result:

ok orz (339 test cases)

Test #8:

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

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 5529
2 3 5528
3 4 5527
4 5 5526
5 6 5525
6 7 5524
7 8 5523
8 9 5522
9 10 5521
10 11 5520
11 12 5519
12 13 5518
13 14 5517
14 15 5516
15 16 5515
16 17 5514
17 18 5513
18 19 5512
19 20 5511
20 21 5510
21 22 5509
22 23 5508
23 24 5507
24 25 5506
25 26 5505
26 27 5504
27 28 5503
28 29 5502
29 3...

result:

ok orz (15 test cases)

Test #9:

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

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
595 596 3
596 597 2
597 598 1
598 34 6
1 599 4
599 600 3
600 601 2
601 602 1
602 35 6
2 603 4
603 604 3
604 605 2
605 606 1
606 36 6
3 607 4
607 608 3
608 609 2
609 610 1
610 37 6
4 611 4
611 612 3
612 613 2
613 614 1
614 38 6
5 615 4
615 616 3
616 617 2
617 618 1
618 39 6
6 619 4
619 620 3
620...

result:

ok orz (35 test cases)

Test #10:

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

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 1712 2
1712 1713 1
1713 59 4
2 1714 2
1714 1715 1
1715 60 4
3 1716 2
1716 1717 1
1717 61 4
4 1718 2
1718 1719 1
1719 62 4
5 1720 2
1720 1721 1
1721 63 4
6 1722 2
1722 1723 1
1723 64 4
7 1724 2
1724 1725 1
1725 65 4
8 1726 2
1726 1727 1
1727 66 4
9 1728 2
1728 1729 1
1729 67 4
10 1730 2
1730 1...

result:

ok orz (15 test cases)

Test #11:

score: 0
Accepted
time: 7ms
memory: 42652kb

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 37 83
37 38 81
38 39 80
39 40 77
40 41 73
41 42 68
42 43 67
43 44 63
44 45 62
45 46 57
46 47 55
47 48 54
48 49 51
49 50 50
50 51 47
51 52 46
52 53 44
53 54 42
54 55 39
55 56 38
56 57 33
57 58 31
58 59 29
59 60 25
60 61 20
61 62 16
62 63 13
63 64 10
64 65 5
65 66 1
66 9 90
2 67 83
67 68 81
68 ...

result:

ok orz (35 test cases)

Test #12:

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

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: 7ms
memory: 42324kb

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
32 33 77
33 34 75
34 35 74
35 36 73
36 37 72
37 38 69
38 39 64
39 40 62
40 41 61
41 42 56
42 43 51
43 44 42
44 45 41
45 46 40
46 47 38
47 48 35
48 49 30
49 50 29
50 51 24
51 52 22
52 53 20
53 54 16
54 55 10
55 56 3
56 57 1
57 8 84
1 58 81
58 59 79
59 60 78
60 61 77
61 62 75
62 63 74
63 64 73
64...

result:

ok orz (35 test cases)

Test #14:

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

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
20 21 165
21 22 164
22 23 163
23 24 162
24 25 160
25 26 159
26 27 156
27 28 154
28 29 153
29 30 152
30 31 151
31 32 150
32 33 148
33 34 147
34 35 146
35 36 145
36 37 141
37 38 139
38 39 137
39 40 135
40 41 134
41 42 133
42 43 132
43 44 131
44 45 130
45 46 129
46 47 127
47 48 126
48 49 125
49 50...

result:

ok orz (15 test cases)

Test #15:

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

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
21 22 1
22 6 5
1 23 3
23 24 1
24 7 5
2 25 3
25 26 1
26 8 5
3 27 3
27 28 1
28 9 5
4 29 3
29 30 1
30 10 5
5 31 3
31 32 1
32 33 2
33 11 5
6 34 3
34 35 1
35 36 2
36 12 5
7 37 3
37 38 1
38 39 2
39 13 5
8 40 3
40 41 1
41 42 2
42 14 5
9 43 3
43 44 1
44 45 2
45 15 5
10 46 3
46 47 1
47 48 2
48 16 5
11 49 ...

result:

ok orz (1000 test cases)

Test #16:

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

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 8
2 11 8
3 40 9
40 41 7
41 42 6
42 43 4
43 44 3
44 45 2
45 46 1
46 12 8
4 47 9
47 48 7
48 49 6
49 50 4
50 51 3
51 52 2
52 53 1
53 13 8
5 54 9
54 55 7
55 56 6
56 57 4
57 58 3
58 59 2
59 60 1
60 14 8
6 61 9
61 62 7
62 63 6
63 64 4
64 65 3
65 66 2
66 67 1
67 15 8
7 68 9
68 69 7
69 70 6
70 71 4...

result:

ok orz (300 test cases)

Test #17:

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

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
65 66 10
66 67 9
67 68 4
68 69 1
69 11 20
1 70 14
70 71 12
71 72 11
72 73 10
73 74 9
74 75 4
75 76 1
76 12 20
2 77 14
77 78 12
78 79 11
79 80 10
80 81 9
81 82 4
82 83 1
83 13 20
3 84 14
84 85 12
85 86 11
86 87 10
87 88 9
88 89 4
89 90 1
90 14 20
4 91 14
91 92 12
92 93 11
93 94 10
94 95 9
95 96 ...

result:

ok orz (100 test cases)

Test #18:

score: 0
Accepted
time: 10ms
memory: 41124kb

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
104 105 13
105 106 12
106 107 11
107 108 10
108 109 9
109 110 6
110 111 5
111 112 4
112 113 3
113 114 2
114 14 20
1 115 18
115 116 16
116 117 15
117 118 13
118 119 12
119 120 11
120 121 10
121 122 9
122 123 6
123 124 5
124 125 4
125 126 3
126 127 2
127 15 20
2 128 18
128 129 16
129 130 15
130 1...

result:

ok orz (50 test cases)

Test #19:

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

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
231 232 17
232 233 16
233 234 15
234 235 14
235 236 13
236 237 12
237 238 11
238 239 10
239 240 8
240 241 7
241 242 5
242 243 4
243 244 3
244 245 1
245 21 37
1 246 33
246 247 32
247 248 31
248 249 29
249 250 25
250 251 24
251 252 23
252 253 22
253 254 20
254 255 18
255 256 17
256 257 16
257 258...

result:

ok orz (20 test cases)

Test #20:

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

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 3
2 18 3
3 19 3
4 20 3
5 21 3
6 22 3
7 23 3
8 24 3
9 25 3
10 26 3
11 27 3
12 28 3
13 29 3
14 30 3
15 136 13
136 137 12
137 138 11
138 139 10
139 140 9
140 141 8
141 142 7
142 143 6
143 144 5
144 145 4
145 146 2
146 31 3
16 147 13
147 148 12
148 149 11
149 150 10
150 151 9
151 152 8
152 153...

result:

ok orz (10 test cases)

Test #21:

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

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
170 171 174
171 172 171
172 173 166
173 174 165
174 175 162
175 176 161
176 177 159
177 178 157
178 179 156
179 180 154
180 181 152
181 182 148
182 183 145
183 184 137
184 185 133
185 186 132
186 187 129
187 188 128
188 189 127
189 190 126
190 191 120
191 192 114
192 193 113
193 194 110
194 19...

result:

ok orz (3 test cases)

Test #22:

score: 0
Accepted
time: 43ms
memory: 49048kb

input:

1
100000 2
0 0

output:

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

result:

ok orz (1 test case)

Test #23:

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

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: 30ms
memory: 46164kb

input:

1
100000 2
1 1

output:

199108
1 447 2
2 448 2
3 449 2
4 450 2
5 451 2
6 452 2
7 453 2
8 454 2
9 455 2
10 456 2
11 457 2
12 458 2
13 459 2
14 460 2
15 461 2
16 462 2
17 463 2
18 464 2
19 465 2
20 466 2
21 467 2
22 468 2
23 469 2
24 470 2
25 471 2
26 472 2
27 473 2
28 474 2
29 475 2
30 476 2
31 477 2
32 478 2
33 479 2
34 48...

result:

ok orz (1 test case)

Test #25:

score: 0
Accepted
time: 10ms
memory: 33336kb

input:

1
100000 2
0 2

output:

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

result:

ok orz (1 test case)

Test #26:

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

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 100000 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 ...

result:

ok orz (1 test case)

Extra Test:

score: 0
Extra Test Passed