QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#86742 | #5716. 圣诞树 | fengyuyue | 5 | 32ms | 152544kb | C++14 | 4.0kb | 2023-03-10 19:33:57 | 2023-03-12 21:16:59 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define gc getchar
#define pc putchar
#define pii pair<int,int>
#define pil pair<int,long long>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define For(i,l,r) for(int i=(l);i<=(r);i++)
#define IFor(i,r,l) for(int i=(r);i>=(l);i--)
#define for_son(u) for(int e=head[u];e;e=nxt[e])
#define eps (1e-8)
#define INF 0x3f3f3f3f
using namespace std;
char aa;
namespace ljh
{
namespace IO
{
// const int SIZ=1<<20;
// char ibuf[SIZ],*p1,*p2,obuf[SIZ],*p3=obuf;
// #define gc() (p1==p2&&(p2=(p1=ibuf)+fread(ibuf,1,SIZ,stdin),p1==p2)?EOF:*p1++)
// void pc(const char &c)
// {
// if(p3-obuf==SIZ) fwrite(obuf,1,SIZ,stdout),p3=obuf;
// *p3++=c;
// }
int rd()
{
int x=0,f=1;
char ch=gc();
while(!isdigit(ch)){
if(ch=='-') f=-1;
ch=gc();
}
while(isdigit(ch)){
x=x*10+ch-'0';
ch=gc();
}
return x*f;
}
void wr(int x,char ch)
{
if(x<0) x=-x,pc('-');
static char st[12];
int top=0;
do{
st[top++]=x%10+'0',x/=10;
}while(x);
while(top) pc(st[--top]);
pc(ch);
}
ll ll_rd()
{
ll x=0;
int f=1;
char ch=gc();
while(!isdigit(ch)){
if(ch=='-') f=-1;
ch=gc();
}
while(isdigit(ch)){
x=x*10+ch-'0';
ch=gc();
}
return x*f;
}
void ll_wr(ll x,char ch)
{
if(x<0) x=-x,pc('-');
static char st[22];
int top=0;
do{
st[top++]=x%10+'0',x/=10;
}while(x);
while(top) pc(st[--top]);
pc(ch);
}
}
using namespace IO;
const int N=3005,mod=0;
namespace tem
{
// void add_edge(int u,int v){nxt[++cnt]=head[u],to[cnt]=v,head[u]=cnt;}
int qpow(int a,int b,int p)
{
a%=p;
int res=1;
while(b){
if(b&1) res=1ll*res*a%p;
a=1ll*a*a%p;
b>>=1;
}
return res;
}
int get_inv(int x){return qpow(x,mod-2,mod);}
int lowbit(int x){return x&(-x);}
void add(int &x,const int y){ x=(x+y>=mod?x+y-mod:x+y); }
// int get(int x) {return fa[x]==x?x:fa[x]=get(fa[x])};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
}
using namespace tem;
int n;
struct Node{
double x,y;
}a[N];
double f[N][N][2];
bool g[N][N][2];
double dis(const Node &a,const Node &b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
void print(int i,int j,bool k)
{
if(i==j) return wr((i-1)%n+1,' '),void();
if(!k) print(i+1,j,g[i][j][k]),wr((i-1)%n+1,' ');
else print(i,j-1,g[i][j][k]),wr((j-1)%n+1,' ');
}
void main()
{
n=rd();
For(i,1,n) scanf("%lf%lf",&a[i].x,&a[i].y),a[i+n]=a[i+n*2]=a[i];
int st=0;
For(i,n+1,n*2) if(!st||a[i].y>a[st].y) st=i;
memset(f,0x5f,sizeof(f));
f[st][st][0]=f[st][st][1]=0;
IFor(i,st,st-n+1){
For(j,st,st+n-1){
if(i==j) continue;
if(i<st){
double v1=f[i+1][j][0]+dis(a[i+1],a[i]),v2=f[i+1][j][1]+dis(a[j],a[i]);
f[i][j][0]=min(v1,v2),g[i][j][0]=(v1>v2);
}
if(j>st){
double v1=f[i][j-1][1]+dis(a[j-1],a[j]),v2=f[i][j-1][0]+dis(a[i],a[j]);
f[i][j][1]=min(v1,v2),g[i][j][1]=(v1>v2);
}
}
}
int l=0;
bool k=false;
For(i,st-n+1,st){
For(j,0,1){
if(!l||f[l][l+n-1][k]>f[i][i+n-1][j]){
l=i,k=j;
}
}
}
// bool k=f[i][j][0]>f[i][j][1];
print(l,l+n-1,k);
pc('\n');
// fwrite(obuf,1,p3-obuf,stdout);
}
/*
*/
}
char bb;
int main()
{
// freopen("1.in","r",stdin);
// freopen("1.out","w",stdout);
// int st=clock();
ljh::main();
// int ed=clock();
// cerr<<ed-st<<"ms"<<endl;
// cerr<<(&bb-&aa)/1024/1024<<"MB"<<endl;
// fclose(stdin);
// fclose(stdout);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 5
Accepted
time: 20ms
memory: 146360kb
input:
4 -22.593412495 -9741424.257746905 66.477818528 -7470406.982326438 71.236323414 7018109.244555489 -18.001300149 9836641.258750316
output:
4 3 2 1
result:
ok correct plan, the length of your path is 19578065.51965740451487363316
Test #2:
score: 0
Wrong Answer
time: 7ms
memory: 145532kb
input:
4 -99.945695391 329478.323986514 58.338556392 -8121952.277471396 98.855861366 1508372.046305224 -98.301252730 1835377.839701636
output:
3 4 1 2
result:
wrong answer invalid plan: p[1] = 3, but k = 4
Test #3:
score: 0
Wrong Answer
time: 1ms
memory: 145884kb
input:
9 -88.130252191 4725523.246414331 -86.337894581 -5045556.847431189 -75.482463432 -6559264.021527681 64.064506153 -7678370.363799104 64.079064933 -7677155.793970107 94.183333255 -3360801.283386214 99.910650088 422627.449100774 94.074532824 3391138.333482600 -52.823585196 8490976.186361579
output:
8 7 9 1 2 6 3 5 4
result:
wrong answer invalid plan: p[1] = 8, but k = 9
Test #4:
score: 0
Wrong Answer
time: 23ms
memory: 145256kb
input:
9 -9999899.409899285 0.445735685 -7231624.918363319 -69.067771292 -867508.690844329 -99.622991525 3425332.589571590 -93.950561320 9889658.552976551 -14.814340491 9492319.604022885 31.457696787 9332495.734425072 35.922856107 498097.043795430 99.875872615 -5404658.812398645 84.136583404
output:
7 6 5 4 3 8 9 2 1
result:
wrong answer invalid plan: p[1] = 7, but k = 8
Test #5:
score: 0
Wrong Answer
time: 3ms
memory: 145252kb
input:
9 -98.456759828 -1750039.400241718 -61.957845365 -7849345.839369436 -59.052313747 -8070205.528202594 77.168445838 -6360055.215798607 96.060368020 -2779217.531057043 78.565395272 6186662.271937571 4.606686692 9989383.069703352 3.397499779 9994226.834499145 -39.069633259 9205195.628080532
output:
7 6 5 4 8 9 1 2 3
result:
wrong answer invalid plan: p[1] = 7, but k = 8
Test #6:
score: 0
Wrong Answer
time: 3ms
memory: 145184kb
input:
9 -97.909815371 2033875.115519879 -80.675324185 -5908882.709178978 -13.448712806 -9909152.078581285 34.090323608 -9400982.711778836 90.480355630 -4258291.002542999 93.108963682 3647904.559997857 60.919471145 7930206.452793276 -38.387831977 9233836.160472939 -76.379741762 6454558.816006526
output:
7 6 5 8 9 1 2 4 3
result:
wrong answer invalid plan: p[1] = 7, but k = 8
Test #7:
score: 0
Wrong Answer
time: 8ms
memory: 146200kb
input:
18 -9777641.109811993 20.970731284 -8753656.260425124 -48.346120434 -7412844.019762204 -67.119084311 -2848482.296643767 -95.857248575 -2643357.228935465 -96.443058122 -740948.350504887 -99.725109459 9194209.737187773 -39.327474387 9526046.479729515 -30.421103729 9682037.024214631 -25.016297631 99599...
output:
3 2 1 18 17 16 4 15 5 6 7 14 8 13 9 12 11 10
result:
wrong answer invalid plan: p[1] = 3, but k = 16
Test #8:
score: 0
Wrong Answer
time: 4ms
memory: 144984kb
input:
18 -97.609231020 2173559.044735648 -96.653901492 -2565191.958433518 -71.068216234 -7035129.893726200 -57.597514590 -8174670.477582518 -43.629677306 -8998026.861567581 -23.445797538 -9721261.043276759 51.843209722 -8551187.171098029 85.919958067 -5116405.234874469 99.410736234 1083997.160856929 99.32...
output:
15 14 13 12 11 10 9 8 7 16 17 18 1 2 3 4 5 6
result:
wrong answer invalid plan: p[1] = 15, but k = 16
Test #9:
score: 0
Wrong Answer
time: 9ms
memory: 144744kb
input:
18 -99.052027871 1373657.188540728 -46.267273393 -8865290.193271797 -40.834336049 -9128282.532344488 17.132754076 -9852140.308015687 38.296002635 -9237648.269742230 99.724923173 741212.433843515 32.700081150 9450240.574760046 28.654655008 9580663.204977673 10.616908878 9943480.906035516 -41.66605215...
output:
17 16 15 14 13 12 11 10 9 18 8 1 7 2 6 3 5 4
result:
wrong answer invalid plan: p[1] = 17, but k = 9
Test #10:
score: 0
Wrong Answer
time: 8ms
memory: 146064kb
input:
18 -9988644.395188430 4.764068958 -9173724.491107116 -39.802951007 -8669681.096146317 -49.836333480 -7443519.270126479 -66.778731030 -5770717.036658329 -81.669335701 -4862699.881117738 -87.380848180 -3713063.792800765 -92.851026160 9500618.150680272 -31.206171477 9721196.074895224 23.448557497 96400...
output:
5 4 3 2 1 18 17 16 15 6 14 13 12 7 8 11 10 9
result:
wrong answer invalid plan: p[1] = 5, but k = 15
Test #11:
score: 0
Wrong Answer
time: 17ms
memory: 145184kb
input:
18 -97.500291551 -2221915.344895550 -85.855028670 -5127291.492091638 -81.506395617 -5793707.605811875 -57.410205499 -8187835.747089645 -22.821335632 -9736110.176641855 66.955919984 -7427585.981703298 89.660019470 -4428408.634845663 90.424403727 -4270159.337310728 99.043900721 -1379511.929871218 62.9...
output:
11 10 9 8 7 6 12 13 14 15 16 17 18 1 2 3 4 5
result:
wrong answer invalid plan: p[1] = 11, but k = 12
Test #12:
score: 0
Wrong Answer
time: 16ms
memory: 145348kb
input:
18 -9947658.731449893 10.217953279 -9939857.386696933 -10.950854070 -9783437.215747919 -20.698629553 -9105239.685636943 -41.345595985 -7899735.977385085 -61.314064708 5556037.039803670 -83.144712470 6528899.547216170 -75.745268214 6692721.204555425 -74.301730965 9197505.650969345 -39.250325864 94685...
output:
7 6 5 4 3 2 1 18 17 16 15 14 8 13 9 12 10 11
result:
wrong answer invalid plan: p[1] = 7, but k = 14
Test #13:
score: 0
Wrong Answer
time: 32ms
memory: 151464kb
input:
1000 -9999997.952898901 -4576.245054302 -9999989.576091422 -13728.731329473 -9999972.822483480 -22881.206104348 -9999947.692089111 -32033.661712073 -9999914.184929363 -41186.090485811 -9999872.301032308 -50338.484758746 -9999822.040433031 -59490.836864093 -9999763.403173631 -68643.139135102 -9999696...
output:
610 609 608 607 606 605 604 603 602 601 600 599 598 597 596 595 594 593 592 591 590 589 588 587 586 585 584 583 582 581 580 579 578 577 576 575 574 573 572 571 570 569 568 567 566 565 564 563 562 561 560 559 558 557 556 555 554 553 552 551 550 549 548 547 546 545 544 543 542 541 540 539 538 537 536 ...
result:
wrong answer invalid plan: p[1] = 610, but k = 613
Test #14:
score: 0
Wrong Answer
time: 23ms
memory: 151964kb
input:
1000 -1825898.847330943 9831890.631985107 5662711.565947135 8242188.891361902 5656228.313823126 8246639.392013366 5649741.563914310 8251084.792982076 5643251.320232062 8255525.091519018 5636757.586789916 8259960.284878331 5630260.367603568 8264390.370317313 5623759.666690866 8268815.345096420 561725...
output:
1000 999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926...
result:
wrong answer invalid plan: p[1] = 1000, but k = 767
Test #15:
score: 0
Wrong Answer
time: 27ms
memory: 151180kb
input:
1000 -99.999981021 -4196.234000641 -99.999320477 -36586.226022812 -99.998638507 -51988.425758636 -99.998540504 -53840.147796606 -99.996477416 -83813.595838026 -99.995887884 -90573.648762260 -99.994477077 -105001.851766843 -99.994068719 -108820.698731471 -99.991919913 -127039.407758334 -99.991264070 ...
output:
998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926 925 924 ...
result:
wrong answer invalid plan: p[1] = 998, but k = 1
Test #16:
score: 0
Wrong Answer
time: 16ms
memory: 151616kb
input:
1000 -99.999978017 -4891.410365499 -99.999967146 -6754.280518179 -99.999955795 -8257.483386669 -99.999736640 -22502.317321211 -99.999214627 -39377.387317373 -99.999167117 -40560.419764050 -99.998745253 -49888.517303299 -99.998206921 -59713.360992776 -99.996711992 -80967.486763354 -99.991893147 -1272...
output:
998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926 925 924 ...
result:
wrong answer invalid plan: p[1] = 998, but k = 1
Test #17:
score: 0
Wrong Answer
time: 15ms
memory: 151856kb
input:
1000 -99.998824893 48271.144190956 -99.998686363 -51059.495118453 -99.994756371 -102306.410053996 -99.859086308 -530668.091646454 -99.791160796 -645927.013729155 -99.656122983 -828583.728203046 -99.617939662 -873292.699336426 -99.617009806 -874352.974038697 -99.316783836 -1166937.226541790 -99.08366...
output:
594 593 592 591 590 589 588 587 586 585 584 583 582 581 580 579 578 577 576 575 574 573 572 571 570 569 568 567 566 565 564 563 562 561 560 559 558 557 556 555 554 553 552 551 550 549 548 547 546 545 544 543 542 541 540 539 538 537 536 535 534 533 532 531 530 529 528 527 526 525 524 523 522 521 520 ...
result:
wrong answer invalid plan: p[1] = 594, but k = 595
Test #18:
score: 0
Wrong Answer
time: 20ms
memory: 152544kb
input:
1000 -99.999737126 22486.548024433 -99.995394603 -95866.151807391 -99.981657893 -191469.955487396 -99.973551603 -229932.984965422 -99.964715932 -265585.375982726 -99.914972981 -412263.142524763 -99.639135629 -848766.985397028 -99.266079287 -1209311.492720083 -99.085585312 -1349239.443977273 -98.7879...
output:
604 603 602 601 600 599 598 597 596 595 594 593 592 591 590 589 588 587 586 585 584 583 582 581 580 579 578 577 576 575 574 573 572 571 570 569 568 567 566 565 564 563 562 561 560 559 558 557 556 555 554 553 552 551 550 549 548 547 546 545 544 543 542 541 540 539 538 537 536 535 534 533 532 531 530 ...
result:
wrong answer invalid plan: p[1] = 604, but k = 605
Test #19:
score: 0
Wrong Answer
time: 20ms
memory: 152140kb
input:
1000 -99.999976329 -5182.932816969 -99.999974006 -5609.074780653 -99.999619226 -27222.105163970 -99.989528601 -144641.674033520 -99.956566214 -294665.670278608 -99.949343997 -318223.266410106 -99.918318277 -404074.299019073 -99.841812148 -562232.269219097 -99.819825417 -600003.369759435 -99.78134063...
output:
610 609 608 607 606 605 604 603 602 601 600 599 598 597 596 595 594 593 592 591 590 589 588 587 586 585 584 583 582 581 580 579 578 577 576 575 574 573 572 571 570 569 568 567 566 565 564 563 562 561 560 559 558 557 556 555 554 553 552 551 550 549 548 547 546 545 544 543 542 541 540 539 538 537 536 ...
result:
wrong answer invalid plan: p[1] = 610, but k = 611
Test #20:
score: 0
Wrong Answer
time: 23ms
memory: 152068kb
input:
1000 -99.999988547 -1677.361228845 -99.998216842 -59548.488590103 -99.982093973 -189178.611914105 -99.969981907 -244963.031694546 -99.947047678 -325355.860842565 -99.915481043 -411030.598804676 -99.858110747 -532500.464719264 -99.802575836 -628042.709810111 -99.799647287 -632679.783296217 -99.796519...
output:
546 545 544 543 542 541 540 539 538 537 536 535 534 533 532 531 530 529 528 527 526 525 524 523 522 521 520 519 518 517 516 515 514 513 512 511 510 509 508 507 506 505 504 503 502 501 500 499 498 497 496 495 494 493 492 491 490 489 488 487 486 485 484 483 482 481 480 479 478 477 476 475 474 473 472 ...
result:
wrong answer invalid plan: p[1] = 546, but k = 547