QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#92173#5716. 圣诞树myee100 ✓33ms29616kbC++112.5kb2023-03-30 12:42:432023-03-30 12:42:47

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-30 12:42:47]
  • 评测
  • 测评结果:100
  • 用时:33ms
  • 内存:29616kb
  • [2023-03-30 12:42:43]
  • 提交

answer

// 那就是希望。
// 即便需要取模,也是光明。

#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
typedef long long llt;
typedef unsigned uint;typedef unsigned long long ullt;
typedef bool bol;typedef char chr;typedef void voi;
typedef double dbl;
template<typename T>bol _max(T&a,T b){return(a<b)?a=b,true:false;}
template<typename T>bol _min(T&a,T b){return(b<a)?a=b,true:false;}
template<typename T>T lowbit(T n){return n&-n;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T lcm(T a,T b){return(a!=0||b!=0)?a/gcd(a,b)*b:(T)0;}
template<typename T>T exgcd(T a,T b,T&x,T&y){if(b!=0){T ans=exgcd(b,a%b,y,x);y-=a/b*x;return ans;}else return y=0,x=1,a;}
template<typename T>T power(T base,T index,T mod)
{
    T ans=1%mod;
    while(index)
    {
        if(index&1)ans=ans*base%mod;
        base=base*base%mod,index>>=1;
    }
    return ans;
}
typedef long double ldbl;
ldbl F[1005][1005],G[1005][1005],X[1005],Y[1005];bol FromF[1005][1005],FromG[1005][1005];
ldbl dist(uint u,uint v){return sqrtl((X[u]-X[v])*(X[u]-X[v])+(Y[u]-Y[v])*(Y[u]-Y[v]));}
int main()
{
#ifdef MYEE
    freopen("QAQ.in","r",stdin);
    freopen("QAQ.out","w",stdout);
#else
#endif
    uint n,p=0;scanf("%u",&n);
    for(uint i=0;i<n;i++){scanf("%Lf%Lf",X+i,Y+i);if(Y[i]>Y[p]+5e-10)p=i;}
    for(uint len=1;len<n;len++)for(uint l=0;l<=len;l++)
    {
        F[l][len-l]=G[l][len-l]=1e18;
        if(l)
        {
            if(_min(F[l][len-l],F[l-1][len-l]+dist((p+n-l)%n,(p+n-l+1)%n)))
                FromF[l][len-l]=0;
            if(_min(F[l][len-l],G[l-1][len-l]+dist((p+n-l)%n,(p+len-l)%n)))
                FromF[l][len-l]=1;
        }
        if(len-l)
        {
            if(_min(G[l][len-l],F[l][len-l-1]+dist((p+n-l)%n,(p+len-l)%n)))
                FromG[l][len-l]=0;
            if(_min(G[l][len-l],G[l][len-l-1]+dist((p+len-l-1)%n,(p+len-l)%n)))
                FromG[l][len-l]=1;
        }
    }
    uint l=0,op=0;
    for(uint i=0;i<n;i++)if(F[i][n-i-1]<F[l][n-l-1])l=i;
    for(uint i=0;i<n;i++)if(G[i][n-i-1]<(op?G:F)[l][n-l-1])l=i,op=1;
    std::vector<uint>V;
    for(uint i=n-1;~i;i--)
        if(op)V.push_back((p+i-l)%n+1),op=FromG[l][i-l];
        else V.push_back((p+n-l)%n+1),op=FromF[l][i-l],l--;
    std::reverse(V.begin(),V.end());
    for(uint i=0;i<n;i++)printf("%u%c",V[i]," \n"[i==n-1]);
    return 0;
}

// 那就是希望。
// 即便需要取模,也是光明。

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 5
Accepted
time: 2ms
memory: 7144kb

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: 5
Accepted
time: 1ms
memory: 7260kb

input:

4
-99.945695391 329478.323986514
58.338556392 -8121952.277471396
98.855861366 1508372.046305224
-98.301252730 1835377.839701636

output:

4 3 1 2

result:

ok correct plan, the length of your path is 9957330.19485222165349114221

Test #3:

score: 5
Accepted
time: 1ms
memory: 7240kb

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:

9 1 8 7 6 2 3 5 4

result:

ok correct plan, the length of your path is 16169346.58119803246700030286

Test #4:

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

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:

8 7 6 5 4 3 9 2 1

result:

ok correct plan, the length of your path is 29281119.48655090131796896458

Test #5:

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

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:

8 7 9 6 1 5 4 2 3

result:

ok correct plan, the length of your path is 18064432.39328480453878000844

Test #6:

score: 5
Accepted
time: 2ms
memory: 9408kb

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:

8 7 9 6 1 5 2 4 3

result:

ok correct plan, the length of your path is 19142988.28144869230163749307

Test #7:

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

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:

16 17 18 1 2 3 4 5 6 15 14 13 7 8 9 12 11 10

result:

ok correct plan, the length of your path is 26923769.77803181657691311557

Test #8:

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

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:

16 15 14 13 17 18 1 12 11 10 9 2 8 3 4 7 5 6

result:

ok correct plan, the length of your path is 19243662.76546958935068687424

Test #9:

score: 5
Accepted
time: 1ms
memory: 7360kb

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:

9 8 7 10 11 12 13 14 15 16 17 18 1 6 2 3 5 4

result:

ok correct plan, the length of your path is 19795621.28394337113422807306

Test #10:

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

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:

15 16 17 18 1 2 3 4 5 6 7 14 13 12 8 11 10 9

result:

ok correct plan, the length of your path is 29393486.54189951627267873846

Test #11:

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

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:

12 11 13 14 10 15 16 17 18 9 1 8 7 2 3 6 4 5

result:

ok correct plan, the length of your path is 19712123.41203574310566182248

Test #12:

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

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:

14 15 16 17 18 1 2 3 4 5 13 12 6 7 8 9 10 11

result:

ok correct plan, the length of your path is 29215653.66241302432899829000

Test #13:

score: 5
Accepted
time: 21ms
memory: 29616kb

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:

613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 ...

result:

ok correct plan, the length of your path is 9143337.61849549340331577696

Test #14:

score: 5
Accepted
time: 30ms
memory: 29040kb

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:

767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 ...

result:

ok correct plan, the length of your path is 9693449.79312936085352703230

Test #15:

score: 5
Accepted
time: 29ms
memory: 28720kb

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:

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 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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...

result:

ok correct plan, the length of your path is 9995801.72726994066215411294

Test #16:

score: 5
Accepted
time: 23ms
memory: 28484kb

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:

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 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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...

result:

ok correct plan, the length of your path is 9995105.65982793520470295334

Test #17:

score: 5
Accepted
time: 26ms
memory: 29096kb

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:

595 596 597 598 599 600 601 594 593 602 603 592 591 604 590 589 605 588 587 586 585 606 607 608 584 609 610 611 583 582 612 613 581 614 580 579 578 615 577 576 575 574 573 572 616 571 570 617 569 568 567 566 565 564 563 562 618 561 619 560 559 558 620 621 557 622 556 623 555 554 553 624 552 551 550 ...

result:

ok correct plan, the length of your path is 20000938.02200506191002205014

Test #18:

score: 5
Accepted
time: 27ms
memory: 28636kb

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:

605 606 607 608 609 604 603 610 602 601 611 600 599 598 612 613 614 615 616 597 617 596 618 595 619 594 593 620 592 621 622 591 590 623 589 624 588 587 625 586 626 585 627 584 583 628 582 629 581 580 579 630 578 577 631 576 575 574 573 632 633 572 634 571 570 569 635 568 567 636 566 565 637 638 564 ...

result:

ok correct plan, the length of your path is 20001073.91454627489474660251

Test #19:

score: 5
Accepted
time: 33ms
memory: 28648kb

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:

611 612 610 613 609 608 607 606 614 615 616 605 604 603 602 601 617 618 600 599 598 619 620 597 596 595 594 593 621 622 592 591 623 590 624 625 589 626 627 628 588 587 629 630 586 631 585 632 633 634 584 583 635 582 636 637 581 580 638 579 578 639 577 576 640 575 574 641 642 643 644 645 646 647 573 ...

result:

ok correct plan, the length of your path is 20001414.72142834469013905618

Test #20:

score: 5
Accepted
time: 26ms
memory: 29336kb

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:

547 548 546 549 545 550 551 552 544 543 553 542 541 540 554 539 555 538 537 556 536 535 557 534 558 559 533 532 560 531 561 530 529 528 527 562 563 564 565 566 567 568 526 569 525 524 570 571 523 572 573 522 574 575 521 576 577 520 519 578 579 518 580 581 517 582 583 516 584 515 514 585 586 513 512 ...

result:

ok correct plan, the length of your path is 20000588.07295909898675745353

Extra Test:

score: 0
Extra Test Passed