QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#71759#3279. 经典游戏He_Ren68 111ms56200kbC++144.5kb2023-01-12 00:57:332023-01-12 00:57:34

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-12 00:57:34]
  • 评测
  • 测评结果:68
  • 用时:111ms
  • 内存:56200kb
  • [2023-01-12 00:57:33]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 1e6 + 5;

namespace FastIO
{
	const int SIZ1 = 1<<21, SIZ2 = 1<<21;
	char buf1[SIZ1], buf2[SIZ2], *s1=buf1, *t1=buf1, *s2=buf2, *t2=buf2;
	inline char gc(void){ return s1 == t1 && (s1=buf1) == (t1=buf1+fread(buf1,1,SIZ1,stdin))? EOF: *s1++;}
	inline void flush(void){ fwrite(s2,1,t2-s2,stdout); t2=s2;}
	inline void pc(char c){ if(t2-s2==SIZ2) flush(); *t2++ = c;}
	inline int read(void)
	{
		int res=0, flag=1; char c=gc();
		for(; c<'0'||c>'9'; c=gc()) if(c=='-') flag=-1;
		for(; c>='0'&&c<='9'; c=gc()) res=res*10+c-'0';
		return res*flag;
	}
	inline void write(int x)
	{
		if(x>=10) write(x/10);
		pc(x%10+'0');
	}
	inline void write(int x,char c){ write(x); pc(c);}
	struct _{ ~_(void){ flush();}}__;
} using FastIO::read; using FastIO::write;

#define bbit(i) (1<<(i))
#define bdig(x,i) (((x)>>(i))&1)

namespace Trie
{
	const int lb = 20;
	const int MAXP = MAXN * lb;
	int son[MAXP][2], siz[MAXP], pool = 0, pcnt = 0;
	int new_Node(void)
	{
		if(!pool) return ++pcnt;
		int u = pool; pool = son[pool][0];
		son[u][0] = son[u][1] = siz[u] = 0;
		return u;
	}
	void del_Node(int &u)
	{
		son[u][0] = pool;
		pool = u; u = 0;
	}
	void update(int &rt,int x,int k)
	{
		if(!rt) rt = new_Node();
		static int pt[lb+5];
		pt[lb] = rt; siz[rt] += k;
		for(int i=lb-1; i>=0; --i)
		{
			int &v = son[pt[i+1]][bdig(x,i)];
			if(!v) v = new_Node();
			pt[i] = v; siz[v] += k;
		}
		for(int i=0; i<lb; ++i) if(!siz[pt[i]])
			del_Node(son[pt[i+1]][bdig(x,i)]);
	}
	int query(int rt,int x,int k)
	{
		int res=0;
		for(int i=lb-1; i>=0 && siz[rt]; --i)
		{
			if(bdig(x,i)) rt = son[rt][bdig(k,i)^1];
			else
			{
				int kk = bdig(k,i);
				res += siz[son[rt][kk^1]];
				rt = son[rt][kk];
			}
		}
		return res;
	}
}

struct BIT
{
	int tree[MAXN], alltag, n;
	#define lowbit(x) ((x)&-(x))
	inline void update(int x,int k)
	{
		while(x<=n) tree[x] ^= k, x += lowbit(x);
	}
	inline void update(int l,int r,int k)
	{
		update(l,k); update(r+1,k);
	}
	inline int query(int x)
	{
		int res=alltag;
		while(x) res ^= tree[x], x ^= lowbit(x);
		return res;
	}
}tree;

int n;
vector<int> g[MAXN];

int anc[MAXN], siz[MAXN], sub[MAXN], dfn[MAXN], curdfn = 0;
void dfs_tree(int u,int fa)
{
	anc[u] = fa;
	siz[u] = 1; sub[u] = 0;
	dfn[u] = ++curdfn;
	for(int v: g[u]) if(v != fa)
	{
		dfs_tree(v,u);
		siz[u] += siz[v];
		sub[u] = max(sub[u], sub[v] + 1);
	}
}

void dfs_dep(int u,int fa,int dep[])
{
	for(int v: g[u]) if(v != fa)
		dep[v] = dep[u] + 1, dfs_dep(v,u,dep);
}
inline int getfar(int rt)
{
	static int dep[MAXN];
	dep[rt] = 0; dfs_dep(rt,0,dep);
	return max_element(dep+1,dep+n+1) - dep;
}

int main(void)
{
	read(); n = read(); int Q = read();
	for(int i=1; i<n; ++i)
	{
		int u = read(), v = read();
		g[u].push_back(v); g[v].push_back(u);
	}
	if(n == 1)
	{
		while(Q--) FastIO::pc('0'), FastIO::pc(' ');
		return 0;
	}
	
	int ep1 = getfar(1), ep2 = getfar(ep1);
	
	static int dep[2][MAXN];
	dfs_dep(ep1, 0, dep[0]);
	dfs_dep(ep2, 0, dep[1]);
	
	static int type[MAXN], h[MAXN];
	for(int i=1; i<=n; ++i)
	{
		type[i] = dep[0][i] >= dep[1][i]? 0: 1;
		h[i] = max(dep[0][i], dep[1][i]);
	}
	
	int rt1 = -1, rt2 = -1;
	for(int u=1; u<=n; ++u) for(int v: g[u])
		if(type[u] == 0 && type[v] == 1)
			rt1 = u, rt2 = v;
	assert(rt1 != -1);
	
	auto isrt = [&] (int u){ return u == rt1 || u == rt2;};
	dfs_tree(rt1, rt2);
	dfs_tree(rt2, rt1);
	
	static int rt[MAXN], val[MAXN], has[MAXN], num0[MAXN];
	for(int i=1; i<=n; ++i) val[i] = sub[i] ^ h[i];
	
	auto checkone = [&] (int u) -> int
	{
		return tree.query(dfn[u]) > h[u];
	};
	auto xor_one = [&] (int u)
	{
		tree.alltag ^= sub[u];
		has[u] ^= 1;
		if(!isrt(u))
		{
			int k = has[u]? 1: -1;
			Trie::update(rt[anc[u]], val[u], k);
			num0[anc[u]] += -k;
		}
		tree.update(dfn[u], dfn[u]+siz[u]-1, val[u]);
	};
	
	tree.n = n;
	for(int u=1; u<=n; ++u)
	{
		has[u] = read() & 1;
		if(has[u])
		{
			tree.alltag ^= sub[u];
			tree.update(dfn[u], dfn[u]+siz[u]-1, val[u]);
			if(!isrt(u)) Trie::update(rt[anc[u]], val[u], 1);
		}
		else ++num0[anc[u]];
	}
	
	while(Q--)
	{
		int x = read(), u = read();
		xor_one(x);
		
		int k = tree.query(dfn[u]);
		int ans = checkone(u) + checkone(anc[u]);
		ans += Trie::query(rt[u], h[u]+1, k);
		if(k > h[u]+1) ans += num0[u];
		
		write(ans, '\n');
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 16
Accepted

Test #1:

score: 16
Accepted
time: 4ms
memory: 27020kb

input:

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

output:

1
1
1
0
0

result:

ok 5 number(s): "1 1 1 0 0"

Test #2:

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

input:

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

output:

0
1
1
0
0

result:

ok 5 number(s): "0 1 1 0 0"

Subtask #2:

score: 15
Accepted

Dependency #1:

100%
Accepted

Test #3:

score: 15
Accepted
time: 9ms
memory: 28932kb

input:

15
300 300
2 49
5 174
7 98
12 254
14 234
21 3
3 11
26 48
29 102
32 232
35 283
36 130
38 22
39 178
40 294
44 192
46 256
47 99
53 58
54 287
55 268
56 207
57 238
58 34
34 207
59 226
63 202
70 13
13 128
73 76
76 261
83 285
84 6
89 217
90 294
94 230
101 155
104 273
106 15
107 52
108 276
110 118
111 285
1...

output:

0
0
3
0
2
1
2
0
0
2
1
0
0
0
2
0
0
2
0
0
0
2
0
2
0
0
1
0
0
0
0
1
0
0
0
2
1
0
2
1
0
0
0
1
0
1
0
0
0
0
0
0
3
2
1
0
0
1
2
1
2
0
2
0
0
3
2
0
1
4
1
0
0
3
0
0
0
3
2
0
0
2
2
0
0
0
0
1
1
3
0
0
0
1
0
0
0
0
2
0
0
0
0
2
2
1
3
0
0
0
0
0
0
3
0
0
0
3
0
0
0
0
2
1
0
0
1
0
0
0
2
1
0
2
0
0
0
0
1
0
0
1
0
1
0
0
0
0
0
2
...

result:

ok 300 numbers

Test #4:

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

input:

15
300 300
2 296
7 137
9 253
11 107
12 298
16 274
18 81
22 51
24 113
25 216
26 254
27 300
30 289
31 180
32 221
33 113
34 225
36 298
46 163
48 258
49 220
50 189
52 268
53 207
55 128
59 74
63 67
65 181
71 70
72 5
5 272
74 135
77 252
80 42
83 28
84 127
86 57
57 141
91 232
92 262
96 181
97 287
98 118
99...

output:

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

result:

ok 300 numbers

Test #5:

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

input:

15
300 300
2 240
7 129
8 82
23 13
27 189
29 274
32 75
36 191
38 131
40 268
44 202
46 223
47 223
48 216
52 276
53 78
55 39
39 169
57 215
59 201
60 110
63 112
64 102
65 166
75 19
77 276
80 49
49 4
4 215
84 143
85 87
87 156
89 58
92 219
95 54
54 137
97 42
42 15
15 74
98 17
99 168
100 296
101 14
103 161...

output:

0
1
1
2
2
3
0
2
2
0
0
0
1
0
2
0
1
0
0
0
1
0
4
0
2
3
0
0
0
0
1
0
0
1
0
3
1
0
3
2
2
2
2
2
1
2
0
2
1
2
1
0
2
1
0
2
2
3
0
0
0
2
1
2
2
4
0
1
3
0
0
2
2
2
1
2
3
3
0
3
1
2
2
0
4
1
3
2
1
3
0
1
0
1
1
1
1
0
1
1
1
0
2
2
0
0
0
0
0
3
0
0
0
0
1
3
0
2
3
2
0
3
1
0
2
0
1
0
1
1
1
2
0
0
0
1
2
1
0
0
0
1
0
3
3
0
0
1
0
1
...

result:

ok 300 numbers

Subtask #3:

score: 14
Accepted

Dependency #2:

100%
Accepted

Test #6:

score: 14
Accepted
time: 10ms
memory: 29204kb

input:

14
5000 5000
1 4135
2 31
7 4379
9 2889
13 3400
18 3575
19 2290
21 2220
24 1553
29 3843
31 4336
34 3761
36 4515
37 819
38 653
39 3034
45 4752
52 2852
57 3982
60 3301
67 3785
69 4902
71 942
72 2868
77 919
80 2748
81 2624
82 1902
84 3498
87 3279
88 4583
91 4452
96 1669
99 2196
100 2151
102 3725
104 234...

output:

3
2
0
1
1
3
3
0
0
2
0
0
0
3
1
2
0
2
1
0
3
0
0
2
3
1
0
1
0
1
2
1
1
1
2
1
0
2
0
3
0
0
0
0
2
0
2
2
2
0
1
2
1
0
4
3
1
2
4
0
0
1
0
1
0
2
1
0
0
2
2
1
3
2
0
1
2
0
3
0
3
0
3
2
2
2
0
1
0
0
1
0
3
2
3
2
2
1
2
0
0
0
0
1
2
0
2
0
0
0
3
1
1
1
1
4
2
0
2
0
0
3
0
1
4
0
1
0
0
0
2
0
2
0
0
0
1
0
1
0
0
3
0
0
0
3
1
2
0
0
...

result:

ok 5000 numbers

Test #7:

score: 0
Accepted
time: 8ms
memory: 29732kb

input:

14
5000 5000
4630 3016
4630 1936
4630 3499
4630 573
4630 2103
4630 3816
4630 290
4630 4996
4630 3188
4630 2192
4630 4725
4630 865
4630 4432
4630 3191
4630 1755
4630 384
4630 1893
4630 2408
4630 2389
4630 4183
4630 4043
4630 2830
4630 2134
4630 3736
4630 2529
4630 3561
4630 622
4630 4079
4630 4055
46...

output:

0
0
0
0
2
0
1
0
0
0
0
0
3
2
176
0
0
0
1
0
149
0
1
0
0
1
1
2
0
0
0
1
0
1
0
0
0
0
0
1
1
0
0
0
1
0
0
3
0
0
0
0
0
1
147
0
0
2
1
0
0
0
1
0
0
0
0
0
1
0
119
0
1
0
1
0
0
0
0
0
0
1
0
2
0
4
0
0
0
2
0
1
0
0
0
0
0
1
2
0
0
0
3
0
0
119
1
0
0
0
1
2
0
0
1
0
0
2
3
0
0
0
0
1
0
2
0
0
1
0
3
0
175
3
1
0
0
1
1
1
148
0
2
...

result:

ok 5000 numbers

Test #8:

score: 0
Accepted
time: 5ms
memory: 29656kb

input:

14
5000 5000
478 4898
4898 1538
1538 4066
4066 1915
1915 3513
3513 3947
3947 4661
4661 1122
1122 1344
1344 2121
2121 4274
4274 3297
3297 4948
4948 655
655 4902
4902 4025
4025 4127
4127 4000
4000 3705
3705 4199
4199 635
635 3369
3369 2292
2292 4309
4309 4868
4868 4282
4282 3075
3075 4326
4326 4092
40...

output:

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

result:

ok 5000 numbers

Subtask #4:

score: 0
Wrong Answer

Test #9:

score: 13
Accepted
time: 96ms
memory: 56200kb

input:

13
100000 100000
91699 52443
52443 41748
41748 32330
32330 42277
42277 80707
80707 97074
97074 84439
84439 73656
73656 94232
94232 19271
19271 64725
64725 68032
68032 15074
15074 98785
98785 84234
84234 63617
63617 85713
85713 32965
32965 90099
90099 95398
95398 84273
84273 90891
90891 89305
89305 9...

output:

2
2
0
0
0
2
0
0
1
3
0
1
0
1
1
2
1
3
2
0
0
3
1
0
1
2
2
0
1
0
1
0
2
0
3
0
2
2
0
0
1
1
0
0
0
2
0
2
0
1
2
3
0
2
0
1
2
0
0
1
0
0
3
2
1
0
0
1
0
3
3
0
0
0
0
3
3
1
1
1
1
0
3
2
0
2
3
1
1
1
0
3
0
0
1
0
0
0
1
1
1
0
0
1
2
0
0
1
2
1
2
1
0
2
2
2
2
1
1
1
1
2
0
1
0
0
0
0
0
0
0
2
3
2
0
2
1
0
3
2
0
0
1
0
2
2
3
2
2
0
...

result:

ok 100000 numbers

Test #10:

score: -13
Wrong Answer
time: 111ms
memory: 55652kb

input:

13
100000 100000
57624 99869
99869 80198
80198 62843
62843 7883
7883 52607
52607 69363
69363 97085
97085 63315
63315 86299
86299 96455
96455 76868
76868 43868
43868 54746
54746 90151
90151 63572
63572 92398
92398 79264
79264 66180
66180 61719
61719 97795
97795 91813
91813 98698
98698 81039
81039 904...

output:

1
2
1
0
1
0
0
2
0
0
0
2
2
2
0
0
1
3
1
1
0
0
0
0
3
1
2
1
3
0
1
0
0
0
0
0
0
0
0
0
1
0
3
1
0
0
1
1
2
0
0
0
0
0
1
0
0
1
0
0
2
0
0
0
2
0
2
0
1
1
0
0
0
1
0
0
1
3
2
1
0
1
3
1
0
0
0
0
0
0
0
1
0
0
2
0
0
0
0
0
3
3
3
0
0
1
0
0
2
1
0
1
3
0
2
1
0
0
2
1
2
3
2
2
0
2
0
0
0
2
0
0
0
0
3
1
3
0
0
0
0
2
2
0
2
0
0
1
0
2
...

result:

wrong answer 33491st numbers differ - expected: '3', found: '4'

Subtask #5:

score: 12
Accepted

Test #13:

score: 12
Accepted
time: 54ms
memory: 38636kb

input:

12
100000 100000
93214 84598
93214 56491
93214 84251
93214 79335
93214 71720
93214 77307
93214 95507
93214 95410
93214 40328
93214 86071
93214 45088
93214 66766
93214 79723
93214 88378
93214 89470
93214 88357
93214 88637
93214 30576
93214 90846
93214 53961
93214 41155
93214 46341
93214 83568
93214 9...

output:

50089
0
0
0
1
50086
0
1
0
50086
50085
0
0
50088
1
50088
0
1
1
50088
50087
50088
0
50088
1
50088
1
0
50087
50086
50085
0
50087
50086
0
50088
50089
0
1
50088
1
50090
0
0
50089
1
0
1
0
50090
50089
1
1
1
1
0
50087
50088
50089
1
50087
50086
50085
50086
50087
0
1
0
50085
1
0
1
50085
1
50085
0
50085
0
0
0
...

result:

ok 100000 numbers

Test #14:

score: 0
Accepted
time: 42ms
memory: 37500kb

input:

12
100000 100000
87813 88402
87813 95508
87813 98893
87813 72683
87813 30574
87813 51137
87813 97898
87813 59020
87813 76017
87813 98656
87813 78075
87813 85721
87813 87306
87813 9176
87813 90004
87813 38369
87813 86573
87813 94026
87813 48667
87813 47642
87813 86402
87813 91112
87813 99092
87813 94...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 100000 numbers

Test #15:

score: 0
Accepted
time: 56ms
memory: 38760kb

input:

12
100000 100000
95193 86523
95193 66880
95193 88385
95193 95738
95193 64581
95193 77273
95193 81211
95193 67702
95193 37065
95193 31294
95193 98186
95193 97664
95193 91076
95193 84680
95193 90759
95193 38467
95193 97823
95193 37082
95193 89129
95193 93058
95193 52159
95193 53257
95193 95170
95193 3...

output:

1
50156
1
50156
0
50156
1
0
0
50156
50157
50158
50157
50156
50155
0
0
0
50157
1
50157
0
1
50156
1
1
0
0
0
1
1
1
50155
50156
1
50158
1
0
50155
0
0
50156
0
50156
0
50154
1
50154
50153
50154
0
0
0
50156
50155
50154
50153
50152
50151
1
0
50152
50153
50154
0
50154
0
50154
1
50154
0
0
0
50150
50151
1
0
50...

result:

ok 100000 numbers

Test #16:

score: 0
Accepted
time: 52ms
memory: 38564kb

input:

12
100000 100000
83073 96684
83073 75419
83073 71759
83073 57231
83073 99832
83073 92865
83073 92164
83073 53823
83073 31154
83073 28408
83073 88848
83073 7334
83073 98219
83073 86129
83073 95290
83073 45169
83073 95392
83073 57686
83073 61365
83073 92684
83073 51746
83073 40660
83073 95954
83073 96...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 100000 numbers

Subtask #6:

score: 11
Accepted

Test #17:

score: 11
Accepted
time: 106ms
memory: 49624kb

input:

11
100000 100000
2 29108
3 77506
4 7190
5 41884
7 9630
14 78381
15 10036
16 13569
19 80204
20 17573
24 86568
26 88304
28 91742
31 50889
32 29659
33 7909
37 61160
38 88144
40 36396
41 8142
43 20787
46 75458
48 23406
50 56495
61 74778
63 97662
70 75429
73 52031
76 49902
77 56882
81 13357
85 70152
89 3...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 100000 numbers

Test #18:

score: 0
Accepted
time: 86ms
memory: 47496kb

input:

11
100000 100000
5157 83042
5157 99808
5157 84092
5157 97178
5157 61850
5157 86984
5157 39797
5157 91201
5157 23694
5157 64810
5157 65775
5157 95780
5157 61901
5157 91192
5157 18334
5157 73610
5157 97423
5157 64103
5157 60144
5157 69149
5157 35873
5157 62909
5157 40770
5157 79692
5157 78154
5157 530...

output:

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

result:

ok 100000 numbers

Test #19:

score: 0
Accepted
time: 82ms
memory: 48812kb

input:

11
100000 100000
94421 77686
77686 99527
99527 89261
89261 95025
95025 99584
99584 59157
59157 97744
97744 10371
10371 68733
68733 81763
81763 84146
84146 32495
32495 99816
99816 15431
15431 80957
80957 31637
31637 73107
73107 88321
88321 81735
81735 76270
76270 54816
54816 18030
18030 96927
96927 6...

output:

1
1
1
1
1
1
1
1
1
1
1
1
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
6
6
6
6
6
6
6
6
6
6
6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 numbers

Test #20:

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

input:

11
100000 100000
79899 89862
91077 54657
42712 54657
85707 54657
74910 54657
84672 54657
72168 54657
84967 54657
47024 54657
17669 54657
54773 54657
78042 54657
51014 54657
26960 54657
75786 54657
97374 54657
66664 54657
60080 54657
68189 54657
79232 54657
13559 54657
58661 54657
59686 54657
72186 5...

output:

149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
...

result:

ok 100000 numbers

Subtask #7:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

0%

Subtask #8:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

0%