QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#56785 | #3873. Towers | Wilson_Lee | 5 | 929ms | 113804kb | C++ | 2.8kb | 2022-10-21 16:12:20 | 2022-10-21 16:12:30 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pa;
const int MAXN=1e6+5;
struct node
{
int x,y;
}p[MAXN];
vector<pa>X[MAXN],Y[MAXN];
int numx[MAXN],numy[MAXN],ans[MAXN];
int main()
{
//freopen("tower.in","r",stdin);
//freopen("tower.out","w",stdout);
int n;
cin>>n;
for(int i=1;i<=n;++i) scanf("%d %d",&p[i].x,&p[i].y),numx[i]=p[i].x,numy[i]=p[i].y;
sort(numx+1,numx+n+1),sort(numy+1,numy+n+1);
int lenx=unique(numx+1,numx+n+1)-numx-1,leny=unique(numy+1,numy+n+1)-numy-1;
for(int i=1;i<=n;++i)
{
p[i].x=lower_bound(numx+1,numx+lenx+1,p[i].x)-numx;
p[i].y=lower_bound(numy+1,numy+leny+1,p[i].y)-numy;
//printf("%d %d\n",p[i].x,p[i].y);
}
for(int i=1;i<=n;++i) X[p[i].x].push_back({p[i].y,i});
for(int i=1;i<=lenx;++i)
{
sort(X[i].begin(),X[i].end());
int si=X[i].size();
Y[X[i][0].first].push_back({i,X[i][0].second});
if(si>=2) Y[X[i][si-1].first].push_back({i,X[i][si-1].second});
}
for(int i=1;i<=leny;++i)
{
//cout<<i<<endl;
if(Y[i].size()<=2)
{
for(auto j:Y[i]) ans[j.second]=1;
continue;
}
//cout<<i<<endl;
sort(Y[i].begin(),Y[i].end());
int si=Y[i].size();
ans[Y[i][0].second]=ans[Y[i][si-1].second]=1;
vector<pa>tmp;
tmp.push_back(Y[i][0]),tmp.push_back(Y[i][si-1]);
for(int j=1;j<si-1;++j)
{
ans[Y[i][j].second]=0;
pa now={i,Y[i][j].second};
int pos=upper_bound(X[Y[i][j].first].begin(),X[Y[i][j].first].end(),now)-X[Y[i][j].first].begin();
if(pos<X[Y[i][j].first].size()) Y[X[Y[i][j].first][pos].first].push_back({Y[i][j].first,X[Y[i][j].first][pos].second});
else tmp.push_back(Y[i][j]);
}
Y[i]=tmp;
}
//for(int i=1;i<=n;++i) if(ans[i]) putchar(i+'A'-1);
//return 0;
for(int i=leny;i>=1;--i)
{
//cout<<Y[i].size()<<endl;
if(Y[i].size()<=2)
{
for(auto j:Y[i]) ans[j.second]=1;
continue;
}
sort(Y[i].begin(),Y[i].end());
int si=Y[i].size();
ans[Y[i][0].second]=ans[Y[i][si-1].second]=1;
for(int j=1;j<si-1;++j)
{
ans[Y[i][j].second]=0;
pa now={i,Y[i][j].second};
int pos=lower_bound(X[Y[i][j].first].begin(),X[Y[i][j].first].end(),now)-X[Y[i][j].first].begin()-1;
if(pos>=0) Y[X[Y[i][j].first][pos].first].push_back({Y[i][j].first,X[Y[i][j].first][pos].second});
}
}
//for(int i=1;i<=n;++i) if(ans[i]) putchar(i+'A'-1);
for(int i=1;i<=n;++i) printf("%d",ans[i]);
return 0;
}
/*
16
2 4
3 3
2 3
5 5
3 1
6 6
5 2
6 2
4 6
1 8
2 8
8 8
1 2
1 1
4 7
7 6
*/
详细
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 17ms
memory: 50700kb
input:
2 869400 218695 664808 31410
output:
11
result:
ok
Test #2:
score: 0
Accepted
time: 4ms
memory: 50724kb
input:
2 195447 154323 271823 133730
output:
11
result:
ok
Test #3:
score: 0
Accepted
time: 8ms
memory: 50692kb
input:
3 751594 545975 951568 859051 621150 686048
output:
111
result:
ok
Test #4:
score: 0
Accepted
time: 11ms
memory: 50736kb
input:
3 404592 259430 770816 43371 147329 582162
output:
111
result:
ok
Test #5:
score: 0
Accepted
time: 8ms
memory: 50628kb
input:
3 401670 296316 401670 809250 401670 595959
output:
110
result:
ok
Test #6:
score: 0
Accepted
time: 12ms
memory: 50556kb
input:
3 657802 927690 657802 872623 657802 83083
output:
101
result:
ok
Test #7:
score: 0
Accepted
time: 12ms
memory: 50732kb
input:
3 759291 185618 759291 386687 759291 100713
output:
011
result:
ok
Test #8:
score: 0
Accepted
time: 11ms
memory: 50628kb
input:
3 997737 106763 684497 106763 412296 106763
output:
101
result:
ok
Test #9:
score: 0
Accepted
time: 8ms
memory: 50640kb
input:
3 305388 642835 538743 642835 608034 642835
output:
101
result:
ok
Test #10:
score: 0
Accepted
time: 8ms
memory: 50632kb
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: 10ms
memory: 50632kb
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
Wrong Answer
time: 14ms
memory: 50572kb
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:
1011110101101100
result:
wrong answer
Subtask #3:
score: 0
Wrong Answer
Test #26:
score: 7
Accepted
time: 30ms
memory: 53920kb
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: 0
Accepted
time: 38ms
memory: 54304kb
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: -7
Wrong Answer
time: 128ms
memory: 66396kb
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:
100000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000001000100000000000000000000000000000000000000000000000100000100000000000000000000000000000000000000000000010000000100000000000000000000000000000000000000000001000000000100000000000000000000000000000...
result:
wrong answer
Subtask #4:
score: 0
Wrong Answer
Test #38:
score: 0
Wrong Answer
time: 929ms
memory: 113804kb
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:
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: 894ms
memory: 111604kb
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