QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#502384#2645. Collapsemakrav0 5745ms28860kbC++204.2kb2024-08-03 04:57:482024-08-03 04:57:48

Judging History

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

  • [2024-08-03 04:57:48]
  • 评测
  • 测评结果:0
  • 用时:5745ms
  • 内存:28860kb
  • [2024-08-03 04:57:48]
  • 提交

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 = 501;

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 += K) {
		unordered_set<ll> ch_edg;
		unordered_set<ll> LOL;
		for (int j = i; j < min(c, i + K); j++) {
			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 = 0; j < i; j++) {
			if (ch_edg.find(X[j] * 1ll * n + Y[j]) == ch_edg.end()) {
				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]);
					}
				}
				unordered_set<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.insert(u);
							rdfs.insert(v);
						}
					}
				}
				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]);
					}
				}
				unordered_set<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.insert(u);
							rdfs.insert(v);
						}
					}
				}
				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;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 5
Accepted
time: 29ms
memory: 4272kb

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
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 5000 lines

Test #2:

score: 0
Wrong Answer
time: 3ms
memory: 4028kb

input:

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

output:

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

result:

wrong answer 2nd lines differ - expected: '5', found: '3'

Subtask #2:

score: 0
Wrong Answer

Test #13:

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

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 #14:

score: 0
Wrong Answer
time: 49ms
memory: 7344kb

input:

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

output:

4
4
4
4
3
4
4
4
4
4
4
4
4
3
4
3
4
4
4
4
3
4
4
4
3
3
4
3
4
4
4
4
4
4
4
3
4
4
4
4
3
3
4
4
4
4
4
4
4
3
4
4
4
4
3
3
4
3
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
3
4
4
3
4
3
3
4
4
3
4
4
3
4
4
4
4
3
4
3
4
4
4
4
3
4
4
4
4
4
3
4
4
4
4
4
3
4
4
4
4
4
4
4
3
4
3
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
3
4
4
4
...

result:

wrong answer 2nd lines differ - expected: '5', found: '4'

Subtask #3:

score: 0
Time Limit Exceeded

Test #28:

score: 30
Accepted
time: 21ms
memory: 7604kb

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

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

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

output:

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

result:

ok 100000 lines

Test #31:

score: 30
Accepted
time: 182ms
memory: 7588kb

input:

10 45 100000
0 5 7
0 2 1
0 3 5
0 4 2
0 4 8
0 7 3
0 0 8
0 1 4
0 6 2
0 9 8
0 7 2
0 5 0
0 1 3
0 6 4
0 9 1
0 4 3
0 8 6
0 2 8
0 5 1
0 3 2
0 7 9
0 4 5
0 0 2
0 0 3
0 8 5
0 1 8
0 0 1
0 0 7
0 1 7
0 6 0
0 6 5
0 7 6
0 4 7
0 7 8
0 2 9
0 9 3
0 1 6
0 6 9
0 0 9
0 9 4
0 3 8
0 5 2
0 3 6
0 9 5
0 0 4
17 8
32 2
8 0
29 ...

output:

2
2
4
2
2
2
2
2
9
2
2
4
2
2
2
2
2
2
6
4
5
2
7
3
3
2
2
8
2
2
3
2
9
5
6
3
3
4
6
7
4
6
2
2
7
7
2
5
2
2
2
2
2
2
3
2
2
6
8
2
2
10
9
6
2
5
2
2
2
2
7
3
6
8
2
2
2
7
2
2
2
2
2
9
4
2
2
3
2
2
2
2
2
7
2
7
3
5
2
3
2
2
2
2
2
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: 3017ms
memory: 7272kb

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

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

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

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

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

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

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:

0%