QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#473399 | #22. Power plants | Mathias | 0 | 4ms | 7832kb | C++20 | 2.2kb | 2024-07-12 03:06:51 | 2024-07-12 03:06:51 |
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define fi first
#define sc second
#define vi vector<int>
#define pii pair<int,int>
#define vpi vector<pair<ll,ll> >
const ll MOD1 = 1e9+7;
const ll MOD2 = 998244353;
const ll MOD3 = 1e9+93;
const ll MOD4 = 1e9+97;
const ll p1 = 1e9+87;
const ll p2 = 1e9+9;
const ll INF = 1e18+7;
const int BASE = 1<<20;
const int LOG = 20;
const int ALF = 27;
const int MAXN = 1e5+7;
const int MAXNN = 1e3+7;
pair<ll,ll> t[MAXN]; bool vis[MAXN],k[MAXN],xd; pair<ll,int> p; int v1[MAXN],v2[MAXN],depth[MAXN];
vi g[MAXN]; int usu,n,rv1,rv2,rp;
struct str{ll fi,sc,th;};
str pkt[MAXN];
bool comp(str a,str b){
if(a.fi==b.fi) return a.sc<b.sc;
else return a.fi<b.fi;
}
set<pair<ll,int> >s;
ll d(int x,int y){ return (t[x].fi-t[y].fi)*(t[x].fi-t[y].fi)+(t[x].sc-t[y].sc)*(t[x].sc-t[y].sc); }
void DFS(int x,int f){
k[x]=1-k[f], vis[x]=1, depth[x]=depth[f]+1;
for(auto s1:g[x]) if(vis[s1]==1 and s1!=f and (depth[x]-depth[s1])%2==0) xd=(k[x]!=k[s1]); else if(vis[s1]==0) DFS(s1,x);
}
bool f(ll mid){
xd=1; usu=1;
for(int i=1;i<=rp;i++){
ll x=pkt[i].fi, y=pkt[i].sc;
while(pkt[usu].fi<x-mid) s.erase({pkt[usu].sc,pkt[usu].th}), usu++;
p={y-mid,0};
auto it=s.lower_bound(p);
for(auto curr=it;curr!=s.end();curr++){
p=*curr;
if(p.fi>y+mid) break;
if(d(p.sc,pkt[i].th)<mid) g[pkt[i].th].pb(p.sc), g[p.sc].pb(pkt[i].th);
}
s.insert({y,pkt[i].th});
}
s.clear();
for(int i=1;i<=n;i++) if(vis[i]==0) DFS(i,0);
for(int i=1;i<=rp;i++) g[pkt[i].th].clear(), vis[pkt[i].th]=0;
if(xd==1){
rv1=rv2=0;
for(int i=1;i<=n;i++) if(k[i]) v1[++rv1]=i; else v2[++rv2]=i;
}
return xd;
}
void solve(){
ll b=0,e=INF,mid,r=0;
cin>>n;
for(int i=1;i<=n;i++) cin>>t[i].fi>>t[i].sc, pkt[++rp]={t[i].fi,t[i].sc,i};
sort(pkt+1,pkt+n,comp);
while(b<=e){
mid=(b+e)/2;
if(f(mid)) r=mid, b=mid+1; else e=mid-1;
}
cout<<r<<'\n'<<rv1<<'\n';
for(int i=1;i<=rv1;i++) cout<<v1[i]<<' '; cout<<'\n'<<rv2<<'\n';
for(int i=1;i<=rv2;i++) cout<<v2[i]<<' '; cout<<'\n';
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int tt=1;
while(tt--) solve();
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 4ms
memory: 7800kb
input:
100 387 501 90 108 273 76 754 365 121 556 102 401 831 215 841 829 424 690 17 35 10 980 34 917 948 478 766 818 55 588 510 772 16 511 499 323 632 554 461 454 281 247 720 575 994 720 739 30 989 992 507 557 665 621 356 398 161 822 906 556 189 835 208 500 628 829 402 969 804 155 697 581 107 630 102 568 3...
output:
425 94 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 76 77 78 79 80 81 82 83 85 86 87 88 89 90 91 93 94 95 96 98 99 100 6 40 49 75 84 92 97
result:
ok
Test #2:
score: 0
Accepted
time: 4ms
memory: 7832kb
input:
95 298 129 485 422 97 190 732 393 73 529 920 101 94 150 806 369 223 653 572 820 985 456 109 602 329 669 670 742 9 999 410 14 854 791 450 635 223 973 14 923 626 891 367 443 226 524 899 949 558 195 556 825 775 987 976 264 32 627 776 194 986 118 427 216 816 477 538 159 674 325 516 388 519 250 10 850 30...
output:
1530 81 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 27 28 29 30 31 32 33 34 35 36 37 38 39 41 42 45 47 49 51 52 53 54 56 57 58 59 60 61 62 63 64 66 67 68 69 71 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 89 91 92 93 95 14 26 40 43 44 46 48 50 55 65 70 72 88 90 94
result:
ok
Test #3:
score: 0
Accepted
time: 4ms
memory: 7752kb
input:
97 45 2 63 84 71 62 15 8 23 74 33 30 87 92 50 25 55 44 36 69 36 20 58 61 19 72 28 33 96 72 93 14 98 62 85 62 4 33 55 54 86 91 86 60 82 27 46 39 16 61 85 37 11 74 11 48 97 96 9 71 46 14 6 70 37 32 17 93 39 98 27 22 79 44 86 1 55 15 66 19 41 97 71 61 83 23 87 62 13 48 72 56 47 68 45 82 10 88 96 96 71 ...
output:
5 88 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 43 46 47 48 49 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 81 84 85 86 87 88 89 90 91 92 93 95 96 97 9 21 42 44 45 50 80 82 83 94
result:
ok
Test #4:
score: 0
Accepted
time: 3ms
memory: 7760kb
input:
95 292 500 313 500 687 500 500 480 791 500 500 916 875 500 438 500 583 500 645 500 500 979 500 520 916 500 937 500 500 604 500 500 500 812 500 625 500 105 500 791 500 937 146 500 417 500 500 334 396 500 42 500 459 500 500 770 355 500 500 854 500 645 500 313 500 271 500 146 334 500 958 500 501 501 50...
output:
8 93 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 85 86 87 88 89 90 91 92 93 94 95 2 37 84
result:
ok
Test #5:
score: 0
Accepted
time: 3ms
memory: 7820kb
input:
99 815 111 6 579 250 933 336 972 555 3 12 389 990 405 55 270 790 907 6 420 106 190 460 998 492 0 71 756 617 985 995 563 586 992 197 102 397 989 839 867 678 32 736 59 920 229 30 328 964 685 149 143 975 343 648 22 88 783 902 203 127 833 964 314 41 299 249 66 30 671 428 5 0 515 586 7 366 981 995 436 49...
output:
1066 50 1 2 3 6 7 8 9 14 15 20 24 27 28 30 37 38 39 41 42 43 44 47 48 50 51 52 55 56 57 60 61 62 63 64 66 69 70 71 73 79 82 85 86 88 91 93 94 95 96 97 49 4 5 10 11 12 13 16 17 18 19 21 22 23 25 26 29 31 32 33 34 35 36 40 45 46 49 53 54 58 59 65 67 68 72 74 75 76 77 78 80 81 83 84 87 89 90 92 98 99
result:
ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 7796kb
input:
81 2 8 1 2 1 5 3 6 7 5 1 1 2 9 3 2 4 9 6 3 8 3 5 2 4 1 8 2 7 3 7 4 5 1 4 7 6 9 5 9 6 7 9 2 2 7 2 1 6 2 4 6 1 8 1 4 9 3 5 5 3 4 8 4 6 4 2 4 2 6 7 2 7 8 2 5 8 1 1 9 4 3 9 4 5 7 4 4 4 2 6 5 7 1 8 6 4 8 3 8 9 6 6 8 3 7 4 5 3 9 7 7 9 7 8 5 5 4 2 2 6 6 3 3 9 5 5 6 9 1 2 3 1 7 6 1 3 5 7 6 5 8 3 1 8 7 1 3 9...
output:
2 41 1 3 5 6 14 15 17 20 25 26 29 30 32 33 34 35 40 43 44 45 47 48 49 52 53 55 56 57 60 61 62 63 65 67 69 72 74 75 78 80 81 40 2 4 7 8 9 10 11 12 13 16 18 19 21 22 23 24 27 28 31 36 37 38 39 41 42 46 50 51 54 58 59 64 66 68 70 71 73 76 77 79
result:
ok
Test #7:
score: 0
Accepted
time: 4ms
memory: 7764kb
input:
100 845 825 422 32 580 328 94 955 607 941 991 977 94 217 986 857 983 777 296 306 439 746 578 46 884 259 475 542 577 48 215 341 148 73 709 71 194 747 794 685 718 657 76 756 802 901 982 583 618 954 252 117 609 943 371 279 90 222 496 958 840 823 879 260 45 245 173 603 662 740 795 627 373 276 419 35 415...
output:
281 50 1 2 3 4 5 6 7 8 9 10 11 12 13 14 16 17 18 19 20 21 22 23 24 25 26 28 30 33 34 35 36 39 40 42 43 44 45 46 47 48 51 53 54 55 57 64 65 68 69 90 50 15 27 29 31 32 37 38 41 49 50 52 56 58 59 60 61 62 63 66 67 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 91 92 93 94 95 96 97 98 99 1...
result:
ok
Test #8:
score: 0
Accepted
time: 4ms
memory: 7764kb
input:
100 351 159 387 82 565 234 715 966 38 208 991 866 200 21 574 529 543 319 216 543 374 653 825 704 591 437 936 295 284 478 785 380 609 454 283 155 790 95 220 181 751 869 877 960 744 61 111 780 583 203 696 211 37 868 930 773 298 129 137 483 952 658 492 154 563 958 935 11 263 844 209 378 9 636 536 878 5...
output:
853 90 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 89 90 92 94 95 96 97 98 99 10 17 42 67 68 69 70 88 91 93 1...
result:
ok
Test #9:
score: -10
Wrong Answer
time: 3ms
memory: 7768kb
input:
100 464 814 173 646 422 812 632 761 136 559 443 813 740 617 834 171 281 760 544 802 750 500 230 718 135 364 759 119 143 340 219 205 507 62 186 665 401 808 563 797 397 85 340 791 727 650 706 93 144 582 484 813 151 316 130 535 371 94 125 413 748 583 277 150 423 76 130 389 124 487 451 70 381 804 785 13...
output:
800 61 1 2 3 5 8 10 11 12 13 14 16 17 21 22 24 27 30 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 55 57 58 59 62 64 65 67 68 69 70 72 73 74 76 77 78 80 82 85 86 88 91 93 94 96 99 100 39 4 6 7 9 15 18 19 20 23 25 26 28 29 31 32 33 34 35 52 53 54 56 60 61 63 66 71 75 79 81 83 84 87 89 90 92 95 97 ...
result:
wrong answer
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #2:
0%