QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#292586#4895. Lovely Dogszyc07041920 96ms64716kbC++144.8kb2023-12-28 09:05:382023-12-28 09:05:38

Judging History

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

  • [2023-12-28 09:05:38]
  • 评测
  • 测评结果:20
  • 用时:96ms
  • 内存:64716kb
  • [2023-12-28 09:05:38]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 10;

inline int read() {
	char ch = getchar(); int x = 0;
	while (!isdigit(ch)) {ch = getchar();}
	while (isdigit(ch)) {x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
	return x;
}

struct node {
	int p, c;
	node(int a = 0, int b = 0) {p = a; c = b;}
};
int n, D, prime[N], cnt, val[N], lim[N], a[N], id[N], pw[N][21], u[N], depth[N], fa[N][18];
vector<node> vec[N];
vector<int> g[N];
bitset<N> vis;

void init() {
	u[1] = 1;
	for (int i = 2; i <= n; ++i) {
		if (!vis[i]) {
			prime[++cnt] = i; u[i] = -1;
			pw[i][0] = 1;
			for (int j = 1; j <= D; ++j) pw[i][j] = min(1ll * pw[i][j - 1] * i, 1000000000ll);
		}
		for (int j = 1; j <= cnt && i * prime[j] <= n; ++j) {
			vis[i * prime[j]] = 1;
			if (i % prime[j]) u[i * prime[j]] = -u[i];
			else {
				u[i * prime[j]] = 0;
				break;
			}
		}
	}
	for (int i = 2, x, o; i <= n; ++i) {
		x = i;
		for (int j = 1; j <= cnt && prime[j] * prime[j] <= x; ++j) {
			if (x % prime[j]) continue;
			o = 0;
			while (x % prime[j] == 0) x /= prime[j], o++;
			vec[i].push_back(node(prime[j], o));
			val[i] += o; lim[i] = max(lim[i], o);
		}
		if (x > 1) vec[i].push_back(node(x, 1)), val[i]++, lim[i] = max(lim[i], 1);
		val[i] &= 1;
	}
}
	
void dfs(int x, int pa, int d) {
	fa[x][0] = pa; depth[x] = d;
	for (auto y : g[x]) {
		if (y == pa) continue;
		dfs(y, x, d + 1);
	}
}

inline int LCA(int x, int y) {
	if (depth[x] < depth[y]) swap(x, y);
	int tmp = depth[x] - depth[y];
	for (int i = 0; i <= 17; ++i)
		if ((tmp >> i) & 1) x = fa[x][i];
	if (x == y) return x;
	for (int i = 17; i >= 0; --i) {
		if (fa[x][i] == fa[y][i]) continue;
		x = fa[x][i]; y = fa[y][i];
	}
	return fa[x][0];
}

namespace subtask1 {
	const int N1 = 2005;
	int ans[N1];
	
	void dfs1(int x) {
		for (auto y : g[x]) {
			if (y == fa[x][0]) continue;
			dfs1(y); ans[x] += ans[y];
		}
	}
	
	void solve() {
		for (int p = 1; p <= n; ++p)
			for (int q = p; q <= n; ++q) {
				int lca = LCA(p, q), x = a[p], y = a[q];
				int i = 0, mx = max(lim[x], lim[y]);
				for (auto tmp : vec[x]) {
					while (i < vec[y].size() && vec[y][i].p < tmp.p) i++;
					if (i < vec[y].size() && vec[y][i].p == tmp.p) mx = max(mx, vec[y][i].c + tmp.c);
				}
				if (mx > D) continue;
				if (val[x] ^ val[y]) ans[lca]--;
				else ans[lca]++;
			}
		dfs1(1);
		for (int i = 1; i <= n; ++i) printf("%d\n", ans[i]);
	}
}

namespace subtask2 {
	int sz[N][2];
	ll dp[N], ex[N];
	map<int, bool> mp;
	
	void dfs1(int x) {
		dp[x] = sz[x][val[a[x]]] = (lim[a[x]] <= D);
		for (auto y : g[x]) {
			if (y == fa[x][0]) continue;
			dfs1(y);
			dp[x] += dp[y];
			dp[x] += 1ll * sz[x][0] * sz[y][0];
			dp[x] += 1ll * sz[x][1] * sz[y][1];
			dp[x] -= 1ll * sz[x][0] * sz[y][1];
			dp[x] -= 1ll * sz[x][1] * sz[y][0];
			sz[x][0] += sz[y][0];
			sz[x][1] += sz[y][1];
		}
	}
	
	void dfs2(int x) {
		for (auto y : g[x]) {
			if (y == fa[x][0]) continue;
			dfs2(y); ex[x] += ex[y];
		}
	}
	
	void solve() {
		dfs1(1);
		for (int i = 1; i <= n; ++i) {
			if (lim[i] > D) continue;
			mp.clear();
			for (auto tmp : vec[i]) {
				int mn = pw[tmp.p][D + 1 - tmp.c];
				if (mn > n) continue;
				int now = mn;
				if (now < i) now = ((i - 1) / now + 1) * now;
				if (now > n) continue;
				while (now <= n) {
					if (lim[now] > D) {now += mn; continue;}
					if (mp[now]) {now += mn; continue;}
					mp[now] = true;
					int x = id[i], y = id[now], lca = LCA(x, y);
					if (val[i] ^ val[now]) ex[lca]--;
					else ex[lca]++;
					now += mn;
				}
			}
		}
		dfs2(1);
		for (int i = 1; i <= n; ++i) printf("%lld\n", dp[i] - ex[i]);
	}
}

namespace subtask3 {
	int sz[N][2]; ll ans;
	
	void solve() {
		for (int i = 1; i <= n; ++i)
			for (int j = 1; 1ll * i * j <= n; ++j) {
				if (u[i * j] == 0) continue;
				sz[i][val[i * j]]++;
			}
		for (int i = 1; i <= n; ++i) {
			ans += 1ll * u[i] * sz[i][0] * sz[i][0];
			ans += 1ll * u[i] * sz[i][1] * sz[i][1];
			ans -= 1ll * u[i] * sz[i][0] * sz[i][1];
			ans -= 1ll * u[i] * sz[i][1] * sz[i][0];
		}
		ans = (ans + 1) / 2; printf("%lld\n", ans);
		for (int i = 2; i <= n; ++i) printf("%d\n", a[i] == 1);
	}
}

int main() {
//	freopen("in.in", "r", stdin);
//	freopen("mine.out", "w", stdout);
	n = read(); D = read(); init();
	for (int i = 1, x, y; i < n; ++i) {
		x = read(); y = read();
		g[x].push_back(y);
		g[y].push_back(x);
	}
	for (int i = 1; i <= n; ++i) a[i] = read(), id[a[i]] = i;
	dfs(1, 0, 1);
	for (int j = 1; j <= 17; ++j)
		for (int i = 1; i <= n; ++i)
			fa[i][j] = fa[fa[i][j - 1]][j - 1];
	
	return subtask3 :: solve(), 0;
	
	if (n <= 2000) subtask1 :: solve();
	else if (D == 20) subtask2 :: solve();
	else if (g[1].size() == n - 1 && D == 1) subtask3 :: solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 13068kb

input:

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

output:

2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0

result:

wrong answer 1st words differ - expected: '16', found: '2'

Subtask #2:

score: 0
Wrong Answer

Test #24:

score: 0
Wrong Answer
time: 5ms
memory: 13516kb

input:

2000 1
134 1468
867 1750
351 1220
1690 1888
1685 134
585 282
1142 643
206 271
260 1833
1987 770
1029 1667
322 1371
341 518
601 915
119 893
1933 1502
951 1785
1056 1630
1957 1208
96 55
1508 1212
331 427
505 151
1378 1486
1545 697
1459 629
202 997
180 1917
1638 1177
1244 1896
302 658
1433 1605
1318 19...

output:

581
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

wrong answer 2nd words differ - expected: '-3', found: '0'

Subtask #3:

score: 0
Wrong Answer

Test #45:

score: 0
Wrong Answer
time: 95ms
memory: 64472kb

input:

200000 20
117994 12616
53490 106425
103660 50033
132640 78252
58384 19939
69183 10015
39098 165030
179856 130356
65245 57831
18234 83378
4240 154896
177149 102260
4634 180087
132390 19627
98506 60775
1890 120740
87908 21917
41323 192721
181885 96684
69412 139951
9800 38301
59025 29879
186185 81402
1...

output:

-44916
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

wrong answer 1st words differ - expected: '143459', found: '-44916'

Subtask #4:

score: 20
Accepted

Test #50:

score: 20
Accepted
time: 69ms
memory: 64680kb

input:

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

output:

-44916
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 200000 tokens

Test #51:

score: 0
Accepted
time: 61ms
memory: 64564kb

input:

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

output:

-44916
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 200000 tokens

Test #52:

score: 0
Accepted
time: 68ms
memory: 64672kb

input:

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

output:

-44916
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 200000 tokens

Test #53:

score: 0
Accepted
time: 63ms
memory: 64480kb

input:

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

output:

-44916
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 200000 tokens

Test #54:

score: 0
Accepted
time: 67ms
memory: 64600kb

input:

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

output:

-44916
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 200000 tokens

Subtask #5:

score: 0
Wrong Answer

Test #55:

score: 15
Accepted
time: 57ms
memory: 64532kb

input:

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

output:

-44916
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 200000 tokens

Test #56:

score: 0
Accepted
time: 60ms
memory: 64500kb

input:

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

output:

-44916
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 200000 tokens

Test #57:

score: 0
Accepted
time: 67ms
memory: 64664kb

input:

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

output:

-44916
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 200000 tokens

Test #58:

score: -15
Wrong Answer
time: 79ms
memory: 64716kb

input:

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

output:

-44916
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

wrong answer 1st words differ - expected: '685522', found: '-44916'

Subtask #6:

score: 0
Wrong Answer

Test #78:

score: 0
Wrong Answer
time: 16ms
memory: 25776kb

input:

50000 1
8097 41839
17674 41774
40520 8024
5786 38261
20664 43471
1217 49276
11185 40807
14186 25584
31704 14814
42333 41475
13053 39565
45938 30104
5826 39463
5031 10814
43784 6042
58 33849
42978 18978
36307 33276
34769 4351
27884 37532
27528 29431
29451 39345
10946 9667
19016 47269
7911 30103
10308...

output:

-9152
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

wrong answer 8th words differ - expected: '-1', found: '0'

Subtask #7:

score: 0
Wrong Answer

Test #103:

score: 0
Wrong Answer
time: 96ms
memory: 64524kb

input:

200000 1
118863 188865
188022 168616
118976 119404
178852 33449
81624 40431
151228 160976
68943 136313
57200 117631
147789 139875
100240 55537
164811 145415
103548 186750
15010 168029
155731 107005
69836 1502
86171 122700
83448 131948
189162 94464
128210 2509
49724 183329
174782 192641
27687 71315
1...

output:

-44916
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

wrong answer 11th words differ - expected: '-1', found: '0'