QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#683672#3873. Towers0xyz11 393ms138288kbC++142.0kb2024-10-27 22:39:282024-10-27 22:39:30

Judging History

This is the latest submission verdict.

  • [2024-10-27 22:39:30]
  • Judged
  • Verdict: 11
  • Time: 393ms
  • Memory: 138288kb
  • [2024-10-27 22:39:28]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int _=36e5,m=12e5;
int n,g[_],h[_],dp[_],dx[_],dy[_],hx[_],hy[_];
queue<int>qx,qy,qp;
struct L{int x,y,l,r,u,d;}p[_];
struct H{int x,y,z,w;}a[_];
inline void upd(int c){
	if(c<=m+m||g[c]&&h[c])return;
	g[c]=(p[c].l<=m+m)|(p[c].r<=m+m);
	h[c]=(p[c].u<=m+m)|(p[c].d<=m+m);
	if(g[c]&&h[c]){
		a[c-m-m].w=1;qp.push(c);
		if(!dx[p[c].x]&&++hx[p[c].x]==2)qx.push(p[c].x);
		if(!dy[p[c].y]&&++hy[p[c].y]==2)qy.push(p[c].y);
	}
}
inline void add(int c,int x,int y){
	p[c]={x,y,p[m+x].l,m+x,p[y].u,y};
	p[p[c].l].r=p[p[c].r].l=p[p[c].u].d=p[p[c].d].u=c;
}
inline void dep(int c){
	if(dp[c])return;
	dp[c]=1;
	p[p[c].l].r=p[c].r;
	p[p[c].r].l=p[c].l;
	p[p[c].u].d=p[c].d;
	p[p[c].d].u=p[c].u;
	upd(p[c].l);
	upd(p[c].r);
	upd(p[c].u);
	upd(p[c].d);
}
void dex(int x){
	if(dx[x])return;
	dx[x]=1;
	for(int i=p[p[m+x].r].r;i!=p[m+x].l;i=p[i].r)dep(i);
}
void dey(int y){
	if(dy[y])return;
	dy[y]=1;
	for(int i=p[p[y].d].d;i!=p[y].u;i=p[i].d)dep(i);
}
int main(){
	//freopen("qwq.in","r",stdin);
	//freopen("qwq.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=m;i++)p[i]={0,i,i-1,i+1,i,i};
	for(int i=m+1;i<=m+m;i++)p[i]={i-m,0,i,i,i-1,i+1};
	p[0]={0,0,m,1,m+m,m+1};p[m].r=p[m+1].u=p[m+m].d=0;
	for(int i=1;i<=n;i++)cin>>a[i].x>>a[i].y,a[i].z=i;
	sort(a+1,a+n+1,[&](H u,H v){return u.x==v.x?u.y<v.y:u.x<v.x;});
	for(int i=1;i<=n;i++)add(m+m+i,a[i].x,a[i].y);
	//for(int i=0;i<=m+m+n;i++)cout<<p[i].x<<' '<<p[i].y<<' '<<p[i].l<<' '<<p[i].r<<' '<<p[i].u<<' '<<p[i].d<<'\n';
	for(int i=1;i<=n;i++)upd(m+m+i);
	while(1){
		//for(int i=1;i<=n;i++)cout<<a[i].w;
		//cout<<'\n';
		int fl=0;
		while(qx.size())fl=1,dex(qx.front()),qx.pop();
		while(qy.size())fl=1,dey(qy.front()),qy.pop();
		while(qp.size())fl=1,dep(qp.front()),qp.pop();
		if(!fl)break;
	}
	sort(a+1,a+n+1,[&](H u,H v){return u.z<v.z;});
	for(int i=1;i<=n;i++)cout<<a[i].w;
	return 0;
}

詳細信息

Subtask #1:

score: 5
Accepted

Test #1:

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

input:

2
869400 218695
664808 31410

output:

11

result:

ok 

Test #2:

score: 5
Accepted
time: 3ms
memory: 67260kb

input:

2
195447 154323
271823 133730

output:

11

result:

ok 

Test #3:

score: 5
Accepted
time: 3ms
memory: 65060kb

input:

3
751594 545975
951568 859051
621150 686048

output:

111

result:

ok 

Test #4:

score: 5
Accepted
time: 3ms
memory: 65056kb

input:

3
404592 259430
770816 43371
147329 582162

output:

111

result:

ok 

Test #5:

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

input:

3
401670 296316
401670 809250
401670 595959

output:

110

result:

ok 

Test #6:

score: 5
Accepted
time: 5ms
memory: 65052kb

input:

3
657802 927690
657802 872623
657802 83083

output:

101

result:

ok 

Test #7:

score: 5
Accepted
time: 3ms
memory: 67316kb

input:

3
759291 185618
759291 386687
759291 100713

output:

011

result:

ok 

Test #8:

score: 5
Accepted
time: 11ms
memory: 67312kb

input:

3
997737 106763
684497 106763
412296 106763

output:

101

result:

ok 

Test #9:

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

input:

3
305388 642835
538743 642835
608034 642835

output:

101

result:

ok 

Test #10:

score: 5
Accepted
time: 7ms
memory: 65064kb

input:

3
420692 202248
784725 202248
931773 202248

output:

101

result:

ok 

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #11:

score: 11
Accepted
time: 7ms
memory: 64956kb

input:

16
296455 404592
582162 770816
807435 536085
259430 536085
112538 770816
610915 369095
582162 369095
94860 147329
112538 147329
296455 61932
259430 147329
807435 369095
610915 404592
807435 309191
807435 61932
94860 770816

output:

1111011101101011

result:

ok 

Test #12:

score: 11
Accepted
time: 0ms
memory: 67148kb

input:

16
561476 595959
58474 595959
58474 664431
105001 143086
809250 250085
58474 250085
789588 281386
350332 161786
789588 250085
561476 281386
296316 401670
296316 250085
350332 595959
296316 161786
350332 281386
58474 281386

output:

1011111101101100

result:

ok 

Test #13:

score: 11
Accepted
time: 3ms
memory: 67232kb

input:

16
316904 170612
433799 125553
316904 125553
859728 341680
433799 32398
872623 388831
859728 83083
872623 83083
584763 388831
148042 861814
316904 861814
927690 861814
148042 83083
148042 32398
584763 657802
905375 388831

output:

1111101111010111

result:

ok 

Test #14:

score: 11
Accepted
time: 10ms
memory: 67084kb

input:

16
386687 759291
995919 169567
788489 197826
185618 713079
198743 100713
995919 372561
916765 169567
185618 763504
386687 169567
832084 763504
832084 759291
386687 292594
185618 197826
386687 197826
832084 197826
916765 759291

output:

1100110111001011

result:

ok 

Test #15:

score: 11
Accepted
time: 4ms
memory: 65148kb

input:

16
716236 20497
587980 648488
587980 642779
412708 997737
369271 642779
106763 71182
412708 642779
173374 869560
684497 648488
587980 945118
106763 648488
716236 412296
587980 71182
412708 869560
369271 869560
412708 412296

output:

1001110111111011

result:

ok 

Test #16:

score: 0
Wrong Answer
time: 0ms
memory: 65104kb

input:

16
642835 173421
512014 309394
610395 518804
538743 305388
493101 608034
610395 85927
214511 309394
512014 173421
214511 608034
493101 85927
512014 85927
538743 309394
538743 608034
512014 518804
610395 309394
214511 518804

output:

1111011111001100

result:

wrong answer 

Subtask #3:

score: 0
Wrong Answer

Test #26:

score: 0
Wrong Answer
time: 17ms
memory: 73016kb

input:

92690
1 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 6...

output:

100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

wrong answer 

Subtask #4:

score: 6
Accepted

Test #38:

score: 6
Accepted
time: 330ms
memory: 122820kb

input:

1000000
1 18543
4 40327
7 19084
8 44274
10 42366
12 22173
13 9862
15 44706
19 48070
21 13389
24 39273
26 18680
27 46858
28 46126
32 27753
34 28289
36 12220
38 39235
42 28505
45 47348
46 34220
48 47551
50 49156
54 8856
55 25515
56 21932
58 24482
59 20686
61 41381
66 30112
67 44504
70 24510
71 26418
7...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #39:

score: 6
Accepted
time: 346ms
memory: 122572kb

input:

1000000
2 21155
4 41232
6 20287
7 46837
9 38631
11 6901
15 43358
16 10142
19 28642
20 33035
21 27599
24 20951
27 12983
30 11366
31 20539
32 10621
34 30734
37 6043
41 5841
43 8213
46 8479
47 12328
49 5893
50 22485
51 39760
52 8737
54 43535
56 24827
57 15847
59 8402
61 23013
65 17937
66 18072
69 36863...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110111111111111111111111111111111111111111111111111111111111111111111110...

result:

ok 

Test #40:

score: 6
Accepted
time: 349ms
memory: 123048kb

input:

1000000
1 44308
3 27877
4 48227
6 27660
8 26210
9 43909
10 11659
11 34110
13 39632
15 7390
17 40561
20 7928
24 24624
25 9113
27 28937
29 23508
30 41645
32 38110
34 10958
36 37937
37 46339
38 41683
40 7125
41 11569
42 9531
44 29591
45 45867
46 48643
49 7654
50 33740
52 26995
55 13345
57 22001
59 1247...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #41:

score: 6
Accepted
time: 346ms
memory: 122140kb

input:

1000000
2 31149
4 25209
7 47632
9 13365
10 23457
12 38193
14 6534
15 33175
16 12181
19 26329
21 7294
24 25786
26 39155
27 12081
29 31350
33 16989
36 34867
38 31751
39 38661
41 17345
44 24470
47 41098
48 41797
51 27139
53 40756
54 15934
59 28395
63 46853
64 46994
66 14330
67 46212
69 23352
70 8115
72...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #42:

score: 6
Accepted
time: 343ms
memory: 122172kb

input:

1000000
1 38450
2 25296
5 6604
7 5068
8 44733
10 49030
11 48217
12 11533
14 7208
15 37097
16 13793
21 41955
23 45683
25 31223
27 27252
28 26319
30 9053
35 41698
36 18276
41 20100
42 32537
44 41677
46 37754
48 28572
50 44106
52 43957
56 21750
57 21732
61 12737
64 45597
66 42872
67 9711
68 25897
69 41...

output:

111111111111111111111111111111111101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101111111111111111111111111111111...

result:

ok 

Test #43:

score: 6
Accepted
time: 393ms
memory: 136096kb

input:

1000000
2 880200
3 405629
4 505753
8 827569
9 249542
15 230517
19 801043
21 393006
23 167265
25 246534
28 302737
32 665950
33 146821
35 765079
36 349562
37 691530
39 446351
40 692089
42 997833
43 688018
44 185484
46 236680
48 414992
50 677116
52 922426
55 930670
57 429844
58 978728
60 671339
62 2508...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #44:

score: 6
Accepted
time: 358ms
memory: 138140kb

input:

1000000
1 905626
2 338678
5 553579
7 552200
8 784328
10 112106
11 928788
12 719285
14 737963
16 204427
17 313941
19 504387
21 61669
22 430904
24 75978
25 248640
26 317625
29 619690
31 193568
32 966216
34 851031
36 964644
37 111735
38 50038
39 436056
41 165749
42 733480
44 45671
46 501053
47 394829
5...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #45:

score: 6
Accepted
time: 353ms
memory: 138288kb

input:

1000000
1 524431
7 627962
11 814078
12 347856
14 929279
16 407341
19 77713
22 938040
25 611644
26 421438
27 39608
29 875594
31 950490
33 938280
35 569458
36 399569
37 565433
39 200899
41 512932
42 892335
45 785082
49 138075
52 556802
55 964794
56 23280
59 765396
63 56095
65 334489
67 116493
68 64798...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #46:

score: 6
Accepted
time: 361ms
memory: 138092kb

input:

1000000
2 793441
5 57521
6 977344
8 152182
9 474068
10 56149
12 388264
15 295964
16 404775
18 333353
19 544761
21 208229
22 409823
26 71607
27 49633
30 748788
32 202839
35 362645
37 896518
38 500521
40 561975
41 682139
42 328620
44 733819
45 687203
47 184074
50 496029
52 831999
53 302832
54 228451
5...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #47:

score: 6
Accepted
time: 380ms
memory: 136128kb

input:

1000000
1 895838
2 325421
3 954723
4 164307
6 340013
7 825549
10 3829
14 523251
15 52480
17 752743
19 256730
21 743287
24 342268
25 348119
27 164916
28 961505
31 446402
33 903443
37 867901
39 765398
40 319469
41 495869
43 425064
45 442601
48 826731
51 870551
53 419326
54 456719
57 200828
59 642520
6...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Subtask #5:

score: 0
Skipped

Dependency #2:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Wrong Answer

Test #85:

score: 0
Wrong Answer
time: 271ms
memory: 137924kb

input:

1000000
1 602300
1 778881
2 397065
3 291452
3 678039
5 235300
6 499367
8 8597
10 327718
10 516489
12 416542
12 440048
13 284169
13 383581
13 642202
13 770858
14 378154
14 710033
15 905531
16 50155
17 142259
19 395613
19 500321
20 358934
21 461772
24 562953
24 995887
25 421244
27 900412
29 301006
31 ...

output:

111111111111100111111111111111101111110111101101111111111111111111111111111111111101111110111111111111110011111011111111111111111111111001111011111001100111101111111111000111111111111111000111111111101111111011111111111111110111111111111111111101111111110111111111011111111111111111111111110110011111...

result:

wrong answer