QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#502423#2645. Collapsemakrav5 5317ms34872kbC++204.4kb2024-08-03 05:24:182024-08-03 05:24:18

Judging History

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

  • [2024-08-03 05:24:18]
  • 评测
  • 测评结果:5
  • 用时:5317ms
  • 内存:34872kb
  • [2024-08-03 05:24:18]
  • 提交

answer

#include "collapse.h"
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define pb push_back
#define ff first
#define sc second

const int K = 600;

struct dsu {
	int n, cmp;
	vector<int> par, siz;
	dsu() = default;
	dsu(int n_) {
		cmp = 0;
		n = n_;
		par.assign(n, 0);
		iota(all(par), 0);
		siz.assign(n, 1);
	}

	int get(int v) {
		return (par[v] == v ? v : par[v] = get(par[v]));
	}

	void merge(int u, int v) {
		u = get(u);
		v = get(v);
		if (u == v) return;
		cmp--;
		if (siz[v] > siz[u]) swap(u, v);
		par[v] = u;
		siz[u] += siz[v];
	}
};		

std::vector<int> simulateCollapse(
	int N,
	std::vector<int> T,
	std::vector<int> X,
	std::vector<int> Y,
	std::vector<int> W,
	std::vector<int> P
) {
	int n = N;
	int c = sz(X);
	vector<vector<pair<int, int>>> qrs(c);
	for (int i = 0; i < sz(W); i++) {
		qrs[W[i]].pb({P[i], i});
	}
	vector<int> ans(sz(W));
	vector<vector<int>> gr(n);
	vector<int> used1(n), used_dfs(n);
	int step = 0;
	for(int i = 0; i < c; i++){
		if(X[i]>Y[i])swap(X[i],Y[i]);
	}
	vector<int> prev(c, -1);
	unordered_map<ll, int> lpos;
	for (int i = 0; i < c; i++) {
		if (lpos.find(X[i] * 1ll * n + Y[i]) != lpos.end()) prev[i] = lpos[X[i] * 1ll * n + Y[i]];
		lpos[X[i] * 1ll * n + Y[i]] = i;
	}
	vector<int> USED(c, 0);
	for (int i = 0; i < c; i += K) {
		unordered_set<ll> ch_edg;
		unordered_set<ll> LOL;
		for (int j = i; j < min(c, i + K); j++) {
			if (T[j] == 0) {
				USED[j] = 1;
			} else if (prev[j] != -1) USED[prev[j]] = 0;
			if (T[j] == 1 && ch_edg.find(X[j] * 1ll * N + Y[j]) == ch_edg.end()) {
				LOL.insert(X[j] * 1ll * n + Y[j]);
			}
			ch_edg.insert(X[j] * 1ll * N + Y[j]);
		}
		vector<vector<int>> by_rig(n), by_left(n);
		for (int j = i - 1; j >= 0; j--) {
			if (USED[j]) {
				by_rig[max(X[j], Y[j])].pb(min(X[j], Y[j]));
				by_left[min(X[j], Y[j])].pb(max(X[j], Y[j]));
			}
		}
		vector<vector<pair<int, int>>> qnums(n - 1);
		for (int j = i; j < min(c, i + K); j++) {
			for (auto &[el, num] : qrs[j]) {
				qnums[el].pb({j, num});
			}
		}
		dsu d(n);
		for (int I = 0; I < n - 1; I++) {
			d.cmp++;
			for (auto &u : by_rig[I]) d.merge(u, I);
			for (auto &[time, numb] : qnums[I]) {
				step++;
				unordered_set<ll> add_edges = LOL;
				for (int j = i; j <= time; j++) {
					if (T[j] == 0) {
						add_edges.insert(X[j] * 1ll * n + Y[j]);
					} else {
						add_edges.erase(X[j] * 1ll * n + Y[j]);
					}
				}
				vector<int> rdfs;
				for (auto E : add_edges) {
					ll u = E / n, v = E % n;
					if (max(u, v) <= I) {
						u = d.get(u);
						v = d.get(v);
						if (u != v) {
							if (used1[u] != step) gr[u].clear();
							if (used1[v] != step) gr[v].clear();
							used1[u] = step;
							used1[v] = step;
							gr[u].pb(v);
							gr[v].pb(u);
							rdfs.pb(u);
						}
					}
				}
				int ccmp = d.cmp;
				auto dfs = [&](int v, auto&&dfs) -> void {
					used_dfs[v] = step;
					for (auto &u : gr[v]) {
						if (used_dfs[u] != step) {
							ccmp--;
							dfs(u, dfs);
						}
					}
				};
				for (auto &u : rdfs) {
					if (used_dfs[u] != step) {
						dfs(u, dfs);
					}
				}
				ans[numb] += ccmp;
			}
		}
		iota(all(d.par), 0);
		d.siz.assign(n, 1);
		d.cmp = 0;
		for (int I = n - 1; I >= 1; I--) {
			d.cmp++;
			for (auto &u : by_left[I]) d.merge(u, I);
			for (auto &[time, numb] : qnums[I - 1]) {
				step++;
				unordered_set<ll> add_edges = LOL;
				for (int j = i; j <= time; j++) {
					if (T[j] == 0) {
						add_edges.insert(X[j] * 1ll * n + Y[j]);
					} else {
						add_edges.erase(X[j] * 1ll * n + Y[j]);
					}
				}
				vector<int> rdfs;
				for (auto E : add_edges) {
					int u = E / n, v = E % n;
					if (min(u, v) >= I) {
						u = d.get(u);
						v = d.get(v);
						if (u != v) {
							if (used1[u] != step) gr[u].clear();
							if (used1[v] != step) gr[v].clear();
							used1[u] = step;
							used1[v] = step;
							gr[u].pb(v);
							gr[v].pb(u);
							rdfs.pb(u);
						}
					}
				}
				int ccmp = d.cmp;
				auto dfs = [&](int v, auto&&dfs) -> void {
					used_dfs[v] = step;
					for (auto &u : gr[v]) {
						if (used_dfs[u] != step) {
							ccmp--;
							dfs(u, dfs);
						}
					}
				};
				for (auto &u : rdfs) {
					if (used_dfs[u] != step) {
						dfs(u, dfs);
					}
				}
				ans[numb] += ccmp;
			}
		}
	}
	return ans;
}

詳細信息

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 40ms
memory: 4320kb

input:

2 5000 5000
0 0 1
1 0 1
0 0 1
1 1 0
0 1 0
1 1 0
0 1 0
1 0 1
0 1 0
1 0 1
0 0 1
1 0 1
0 1 0
1 1 0
0 1 0
1 1 0
0 0 1
1 0 1
0 1 0
1 0 1
0 1 0
1 0 1
0 0 1
1 0 1
0 1 0
1 1 0
0 0 1
1 1 0
0 1 0
1 1 0
0 1 0
1 1 0
0 1 0
1 0 1
0 1 0
1 0 1
0 0 1
1 0 1
0 0 1
1 0 1
0 0 1
1 0 1
0 1 0
1 1 0
0 1 0
1 0 1
0 0 1
1 1 0
...

output:

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

result:

ok 5000 lines

Test #5:

score: 5
Accepted
time: 54ms
memory: 4312kb

input:

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

output:

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

result:

ok 5000 lines

Test #6:

score: 5
Accepted
time: 167ms
memory: 4888kb

input:

100 4950 5000
0 38 3
0 56 61
0 87 71
0 64 10
0 92 60
0 44 11
0 3 7
0 81 41
0 43 72
0 73 61
0 77 23
0 63 20
0 64 16
0 11 37
0 51 97
0 80 10
0 56 2
0 76 42
0 69 74
0 26 28
0 40 37
0 5 35
0 25 22
0 95 35
0 89 34
0 3 88
0 26 17
0 40 8
0 8 79
0 48 6
0 18 94
0 76 75
0 44 22
0 30 94
0 50 41
0 92 45
0 11 20...

output:

2
2
2
2
2
2
2
2
2
3
2
2
5
2
2
7
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
4
2
2
3
2
2
2
68
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
7
3
2
2
2
2
2
2
2
2
2
13
2
2
2
9
9
71
3
2
7
2
2
2
13
2
9
3
2
2
2
2
2
3
2
2
8
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
7
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 5000 lines

Test #7:

score: 5
Accepted
time: 2ms
memory: 4652kb

input:

5000 1 5000
0 4285 4296
0 174
0 1012
0 3399
0 3238
0 1816
0 4133
0 3019
0 4260
0 2930
0 4630
0 1081
0 2725
0 4468
0 3870
0 1078
0 2021
0 2532
0 4271
0 3007
0 4647
0 3279
0 1541
0 4631
0 2309
0 2625
0 1049
0 3253
0 1274
0 4488
0 4202
0 885
0 2684
0 2656
0 1036
0 2263
0 2196
0 4410
0 1974
0 2852
0 113...

output:

4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
...

result:

ok 5000 lines

Test #8:

score: 5
Accepted
time: 4ms
memory: 4596kb

input:

5000 13 5000
0 1437 2917
0 4619 3686
0 4797 4454
0 3445 4933
0 561 1988
1 4797 4454
1 1988 561
0 1409 339
0 2874 2680
0 1266 4421
0 803 4698
0 3886 2422
1 3686 4619
1 2249
7 4184
3 4331
3 1568
4 4846
1 3533
12 2754
6 232
4 3193
9 2272
7 2268
10 4048
8 4216
6 3985
0 4840
12 3065
5 2887
12 592
2 1092
...

output:

4999
4998
4998
4997
4996
4998
4998
4997
4995
4996
4997
4997
4997
4999
4999
4996
4997
4994
4997
4996
4999
4997
4996
4995
4995
4997
4998
4996
4998
4996
4999
4998
4995
4996
4997
4996
4998
4996
4994
4996
4996
4998
4997
4996
4999
4998
4993
4997
4997
4998
4997
4999
4996
4992
4998
5000
4993
4998
4997
4997
...

result:

ok 5000 lines

Test #9:

score: 5
Accepted
time: 58ms
memory: 5344kb

input:

5000 5000 5000
0 975 2469
1 2469 975
0 3116 3798
0 2112 4747
0 1861 3986
1 3798 3116
0 2915 1795
0 1550 3770
0 433 3583
1 4747 2112
0 1153 4006
0 2233 3268
1 4006 1153
0 4456 1149
0 4 655
0 4058 2897
1 2915 1795
0 1725 1423
0 2206 1507
1 4058 2897
1 1423 1725
1 4 655
1 433 3583
0 4821 1327
0 1407 24...

output:

4961
4981
4994
4986
4974
4993
4987
4987
4981
4998
4986
4994
4997
4974
4986
4998
5000
4988
4993
4982
4993
4984
4993
4965
4996
4968
4997
4963
4986
4996
4996
4982
4996
4993
4998
4992
4972
4999
4999
4991
4996
5000
4999
4987
4961
4991
4993
4979
4994
4981
4999
4983
4989
4975
4996
4993
4989
4998
5000
4991
...

result:

ok 5000 lines

Test #10:

score: 5
Accepted
time: 148ms
memory: 5432kb

input:

5000 5000 5000
0 3449 1421
1 1421 3449
0 253 3884
1 253 3884
0 2908 3268
0 4948 3871
0 2908 3908
1 2908 3268
0 4186 1306
1 3871 4948
1 2908 3908
1 4186 1306
0 3741 2117
0 1391 4186
0 778 509
0 1597 2117
1 4186 1391
0 2908 4020
1 4020 2908
1 1597 2117
0 4948 3179
0 196 4186
0 2117 1579
1 778 509
1 41...

output:

4464
4508
4509
4635
4763
4516
4646
4766
4525
4772
4789
4388
4910
4779
4907
4409
4907
4724
4669
4873
4850
4545
4383
4438
4509
4850
4537
4859
4725
4828
4532
4826
4629
4299
4957
4477
4992
4543
4805
4656
4996
4832
4465
4729
4923
4717
4364
4564
4456
4388
4680
4534
4800
4457
4734
4747
4793
4740
4926
4532
...

result:

ok 5000 lines

Test #11:

score: 5
Accepted
time: 192ms
memory: 5416kb

input:

5000 5000 5000
0 1900 2340
0 4130 1922
0 4969 1233
0 2827 3942
0 3982 1431
0 3486 3980
0 3997 2929
0 2449 3118
0 3060 2285
0 971 2628
0 1938 1814
0 240 4209
0 2249 2974
0 2372 1784
0 3729 4064
0 3636 2763
0 3518 2722
0 3948 2501
0 200 1592
0 3783 1348
0 3343 1642
0 4576 3200
0 1460 1735
0 3938 2178
...

output:

4740
2997
3403
4239
2531
4424
2465
2519
3310
2420
3799
1923
3777
2055
3063
3748
2640
4713
4792
3263
3068
3434
4461
2712
3717
1634
1751
2536
4249
4870
4382
3349
3591
4942
3143
2777
4796
4931
1675
3006
3737
3628
1197
2662
2059
3752
3720
3887
4469
4127
4526
1813
4369
4559
4582
3506
4054
3771
3815
2561
...

result:

ok 5000 lines

Test #12:

score: 5
Accepted
time: 183ms
memory: 5408kb

input:

5000 5000 5000
0 976 1107
0 2771 4969
0 976 3008
0 155 976
0 3048 3929
0 4548 2155
0 3811 3048
0 4982 3048
0 4308 976
0 3048 2390
0 3048 3912
0 3250 2339
0 2660 976
0 976 2307
0 3048 4635
0 3048 1329
0 952 1913
0 4996 8
0 3717 976
0 2022 4914
0 3048 457
0 976 740
0 976 991
0 2989 3048
0 976 4925
0 3...

output:

3578
2489
4843
4622
3701
3077
4881
2925
2394
2513
3902
2867
4299
4769
4021
2773
3530
3958
4462
4306
4707
2657
4068
4490
2105
3627
3887
2680
4428
4258
3269
4525
4126
2759
3107
4294
2508
2012
3755
3588
4804
3768
3122
2763
3570
1818
3020
4546
3826
3357
2310
3197
3512
3293
3145
3089
4023
3132
4052
2462
...

result:

ok 5000 lines

Subtask #2:

score: 0
Time Limit Exceeded

Test #13:

score: 30
Accepted
time: 25ms
memory: 7376kb

input:

2 1 100000
0 1 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
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
5
4
4
4
4
4
4
5
5
5
4
5
4
4
5
5
4
4
5
4
4
4
5
4
5
4
5
5
4
4
4
5
5
4
4
5
5
4
5
4
4
5
5
5
5
4
4
4
4
4
4
5
5
4
4
5
4
5
5
5
5
4
5
4
4
4
5
5
...

result:

ok 100000 lines

Test #15:

score: 30
Accepted
time: 1134ms
memory: 13684kb

input:

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

output:

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

result:

ok 100000 lines

Test #16:

score: 30
Accepted
time: 161ms
memory: 7504kb

input:

10 45 100000
0 9 7
0 0 6
0 3 2
0 7 8
0 3 7
0 1 0
0 2 8
0 8 3
0 0 4
0 8 4
0 7 0
0 6 1
0 0 3
0 8 1
0 5 8
0 5 1
0 7 6
0 4 2
0 9 3
0 0 9
0 3 1
0 3 6
0 5 3
0 9 8
0 2 9
0 7 1
0 4 6
0 0 8
0 9 5
0 6 2
0 4 5
0 4 7
0 0 2
0 6 9
0 5 6
0 5 0
0 8 6
0 1 9
0 1 2
0 1 4
0 4 3
0 9 4
0 5 7
0 2 7
0 5 2
1 6
14 6
26 6
6 6...

output:

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

result:

ok 100000 lines

Test #17:

score: 30
Accepted
time: 1887ms
memory: 14312kb

input:

100 100000 100000
0 12 26
1 12 26
0 44 29
1 44 29
0 21 32
1 21 32
0 81 30
1 30 81
0 93 39
0 26 5
1 39 93
0 93 87
0 60 13
1 87 93
1 13 60
1 26 5
0 26 84
1 26 84
0 26 50
0 44 32
1 26 50
0 61 86
1 61 86
1 32 44
0 69 59
0 68 92
0 37 21
0 5 53
1 37 21
0 87 78
0 64 9
1 64 9
1 53 5
1 92 68
0 31 66
1 66 31
...

output:

19
25
62
11
13
61
20
31
79
83
63
50
94
9
35
31
17
17
86
56
98
9
69
38
54
91
78
11
69
30
8
41
10
33
5
45
48
70
76
80
9
59
7
58
24
15
35
97
96
46
88
38
19
38
86
18
49
70
61
14
37
58
5
91
35
23
30
29
61
56
13
55
12
63
56
74
67
40
92
12
81
14
42
29
68
93
10
10
19
84
60
32
77
67
44
96
38
98
9
13
21
97
60...

result:

ok 100000 lines

Test #18:

score: 30
Accepted
time: 2871ms
memory: 7316kb

input:

100 4950 100000
0 84 47
0 31 87
0 62 83
0 54 79
0 41 94
0 87 43
0 46 70
0 84 93
0 33 91
0 0 87
0 36 88
0 8 74
0 86 39
0 99 23
0 74 33
0 86 11
0 29 8
0 24 23
0 5 97
0 7 68
0 9 8
0 17 22
0 75 55
0 61 35
0 32 18
0 20 38
0 99 89
0 89 80
0 96 29
0 5 27
0 90 6
0 36 1
0 83 49
0 69 33
0 70 36
0 4 94
0 51 74...

output:

8
2
2
2
2
2
2
2
2
2
2
2
2
9
2
2
2
2
2
2
2
2
2
6
2
2
2
2
2
2
2
2
2
2
2
2
2
2
9
2
2
2
2
12
2
2
2
19
65
2
2
2
2
2
2
58
9
2
2
2
2
7
2
11
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
8
89
2
2
2
2
2
2
2
2
9
2
2
2
2
2
2
2
2
2
2
2
2
2
2
87
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
21
2
2
2
2
65
2
2
2
2
2
2
2
2
2
2...

result:

ok 100000 lines

Test #19:

score: 30
Accepted
time: 3123ms
memory: 19960kb

input:

1000 100000 100000
0 401 876
0 420 792
0 965 268
0 909 871
0 736 337
0 341 634
0 112 317
0 685 606
0 778 506
0 162 289
0 375 590
0 874 77
0 434 986
0 78 804
0 743 760
0 290 466
0 721 828
0 44 145
0 601 101
0 223 651
0 327 860
0 105 727
0 447 93
0 680 298
0 868 502
0 130 527
0 567 523
0 871 862
0 423...

output:

9
2
2
2
166
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
483
2
2
2
2
2
2
2
49
2
2
2
2
2
2
2
2
2
2
2
198
804
2
2
3
2
9
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
9
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
200
2
2
2
2
2...

result:

ok 100000 lines

Test #20:

score: 30
Accepted
time: 2034ms
memory: 17316kb

input:

10000 100000 100000
0 3029 6081
0 8203 8589
1 3029 6081
1 8203 8589
0 5644 5052
0 7453 4217
1 4217 7453
0 411 1437
0 6129 6204
1 6129 6204
1 411 1437
1 5052 5644
0 3706 3648
1 3648 3706
0 4124 255
1 4124 255
0 6254 1238
1 6254 1238
0 315 9450
0 3482 4345
0 5779 9692
0 8499 9981
0 9054 4198
1 3482 43...

output:

9954
9868
9838
9950
9998
9870
9919
9954
9980
9949
9944
9911
9836
9904
9970
9943
9890
9903
9871
9984
9998
9934
9950
9885
9922
9997
9981
9953
9870
9942
9924
9916
9996
9899
9995
9937
9901
9878
9986
9854
9928
9981
9966
9990
9926
9974
9977
9881
9908
9996
9980
9843
9940
9944
9887
9903
9860
9897
9952
9880
...

result:

ok 100000 lines

Test #21:

score: 30
Accepted
time: 26ms
memory: 17696kb

input:

100000 1 100000
0 82807 93097
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 73456
0 7345...

output:

99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
...

result:

ok 100000 lines

Test #22:

score: 30
Accepted
time: 57ms
memory: 17716kb

input:

100000 13 100000
0 1439 16071
0 77126 71233
0 65676 31466
0 46411 63728
0 89638 56713
0 87375 51822
1 51822 87375
0 8857 81973
1 46411 63728
0 3682 72818
0 99222 1242
0 9034 60037
1 8857 81973
9 24572
11 24572
11 24572
9 24572
10 24572
12 24572
12 24572
9 24572
9 24572
1 24572
5 24572
1 24572
10 245...

output:

99996
99996
99996
99996
99996
99996
99996
99996
99996
99998
99994
99998
99996
99995
99998
99996
99996
99996
99996
99996
99997
99996
99996
99995
99996
99998
99996
99995
99996
99997
99996
99999
99996
99995
99995
99998
99998
99996
99995
99997
99995
99996
99995
99996
99996
99995
99996
99995
99996
99996
...

result:

ok 100000 lines

Test #23:

score: 30
Accepted
time: 2271ms
memory: 18196kb

input:

100000 1300 100000
0 89356 81602
0 25968 71253
1 71253 25968
1 81602 89356
0 9552 48034
1 48034 9552
0 60781 48013
1 48013 60781
0 37834 44402
1 44402 37834
0 65946 49304
0 18516 23388
0 29228 56191
1 23388 18516
0 59336 2420
0 93358 56425
1 56425 93358
1 65946 49304
0 54778 99482
1 54778 99482
1 29...

output:

100000
99959
99919
99844
99931
99870
99885
99972
99848
99619
99897
99730
99916
99947
99926
99796
99832
99920
99620
99880
99690
99888
99888
99865
99730
99914
99690
99916
99681
99757
99720
99962
99864
99795
99685
99962
99618
99915
99752
99681
99962
99687
99622
99798
99795
99877
99786
99796
99756
99963...

result:

ok 100000 lines

Test #24:

score: 30
Accepted
time: 2279ms
memory: 28680kb

input:

100000 100000 100000
0 17804 63065
1 63065 17804
0 45575 88403
1 45575 88403
0 80699 2416
1 80699 2416
0 31614 61013
0 56546 21713
1 31614 61013
1 56546 21713
0 62497 35703
1 35703 62497
0 31149 60185
1 60185 31149
0 78537 84342
1 78537 84342
0 32132 70924
1 70924 32132
0 43661 10068
0 347 91377
0 5...

output:

99867
99992
99898
99888
99915
99975
99864
99877
99876
99861
99866
99864
99986
99997
99908
99990
99835
99886
99819
99894
99918
99844
99877
99982
99887
99900
99867
99886
99910
99988
99918
99936
99913
99961
99891
99928
99850
99948
99974
99865
99800
99895
99953
99863
99958
99836
99961
99841
99945
99867
...

result:

ok 100000 lines

Test #25:

score: 30
Accepted
time: 4908ms
memory: 30652kb

input:

100000 100000 100000
0 24907 27865
1 27865 24907
0 52274 52157
0 33 31159
0 55043 23321
0 82744 42837
1 31159 33
1 82744 42837
0 88688 98999
1 52274 52157
0 51278 31159
1 88688 98999
1 55043 23321
0 61377 31159
0 26891 98999
0 98999 45687
0 43623 39111
0 89515 31159
1 45687 98999
0 38524 94012
0 152...

output:

93423
87123
82099
95363
93522
88616
96001
88490
87910
87114
90029
84266
89936
98685
84402
88903
96346
86243
89791
84715
95956
98159
84744
93347
99490
83760
96070
86758
89011
82768
88238
81508
92733
84987
93386
94883
84738
97333
86359
81562
92756
85568
85310
88344
93250
81356
83659
99905
82166
85746
...

result:

ok 100000 lines

Test #26:

score: 0
Time Limit Exceeded

input:

100000 100000 100000
0 51121 62431
0 99918 74056
0 60825 71018
0 7595 24939
0 98355 56680
0 53097 32198
0 6546 74840
0 53620 67586
0 32747 14603
0 15566 41025
0 10663 7997
0 63554 41417
0 86524 78350
0 93313 23614
0 48984 86305
0 29296 37851
0 69475 8084
0 58875 73654
0 92009 45536
0 89865 67813
0 2...

output:

88708
54743
74756
52508
82115
60826
55492
61928
78480
88881
70276
64099
96761
54320
52627
75089
79098
65142
56337
53275
72623
96839
73044
72228
96403
94337
55788
79638
55339
84654
73149
87995
94910
86555
92763
77829
51834
93682
60263
75213
92260
83673
80054
70258
86209
97431
58540
95354
77864
65201
...

result:


Subtask #3:

score: 0
Time Limit Exceeded

Test #28:

score: 30
Accepted
time: 18ms
memory: 7532kb

input:

2 1 100000
0 1 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:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 100000 lines

Test #29:

score: 30
Accepted
time: 36ms
memory: 7128kb

input:

5 7 100000
0 3 1
0 4 1
0 2 3
0 2 1
0 2 4
0 2 0
0 4 0
1 0
3 0
4 0
0 3
1 2
2 0
4 0
2 1
5 1
4 0
2 3
0 2
0 3
6 0
4 2
5 2
4 3
5 0
0 0
5 3
0 1
4 0
4 0
3 1
3 0
1 1
6 3
0 0
0 0
0 3
5 3
3 2
6 0
5 0
4 1
0 0
5 0
0 3
2 3
1 2
2 1
6 2
0 0
3 2
0 0
2 2
1 0
1 1
0 2
1 0
5 3
5 2
2 1
2 2
3 0
2 3
1 3
1 0
3 1
5 2
1 2
5 0...

output:

3
2
2
4
5
2
2
4
3
2
3
5
4
2
4
3
3
2
4
2
5
2
2
4
2
5
2
4
4
4
2
4
2
2
3
4
2
4
3
5
4
3
4
4
4
5
3
5
5
3
2
3
4
5
2
3
4
3
4
3
5
2
5
4
5
2
4
2
5
2
4
5
4
3
2
3
3
3
2
4
5
4
5
4
4
2
3
4
3
3
2
3
2
3
3
2
4
4
4
5
3
3
4
5
4
4
5
3
3
2
5
3
5
4
3
2
5
4
4
5
3
3
4
4
3
5
4
2
4
2
2
4
2
3
4
2
5
5
4
4
2
2
3
3
4
2
2
5
5
4
...

result:

ok 100000 lines

Test #30:

score: 30
Accepted
time: 85ms
memory: 7852kb

input:

10 20 100000
0 5 6
0 5 0
0 0 9
0 0 6
0 3 4
0 4 0
0 7 9
0 3 1
0 4 1
0 6 1
0 3 0
0 8 7
0 1 2
0 5 1
0 3 2
0 8 4
0 8 6
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6
5
2
2
3
7
2
7
2
6
3
8
5
7
2
5
4
3
2
3
2
2
9
4
2
2
2
2
3
9
2
2
3
3
4
6
2
5
2
3
5
2
6
2
2...

result:

ok 100000 lines

Test #32:

score: 30
Accepted
time: 2840ms
memory: 7236kb

input:

100 500 100000
0 75 20
0 23 42
0 53 70
0 11 28
0 23 67
0 74 63
0 93 4
0 13 43
0 96 72
0 2 65
0 43 96
0 86 52
0 77 38
0 89 33
0 85 84
0 55 48
0 8 20
0 7 18
0 43 62
0 38 44
0 42 24
0 98 6
0 92 66
0 17 33
0 4 70
0 12 74
0 13 99
0 79 63
0 53 14
0 38 22
0 54 41
0 61 44
0 85 21
0 25 38
0 38 28
0 81 87
0 7...

output:

8
19
7
7
5
51
5
8
16
8
3
6
5
3
42
3
6
5
9
15
3
9
7
6
5
26
12
4
22
22
3
13
11
6
99
3
79
2
30
3
2
9
56
5
67
2
43
4
12
3
28
26
11
6
5
18
2
6
72
6
17
2
11
18
48
86
3
3
85
6
10
3
7
36
5
3
6
12
5
3
38
3
3
11
9
93
54
60
8
22
35
4
34
16
48
6
11
5
5
31
99
43
60
5
11
8
2
21
69
3
94
50
8
3
8
3
8
6
25
28
3
6
2
...

result:

ok 100000 lines

Test #33:

score: 30
Accepted
time: 3082ms
memory: 7224kb

input:

100 4950 100000
0 50 40
0 87 50
0 72 73
0 74 65
0 2 4
0 29 28
0 20 28
0 15 99
0 13 56
0 31 5
0 5 89
0 28 10
0 84 6
0 19 92
0 38 96
0 89 86
0 21 10
0 18 35
0 84 28
0 86 80
0 69 45
0 33 62
0 3 45
0 81 22
0 0 43
0 12 41
0 81 58
0 34 4
0 53 65
0 55 43
0 71 18
0 60 17
0 44 18
0 12 6
0 55 94
0 87 41
0 42 ...

output:

2
4
2
2
2
2
4
2
2
3
2
2
2
2
2
2
5
2
2
2
2
2
2
2
2
2
2
4
2
2
5
2
2
2
14
2
16
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
41
2
2
2
2
2
14
2
2
2
2
2
2
2
2
6
2
2
2
2
2
2
2
2
8
2
2
2
2
2
2
2
2
2
28
2
2
2
2
2
14
2
2
12
2
2
2
2
2
2
2
2
2
3
2
2
2
2
10
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
6
78
2
2
2
2
2
2
2
2
2
2
1...

result:

ok 100000 lines

Test #34:

score: 30
Accepted
time: 3530ms
memory: 15452kb

input:

1000 75000 100000
0 312 514
0 320 439
0 100 448
0 646 280
0 535 701
0 199 217
0 178 777
0 843 287
0 996 52
0 587 444
0 728 395
0 882 610
0 875 656
0 971 990
0 656 990
0 549 684
0 766 968
0 969 956
0 15 757
0 978 467
0 736 621
0 673 44
0 911 944
0 555 47
0 385 922
0 897 648
0 352 936
0 157 311
0 645 ...

output:

2
6
2
2
2
10
2
2
2
2
2
2
2
2
3
2
2
2
17
177
3
2
3
2
2
2
39
4
3
2
2
3
2
2
2
2
4
2
2
2
40
2
236
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
694
2
2
2
3
12
19
2
10
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
34
4
2
2
2
2
2
2
2
2
2
2
2
2
2
2
12
2
2
2
3
2
2
2
3
70
33
2
14
2
3
2
2
17
2
2
2
2
2
2
2
7
2
2
2
8
10
2
2
3
...

result:

ok 100000 lines

Test #35:

score: 30
Accepted
time: 3785ms
memory: 20540kb

input:

10000 100000 100000
0 4650 4651
0 5118 50
0 8501 1203
0 4320 9114
0 5284 84
0 7128 8483
0 6247 6754
0 4110 4770
0 7990 4574
0 1552 708
0 772 6932
0 924 9657
0 9165 8340
0 8946 1023
0 4548 8725
0 3262 6753
0 8435 8769
0 7335 9388
0 4270 5695
0 2997 5918
0 6108 18
0 724 5121
0 1094 3007
0 7024 4086
0 ...

output:

51
73
889
316
26
367
4
5327
2831
167
3436
107
142
37
8
510
9029
32
28
436
377
342
84
17
4266
38
2590
120
95
52
404
19
21
591
8941
5501
56
362
225
87
263
226
576
40
207
917
31
154
48
6348
1250
53
194
60
65
222
21
67
1688
620
342
62
946
155
25
207
61
1402
72
226
153
22
8283
314
7467
117
9033
17
7044
2...

result:

ok 100000 lines

Test #36:

score: 30
Accepted
time: 39ms
memory: 19980kb

input:

100000 1 100000
0 33336 16556
0 92196
0 26197
0 53372
0 38599
0 96200
0 44612
0 24541
0 75990
0 28525
0 25457
0 83626
0 61731
0 69015
0 29071
0 3513
0 39485
0 52956
0 9699
0 90062
0 41875
0 14538
0 74187
0 73753
0 97815
0 61704
0 86178
0 42498
0 44887
0 55131
0 98310
0 78129
0 54118
0 25940
0 11754
...

output:

99999
100000
99999
99999
99999
99999
100000
99999
100000
100000
99999
99999
99999
100000
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
100000
99999
100000
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999
99999...

result:

ok 100000 lines

Test #37:

score: 30
Accepted
time: 2794ms
memory: 18636kb

input:

100000 1000 100000
0 40911 70767
0 43851 74810
0 98101 23348
0 2588 74553
0 99709 32715
0 80067 21678
0 65194 58715
0 20669 33662
0 58431 82503
0 23326 15298
0 65281 6831
0 49793 40357
0 84369 53367
0 65621 16191
0 99338 18468
0 87123 1278
0 59646 15976
0 34874 48231
0 28748 77608
0 35658 19831
0 75...

output:

99535
99471
99799
99610
99996
99597
99721
99361
99778
99792
99768
99743
99656
99504
99638
99595
99552
99737
99882
99866
99084
99509
99941
99630
99745
99988
99547
99633
99860
99915
99552
99610
99329
99766
99922
99521
99815
99359
99621
99658
99442
99979
99982
99672
99971
99742
99867
99690
99834
99601
...

result:

ok 100000 lines

Test #38:

score: 30
Accepted
time: 5317ms
memory: 34872kb

input:

100000 100000 100000
0 58788 61813
0 21513 25800
0 88016 61813
0 61813 76909
0 80963 25800
0 10224 61813
0 6529 25800
0 84889 16488
0 25800 18639
0 61813 12954
0 86274 61813
0 61813 47108
0 87338 61813
0 31751 61813
0 33113 51903
0 16488 72671
0 28731 40816
0 16488 46955
0 25800 47670
0 72904 16488
...

output:

78047
60034
90581
63392
67541
60865
89448
81437
80808
79233
52778
88836
65017
68685
94108
41263
58600
55445
39882
58392
51111
98840
66143
82087
62682
89169
86782
58768
55792
96187
67172
45894
85547
78657
55227
61523
29863
74318
66324
66850
79441
68780
88962
60149
69875
92753
72295
47527
39478
71770
...

result:

ok 100000 lines

Test #39:

score: 0
Time Limit Exceeded

input:

100000 100000 100000
0 20750 63020
0 78129 41347
0 6274 44744
0 84800 27790
0 38830 41299
0 45700 1339
0 54539 62677
0 66137 96771
0 97257 95836
0 99860 22225
0 1817 18865
0 76593 67906
0 14538 48021
0 53976 99932
0 18091 93984
0 81227 60047
0 71218 27770
0 62632 49210
0 85275 86222
0 10536 63833
0 ...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%