QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#338326#4000. Dynamic ReachabilityLarunatrecyAC ✓2412ms36296kbC++142.4kb2024-02-25 20:36:522024-02-25 20:36:53

Judging History

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

  • [2024-02-25 20:36:53]
  • 评测
  • 测评结果:AC
  • 用时:2412ms
  • 内存:36296kb
  • [2024-02-25 20:36:52]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+7+7;
const int B = 300;
bitset<2*B+3> F[N/2],E[B*2+2],cur;
int n,m,q,deg[N],ord[N],dft=0;
vector<int> G[N];
void add(int x,int y)
{
	G[x].push_back(y);
}
int u[N],v[N];
int qc[N],qu[N],qv[N],col[N];
bool key[N],cut[N];
int spec[N],id[N],idx=0;
int scc[N],low[N],dfn[N],num=0,cnt=0;
bool ins[N];
stack<int> st;
void tarjan(int x)
{
	dfn[x]=low[x]=++num;
	ins[x]=1;
	st.push(x);
	for(int y:G[x])
	{
		if(!dfn[y])
		{
			tarjan(y);
			low[x]=min(low[x],low[y]);
		}
		else if(ins[y])low[x]=min(low[x],dfn[y]);
	}
	if(dfn[x]==low[x])
	{
		int c=++cnt;
		int y=0;
		do
		{
			y=st.top();
			scc[y]=c;
			st.pop();
			ins[y]=0;
		}while(y!=x);
	}
}
queue<int> Q;
vector<int> S[N];
void init()
{
	for(int i=1;i<=cnt;i++)S[i].clear(),F[i].reset();
	for(int i=1;i<=n;i++)dfn[i]=low[i]=scc[i]=id[i]=0,ins[i]=key[i]=0,G[i].clear();
	for(int i=1;i<=idx;i++)spec[i]=0;
	for(int i=1;i<=m;i++)cut[i]=0;
	dft=idx=cnt=num=0;
}
void qsolve(int l,int r)
{
	for(int i=l;i<=r;i++)
	if(qc[i]==1)key[u[qu[i]]]=key[v[qu[i]]]=1,cut[qu[i]]=1;
	else key[qu[i]]=key[qv[i]]=1;
	for(int i=1;i<=m;i++)if(!cut[i]&&col[i])add(u[i],v[i]);
	for(int i=1;i<=n;i++)if(!dfn[i])tarjan(i);
	for(int i=1;i<=m;i++)if(!cut[i]&&col[i]&&scc[u[i]]!=scc[v[i]])S[scc[u[i]]].push_back(scc[v[i]]),deg[scc[v[i]]]++;
	for(int i=1;i<=cnt;i++)if(!deg[i])Q.push(i);
	while(!Q.empty())
	{
		int x=Q.front();
		Q.pop();
		ord[++dft]=x;
		for(int y:S[x])
		{
			--deg[y];
			if(!deg[y])Q.push(y);
		}
	}
	for(int i=1;i<=n;i++)if(key[i])spec[id[i]=++idx]=i,F[scc[i]][idx]=1;
	for(int i=dft;i>=1;i--){int x=ord[i];for(int y:S[x])F[x]|=F[y];}
	for(int j=l;j<=r;j++)
	if(qc[j]==1) col[qu[j]]^=1;
	else 
	{
		for(int i=1;i<=idx;i++)E[i]=F[scc[spec[i]]];
		for(int i=l;i<=r;i++)if(qc[i]==1&&col[qu[i]])E[id[u[qu[i]]]][id[v[qu[i]]]]=1;
		cur.set();
		cur.reset(id[qu[j]]);
		Q.push(id[qu[j]]);
		while(!Q.empty())
		{
			int x=Q.front();
			Q.pop();
			for(int y;(y=(cur&E[x])._Find_first())<=idx;cur.reset(y))
		 	Q.push(y);
		}
		if(cur[id[qv[j]]])printf("NO\n");
		else printf("YES\n");
	}
	init();
}
int main()
{
	cin>>n>>m>>q;
	for(int i=1;i<=m;i++)scanf("%d %d",&u[i],&v[i]),col[i]=1;
	for(int i=1;i<=q;i++)
	{
		scanf("%d %d",&qc[i],&qu[i]);
		if(qc[i]==2)scanf("%d",&qv[i]);
	}
	for(int i=1;i<=q;i+=B)qsolve(i,min(i+B-1,q));
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 14280kb

input:

5 6 7
1 2
1 3
2 4
3 4
3 5
4 5
2 1 5
2 2 3
1 3
1 4
2 1 4
1 3
2 1 5

output:

YES
NO
NO
YES

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 2052ms
memory: 22712kb

input:

50000 100000 100000
36671 44121
25592 44321
13226 46463
13060 25694
14021 20087
22881 38333
34655 47774
22868 26462
31154 48710
27491 32365
5874 47497
17622 28600
1886 14193
22315 23656
14973 22704
1335 25384
22612 34915
2852 48213
23334 25519
24342 28784
6238 36125
14598 39494
33069 34250
2123 3059...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok 50000 lines

Test #3:

score: 0
Accepted
time: 2054ms
memory: 22472kb

input:

50000 100000 100000
27059 36120
32335 41190
9436 29046
36520 44281
25005 39115
37096 43321
11891 38873
10439 31878
19154 25918
26756 44170
9594 16092
9920 23747
17107 35055
31401 35308
17102 35604
18635 26767
27925 29726
7012 14266
973 21483
622 41029
25685 31856
36951 46699
18103 46885
9911 18465
2...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok 50000 lines

Test #4:

score: 0
Accepted
time: 2347ms
memory: 21012kb

input:

50000 100000 100000
7 14
14 21
21 28
28 35
35 42
42 49
49 56
56 63
63 70
70 77
77 84
84 91
91 98
98 105
105 112
112 119
119 126
126 133
133 140
140 147
147 154
154 161
161 168
168 175
175 182
182 189
189 196
196 203
203 210
210 217
217 224
224 231
231 238
238 245
245 252
252 259
259 266
266 273
273 ...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
N...

result:

ok 100000 lines

Test #5:

score: 0
Accepted
time: 2061ms
memory: 22568kb

input:

50000 100000 100000
233 466
466 699
699 932
932 1165
1165 1398
1398 1631
1631 1864
1864 2097
2097 2330
2330 2563
2563 2796
2796 3029
3029 3262
3262 3495
3495 3728
3728 3961
3961 4194
4194 4427
4427 4660
4660 4893
4893 5126
5126 5359
5359 5592
5592 5825
5825 6058
6058 6291
6291 6524
6524 6757
6757 69...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok 50000 lines

Test #6:

score: 0
Accepted
time: 2048ms
memory: 22456kb

input:

50000 100000 100000
13 26
26 39
39 52
52 65
65 78
78 91
91 104
104 117
117 130
130 143
143 156
156 169
169 182
182 195
195 208
208 221
221 234
234 247
247 260
260 273
273 286
286 299
299 312
312 325
325 338
338 351
351 364
364 377
377 390
390 403
403 416
416 429
429 442
442 455
455 468
468 481
481 4...

output:

NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok 50000 lines

Test #7:

score: 0
Accepted
time: 2064ms
memory: 22652kb

input:

50000 100000 100000
4 8
8 12
12 16
16 20
20 24
24 28
28 32
32 36
36 40
40 44
44 48
48 52
52 56
56 60
60 64
64 68
68 72
72 76
76 80
80 84
84 88
88 92
92 96
96 100
100 104
104 108
108 112
112 116
116 120
120 124
124 128
128 132
132 136
136 140
140 144
144 148
148 152
152 156
156 160
160 164
164 168
16...

output:

YES
YES
NO
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
NO
NO
NO
NO
YES
YES
NO
NO
YES
NO
NO
NO
NO
NO
YES
YES
NO
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
YES
NO
YES
YES
NO
NO
YES
NO
YES
YES
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
N...

result:

ok 50000 lines

Test #8:

score: 0
Accepted
time: 2059ms
memory: 22572kb

input:

50000 100000 100000
2 4
4 6
6 8
8 10
10 12
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 64
64 66
66 68
68 70
70 72
72 74
74 76
76 78
78 80
80 82
82 84
84 86
86 88
88 90
90 92
92 94
94 96
96 98...

output:

NO
NO
NO
NO
NO
NO
YES
YES
YES
YES
NO
YES
YES
YES
NO
NO
YES
YES
NO
NO
NO
NO
YES
NO
YES
YES
NO
YES
NO
YES
YES
NO
NO
YES
YES
YES
NO
YES
YES
NO
NO
YES
YES
YES
NO
NO
YES
NO
YES
NO
NO
NO
YES
YES
YES
NO
YES
NO
NO
YES
YES
YES
YES
YES
YES
NO
NO
YES
NO
NO
YES
NO
YES
YES
NO
NO
NO
NO
YES
NO
NO
NO
YES
YES
NO
YES...

result:

ok 50000 lines

Test #9:

score: 0
Accepted
time: 1938ms
memory: 22752kb

input:

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

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
...

result:

ok 50000 lines

Test #10:

score: 0
Accepted
time: 1867ms
memory: 22876kb

input:

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

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
NO
YES
YES
NO
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YE...

result:

ok 50000 lines

Test #11:

score: 0
Accepted
time: 1923ms
memory: 22572kb

input:

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

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
Y...

result:

ok 50000 lines

Test #12:

score: 0
Accepted
time: 2023ms
memory: 22096kb

input:

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

output:

YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
N...

result:

ok 50000 lines

Test #13:

score: 0
Accepted
time: 1660ms
memory: 26240kb

input:

50000 100000 100000
12500 12501
12501 12502
12502 12503
12503 12504
12504 12505
12505 12506
12506 12507
12507 12508
12508 12509
12509 12510
12510 12511
12511 12512
12512 12513
12513 12514
12514 12515
12515 12516
12516 12517
12517 12518
12518 12519
12519 12520
12520 12521
12521 12522
12522 12523
1252...

output:

NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES...

result:

ok 50000 lines

Test #14:

score: 0
Accepted
time: 1653ms
memory: 26340kb

input:

50000 100000 100000
12500 12501
12501 12502
12502 12503
12503 12504
12504 12505
12505 12506
12506 12507
12507 12508
12508 12509
12509 12510
12510 12511
12511 12512
12512 12513
12513 12514
12514 12515
12515 12516
12516 12517
12517 12518
12518 12519
12519 12520
12520 12521
12521 12522
12522 12523
1252...

output:

NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES...

result:

ok 50000 lines

Test #15:

score: 0
Accepted
time: 1632ms
memory: 26644kb

input:

50000 100000 100000
12500 12501
12501 12502
12502 12503
12503 12504
12504 12505
12505 12506
12506 12507
12507 12508
12508 12509
12509 12510
12510 12511
12511 12512
12512 12513
12513 12514
12514 12515
12515 12516
12516 12517
12517 12518
12518 12519
12519 12520
12520 12521
12521 12522
12522 12523
1252...

output:

NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
N...

result:

ok 50000 lines

Test #16:

score: 0
Accepted
time: 1613ms
memory: 26340kb

input:

50000 100000 100000
12500 12501
12501 12502
12502 12503
12503 12504
12504 12505
12505 12506
12506 12507
12507 12508
12508 12509
12509 12510
12510 12511
12511 12512
12512 12513
12513 12514
12514 12515
12515 12516
12516 12517
12517 12518
12518 12519
12519 12520
12520 12521
12521 12522
12522 12523
1252...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
N...

result:

ok 50000 lines

Test #17:

score: 0
Accepted
time: 2192ms
memory: 25912kb

input:

50000 100000 100000
24500 24501
24501 24502
24502 24503
24503 24504
24504 24505
24505 24506
24506 24507
24507 24508
24508 24509
24509 24510
24510 24511
24511 24512
24512 24513
24513 24514
24514 24515
24515 24516
24516 24517
24517 24518
24518 24519
24519 24520
24520 24521
24521 24522
24522 24523
2452...

output:

NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES...

result:

ok 98000 lines

Test #18:

score: 0
Accepted
time: 2365ms
memory: 25228kb

input:

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

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
...

result:

ok 100000 lines

Test #19:

score: 0
Accepted
time: 2411ms
memory: 21252kb

input:

50000 100000 100000
2 4
4 6
6 8
8 10
10 12
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 64
64 66
66 68
68 70
70 72
72 74
74 76
76 78
78 80
80 82
82 84
84 86
86 88
88 90
90 92
92 94
94 96
96 98...

output:

NO
YES
YES
YES
NO
NO
YES
YES
YES
NO
YES
YES
NO
YES
YES
NO
YES
NO
NO
NO
NO
NO
YES
YES
NO
YES
NO
YES
YES
YES
NO
NO
YES
NO
NO
NO
YES
YES
YES
YES
NO
YES
NO
NO
YES
YES
YES
NO
NO
YES
YES
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
YES
NO
NO
YES
YES
NO
NO
YES
NO
NO
...

result:

ok 100000 lines

Test #20:

score: 0
Accepted
time: 2412ms
memory: 21216kb

input:

50000 100000 100000
3 6
6 9
9 12
12 15
15 18
18 21
21 24
24 27
27 30
30 33
33 36
36 39
39 42
42 45
45 48
48 51
51 54
54 57
57 60
60 63
63 66
66 69
69 72
72 75
75 78
78 81
81 84
84 87
87 90
90 93
93 96
96 99
99 102
102 105
105 108
108 111
111 114
114 117
117 120
120 123
123 126
126 129
129 132
132 13...

output:

YES
NO
NO
NO
YES
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
YES
NO
NO
YES
NO
YES
NO
NO
NO
NO
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
NO
YES
NO
YES
NO
NO
NO
NO
YES
NO
NO
YES
NO
YES
YES
YES
YES
NO
NO
NO
NO
YES
YES
NO
NO
NO
YES
NO
NO
NO
YES
YES
NO
NO
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO...

result:

ok 100000 lines

Test #21:

score: 0
Accepted
time: 37ms
memory: 16536kb

input:

5000 10000 10000
4103 3044
1509 4745
3287 2269
1227 1146
3580 1636
4103 1040
1747 4633
1572 1188
4212 2110
633 4726
1390 511
3571 20
3491 1138
332 4118
3445 1002
3848 4285
2373 4520
2276 2638
4003 4209
1647 3074
372 374
4317 202
3969 2571
1459 3606
2006 1859
1985 1755
4443 3420
449 3964
539 2829
347...

output:

NO
YES
NO
NO
YES
NO
YES
YES
NO
NO
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
NO
YES
NO
NO
YES
YES
YES
NO
YES
YES
NO
NO
YES
NO
NO
NO
NO
NO
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
NO
NO
YES
NO
NO
YES
YES
NO
YES
NO
YES
YES
NO
NO
NO
YES
YES
NO
YES
YES
YES
YES
NO
NO
NO
NO
YES
YES
YES
YES
NO
YES
NO
YES
YES
Y...

result:

ok 5000 lines

Test #22:

score: 0
Accepted
time: 1993ms
memory: 36296kb

input:

50000 100000 100000
6061 22695
15954 27714
42835 31992
179 39077
21790 21794
12016 42264
25592 44016
9510 13155
41929 28310
27509 37593
27187 27022
41269 5119
3414 46640
17135 14546
33252 19903
32573 29689
15519 36864
31361 34103
41054 48474
1860 45033
46463 37990
35082 25907
22143 473
6195 19370
13...

output:

YES
YES
YES
NO
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
YES
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
NO
YES
NO
YES
YES
NO
NO
YES
NO
YES
NO
YES
NO
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
NO
YES
YES
NO
YES
YES
NO
YES
YES
YES
NO
Y...

result:

ok 50000 lines

Test #23:

score: 0
Accepted
time: 1970ms
memory: 36172kb

input:

50000 100000 100000
30380 30171
8714 21977
17910 23728
30792 35180
1097 6580
45454 42956
14954 6909
24599 12426
14136 36556
28901 29472
26695 24651
37956 14082
2515 31828
2289 29674
46083 46409
18706 29194
24371 229
31696 40513
48768 41897
27789 44824
10490 11482
6788 10306
15469 24437
14795 21470
4...

output:

YES
NO
NO
YES
YES
YES
YES
YES
NO
YES
NO
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
NO
YES
YES
NO
YES
YES
NO
YES
NO
NO
YES
NO
YES
YES
NO
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
YES
YES
NO
YES
YES
YES
NO
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
NO
NO
NO
NO
NO
YES
YES
YES
NO
YES
NO
NO
Y...

result:

ok 50000 lines

Test #24:

score: 0
Accepted
time: 2183ms
memory: 18976kb

input:

50000 100000 100000
7 14
14 21
21 28
28 35
35 42
42 49
49 56
56 63
63 70
70 77
77 84
84 91
91 98
98 105
105 112
112 119
119 126
126 133
133 140
140 147
147 154
154 161
161 168
168 175
175 182
182 189
189 196
196 203
203 210
210 217
217 224
224 231
231 238
238 245
245 252
252 259
259 266
266 273
273 ...

output:

NO
NO
YES
NO
NO
YES
YES
NO
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
NO
YES
NO
NO
YES
YES
NO
NO
YES
YES
YES
NO
NO
YES
YES
NO
YES
NO
NO
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
NO
NO
NO
YES
YES
YES
NO
NO
NO
NO
YES
YES
NO
YES
YES
YES
YES
NO
NO
YES
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
YES
NO
NO...

result:

ok 100000 lines

Test #25:

score: 0
Accepted
time: 1955ms
memory: 35780kb

input:

50000 100000 100000
233 466
466 699
699 932
932 1165
1165 1398
1398 1631
1631 1864
1864 2097
2097 2330
2330 2563
2563 2796
2796 3029
3029 3262
3262 3495
3495 3728
3728 3961
3961 4194
4194 4427
4427 4660
4660 4893
4893 5126
5126 5359
5359 5592
5592 5825
5825 6058
6058 6291
6291 6524
6524 6757
6757 69...

output:

YES
NO
NO
YES
YES
YES
NO
NO
NO
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
NO
YES
YES
YES
YES
YES
YES
YES
NO
YES
NO
YES
YES
YES
YES
YES
NO
NO
NO
YES
YES
YES
YES
NO
NO
NO
YES
NO
YES
YES
YES
NO
YES
YES
NO
YES
NO
NO
NO
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
NO
YES
NO
Y...

result:

ok 50000 lines

Test #26:

score: 0
Accepted
time: 1958ms
memory: 35996kb

input:

50000 100000 100000
13 26
26 39
39 52
52 65
65 78
78 91
91 104
104 117
117 130
130 143
143 156
156 169
169 182
182 195
195 208
208 221
221 234
234 247
247 260
260 273
273 286
286 299
299 312
312 325
325 338
338 351
351 364
364 377
377 390
390 403
403 416
416 429
429 442
442 455
455 468
468 481
481 4...

output:

YES
YES
YES
NO
YES
NO
YES
NO
NO
YES
NO
YES
YES
NO
YES
NO
YES
YES
YES
NO
YES
NO
YES
YES
YES
YES
NO
NO
NO
NO
YES
YES
NO
NO
NO
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
NO
YES
YES
NO
YES
NO
YES
NO
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YE...

result:

ok 50000 lines

Test #27:

score: 0
Accepted
time: 1917ms
memory: 35292kb

input:

50000 100000 100000
4 8
8 12
12 16
16 20
20 24
24 28
28 32
32 36
36 40
40 44
44 48
48 52
52 56
56 60
60 64
64 68
68 72
72 76
76 80
80 84
84 88
88 92
92 96
96 100
100 104
104 108
108 112
112 116
116 120
120 124
124 128
128 132
132 136
136 140
140 144
144 148
148 152
152 156
156 160
160 164
164 168
16...

output:

NO
NO
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
NO
YES
YES
YES
NO
NO
YES
YES
YES
NO
YES
YES
NO
YES
NO
YES
NO
YES
YES
YES
YES
NO
YES
YES
NO
NO
YES
NO
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
NO
YES
YES
YES
YES
NO
NO
NO
NO
YES
NO
NO
YES
YES
YES
NO
YES
YES
YES
NO
YES
NO
YES
YES
YES...

result:

ok 50000 lines

Test #28:

score: 0
Accepted
time: 1830ms
memory: 34876kb

input:

50000 100000 100000
2 4
4 6
6 8
8 10
10 12
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 64
64 66
66 68
68 70
70 72
72 74
74 76
76 78
78 80
80 82
82 84
84 86
86 88
88 90
90 92
92 94
94 96
96 98...

output:

YES
YES
NO
NO
NO
NO
NO
YES
YES
YES
YES
YES
NO
YES
YES
NO
YES
YES
YES
NO
YES
NO
YES
YES
YES
NO
YES
YES
YES
YES
NO
YES
NO
NO
NO
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
NO
YES
YES
NO
NO
YES
NO
NO
YES
YES
YES
NO
NO
YES
YES
YES
YES
NO
NO
NO
NO
YES
YES
NO
NO
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
NO
YES...

result:

ok 50000 lines

Test #29:

score: 0
Accepted
time: 1670ms
memory: 32068kb

input:

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

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
...

result:

ok 50000 lines

Test #30:

score: 0
Accepted
time: 1677ms
memory: 32192kb

input:

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

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
...

result:

ok 50000 lines

Test #31:

score: 0
Accepted
time: 1710ms
memory: 31356kb

input:

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

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
...

result:

ok 50000 lines

Test #32:

score: 0
Accepted
time: 457ms
memory: 20132kb

input:

22222 44442 99996
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51...

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
...

result:

ok 33333 lines