QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#562113#3873. Towershansiyuan0 496ms106920kbC++141.6kb2024-09-13 15:09:062024-09-13 15:09:07

Judging History

This is the latest submission verdict.

  • [2024-09-13 15:09:07]
  • Judged
  • Verdict: 0
  • Time: 496ms
  • Memory: 106920kb
  • [2024-09-13 15:09:06]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
const int N=1e6+5,m=1e6;
int n;
int ex[N],ey[N];
vector<int> row[N],col[N];
int pl[N],pr[N];
bool ans[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&ex[i],&ey[i]);
		row[ex[i]].push_back(i);
		col[ey[i]].push_back(i);
	}
	for(int i=1;i<=m;i++){
		sort(row[i].begin(),row[i].end(),[](int i,int j){return ey[i]<ey[j];});
		sort(col[i].begin(),col[i].end(),[](int i,int j){return ex[i]<ex[j];});
		if(!row[i].size()) continue;
		pl[i] = 0;
		pr[i] = row[i].size()-1;
		ans[row[i][pl[i]]] = 1;
		ans[row[i][pr[i]]] = 1;
	}
	for(int i=1;i<=m;i++){
		int up=-1,down=-1;
		for(int j=0;j<col[i].size();j++){
			if(ans[col[i][j]]) {up=j; break;}
		}
		for(int j=col[i].size()-1;j>=0;j--){
			if(ans[col[i][j]]) {down=j; break;}
		}
		if(up==-1) continue;
		//printf("%d %d\n",up,down);
		for(int j=up+1;j<down;j++){
			if(ans[col[i][j]]){
				int x = ex[col[i][j]];
				if(col[i][j] == row[x][pr[x]]) continue;
				ans[col[i][j]] = 0;
				pl[x]++;
				if(pl[x]>pr[x]) continue;
				ans[row[x][pl[x]]] = 1;
			}
		}
		
	}
	for(int i=m;i>=1;i--){
		int up=-1,down=-1;
		for(int j=0;j<col[i].size();j++){
			if(ans[col[i][j]]) {up=j; break;}
		}
		for(int j=col[i].size()-1;j>=0;j--){
			if(ans[col[i][j]]) {down=j; break;}
		}
		for(int j=up+1;j<down;j++){
			if(ans[col[i][j]]){
				ans[col[i][j]] = 0;
				int x = ex[col[i][j]];
				if(col[i][j] == row[x][pl[x]]) puts("?");
				pr[x]--;
				if(pl[x]>pr[x]) continue;
				ans[row[x][pr[x]]] = 1;
			}
		}
	}
	for(int i=1;i<=n;i++)
		printf("%d",ans[i]);
	return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

2
869400 218695
664808 31410

output:

11

result:

ok 

Test #2:

score: 5
Accepted
time: 15ms
memory: 53112kb

input:

2
195447 154323
271823 133730

output:

11

result:

ok 

Test #3:

score: 5
Accepted
time: 15ms
memory: 53156kb

input:

3
751594 545975
951568 859051
621150 686048

output:

111

result:

ok 

Test #4:

score: 5
Accepted
time: 19ms
memory: 52956kb

input:

3
404592 259430
770816 43371
147329 582162

output:

111

result:

ok 

Test #5:

score: 5
Accepted
time: 13ms
memory: 50692kb

input:

3
401670 296316
401670 809250
401670 595959

output:

110

result:

ok 

Test #6:

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

input:

3
657802 927690
657802 872623
657802 83083

output:

101

result:

ok 

Test #7:

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

input:

3
759291 185618
759291 386687
759291 100713

output:

011

result:

ok 

Test #8:

score: 0
Wrong Answer
time: 15ms
memory: 50892kb

input:

3
997737 106763
684497 106763
412296 106763

output:

?
101

result:

wrong answer 

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #26:

score: 7
Accepted
time: 32ms
memory: 52884kb

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:

ok 

Test #27:

score: 7
Accepted
time: 33ms
memory: 53232kb

input:

111890
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 ...

output:

100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok 

Test #28:

score: 0
Wrong Answer
time: 56ms
memory: 59172kb

input:

339624
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
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2...

output:

?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
...

result:

wrong answer 

Subtask #4:

score: 0
Wrong Answer

Test #38:

score: 0
Wrong Answer
time: 496ms
memory: 97744kb

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:

?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
...

result:

wrong answer 

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: 457ms
memory: 106920kb

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:

?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
...

result:

wrong answer