QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#357568#5111. Take On MemeInfinityNSAC ✓22ms6552kbC++144.0kb2024-03-19 00:00:222024-03-19 00:00:23

Judging History

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

  • [2024-03-19 00:00:23]
  • 评测
  • 测评结果:AC
  • 用时:22ms
  • 内存:6552kb
  • [2024-03-19 00:00:22]
  • 提交

answer

#include<bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define ll long long
using namespace std;

typedef pair<int,int> pii;

const int maxn=10010;
int n,ep;
vector<int>vect[maxn];

struct pt{

    ll x,y;

    pt(){}
    pt(ll x,ll y){
        this->x=x;
        this->y=y;
    }

    pt operator +(pt b){
        return pt(x+b.x,y+b.y);
    }
    pt operator -(pt b){
        return pt(x-b.x,y-b.y);
    }

    ll cross(pt b){
        return (ll)x*b.y-(ll)y*b.x;
    }

    bool operator <(const pt &b)const {
        return x<b.x || (x==b.x && y<b.y);
    }

    bool operator ==(pt b){
        return x==b.x && y==b.y;
    }

    void ispis(){
        printf("%d %d PT | ",x,y);
    }

};

int get_minpt(vector<pt>&a){
    int id=0;
    for(int i=1;i<a.size();i++)
        if(a[i]<a[id])id=i;
    return id;
}
vector<pt> minkowski(vector<pt>a,vector<pt>b){
    if(a.size()>b.size())swap(a,b);
    if(a.size()==1){
        for(int i=0;i<b.size();i++)b[i]=b[i]+a[0];
        return b;
    }

    int id=get_minpt(a);
    rotate(a.begin(),a.begin()+id,a.end());

    id=get_minpt(b);
    rotate(b.begin(),b.begin()+id,b.end());

    a.pb(a[0]);
    a.pb(a[1]);

    b.pb(b[0]);
    b.pb(b[1]);

    int pta=0;
    int ptb=0;

    vector<pt>ret;
    while( !(pta==a.size()-2 && ptb==b.size()-2) ){

        ret.pb(a[pta]+b[ptb]);

        ll val=(a[pta+1]-a[pta]).cross(b[ptb+1]-b[ptb]);

        if(val>=0)pta++;
        if(val<=0)ptb++;

    }
    return ret;
}

vector<pt> get_hull_pts(vector<pt>&pts){

    sort(pts.begin(),pts.end());
    pts.resize(unique(pts.begin(),pts.end())-pts.begin());

    vector<pt>ret;

    if(pts.size()==1){
        ret.pb(pts[0]);
        return ret;
    }

    vector<pt>stek;
    for(int i=0;i<pts.size();i++){
        pt pom=pts[i];
        while(stek.size()>1 && (stek[stek.size()-1]-stek[stek.size()-2]).cross(pom-stek[stek.size()-2])<=0)stek.pop_back();
        stek.pb(pom);
    }
    for(int i=0;i<stek.size()-1;i++)ret.pb(stek[i]);

    stek.clear();
    for(int i=pts.size()-1;i>=0;i--){
        pt pom=pts[i];
        while(stek.size()>1 && (stek[stek.size()-1]-stek[stek.size()-2]).cross(pom-stek[stek.size()-2])<=0)stek.pop_back();
        stek.pb(pom);
    }
    for(int i=0;i<stek.size()-1;i++)ret.pb(stek[i]);

    return ret;
}

struct hull{

    vector<pt>a;

    hull(){}
    hull(vector<pt>a){
        this->a=a;
    }

    hull operator *(hull b){
        return hull(minkowski(a,b.a));
    }

    hull operator +(hull b){

        vector<pt>pts;
        for(int i=0;i<a.size();i++)pts.pb(a[i]);
        for(int i=0;i<b.a.size();i++)pts.pb(b.a[i]);

        return hull(get_hull_pts(pts));
    }

    hull mins(){
        hull ret;
        for(int i=0;i<a.size();i++){
            ret.a.pb(pt(-a[i].x,-a[i].y));
        }
        return ret;
    }

}ch[maxn];

typedef pair<hull,hull> pcc;
pcc go_dnc(int l,int r,vector<int>&vect){

    if(l==r){
        return {ch[vect[l]],ch[vect[l]].mins()};
    }

    int mid=(l+r)/2;


    pcc lp=go_dnc(l,mid,vect);
    pcc rp=go_dnc(mid+1,r,vect);

    pcc ret={lp.ff*rp.ss+lp.ss*rp.ff,lp.ss*rp.ss};
    return ret;

}
void go(int x){

    for(int i=0;i<vect[x].size();i++){
        int id=vect[x][i];
        go(id);
    }

    if(vect[x].size()==0)return;
    ch[x]=go_dnc(0,vect[x].size()-1,vect[x]).ff;
}

int main(){

    ///freopen("test.txt","r",stdin);

    scanf("%d",&n);
    for(int i=1;i<=n;i++){

        int k;
        scanf("%d",&k);
        for(int j=0;j<k;j++){

            int c;
            scanf("%d",&c);

            vect[i].pb(c);
        }

        if(k==0){
            int x,y;
            scanf("%d %d",&x,&y);
            ch[i].a.pb(pt(x,y));
        }

    }


    go(1);

    ll rez=0;

    for(int i=0;i<ch[1].a.size();i++){

        rez=max(rez,(ll)ch[1].a[i].x*ch[1].a[i].x+(ll)ch[1].a[i].y*ch[1].a[i].y);

    }
    printf("%lld\n",rez);


return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 4272kb

input:

5
4 2 3 4 5
0 2 -2
0 1 3
0 4 -6
0 -18 5

output:

725

result:

ok single line: '725'

Test #2:

score: 0
Accepted
time: 1ms
memory: 4560kb

input:

5
2 2 3
2 4 5
0 1 5
0 -4 -6
0 -1 7

output:

340

result:

ok single line: '340'

Test #3:

score: 0
Accepted
time: 1ms
memory: 4216kb

input:

18
3 4 3 2
2 5 6
3 7 9 8
3 10 11 12
0 4 -1
0 18 49
0 -2 10
2 13 14
0 -5 6
0 5 8
4 15 16 17 18
0 17 3
0 3 -9
0 -7 -1
0 14 -33
0 -23 11
0 11 14
0 2 19

output:

26269

result:

ok single line: '26269'

Test #4:

score: 0
Accepted
time: 18ms
memory: 5924kb

input:

10000
59 2 171 340 509 678 847 1016 1185 1382 1551 1720 1889 2058 2227 2396 2565 2734 2903 3072 3241 3410 3579 3748 3917 4086 4255 4424 4593 4762 4931 5100 5269 5438 5607 5776 5945 6114 6283 6452 6621 6790 6959 7128 7297 7466 7635 7804 7973 8142 8311 8480 8649 8818 8987 9156 9325 9494 9663 9832
2 3 ...

output:

4893524000116

result:

ok single line: '4893524000116'

Test #5:

score: 0
Accepted
time: 19ms
memory: 5624kb

input:

10000
37 2 272 542 812 1082 1352 1622 1892 2162 2432 2702 2972 3242 3512 3782 4052 4322 4592 4862 5132 5402 5672 5942 6212 6482 6752 7022 7292 7571 7841 8111 8381 8651 8921 9191 9461 9731
51 3 8 13 18 23 42 47 52 57 62 67 72 77 82 87 92 97 102 107 112 117 122 127 132 137 142 147 152 157 162 167 172 ...

output:

5186192629829

result:

ok single line: '5186192629829'

Test #6:

score: 0
Accepted
time: 18ms
memory: 5960kb

input:

10000
89 2 114 226 338 450 562 674 786 898 1010 1122 1234 1346 1458 1570 1682 1794 1906 2018 2130 2242 2354 2466 2578 2690 2802 2914 3026 3138 3250 3362 3474 3586 3698 3810 3922 4034 4146 4258 4370 4482 4594 4706 4818 4930 5042 5154 5266 5378 5490 5602 5714 5826 5938 6050 6162 6274 6386 6498 6610 67...

output:

5143217930845

result:

ok single line: '5143217930845'

Test #7:

score: 0
Accepted
time: 1ms
memory: 4292kb

input:

1
0 0 0

output:

0

result:

ok single line: '0'

Test #8:

score: 0
Accepted
time: 1ms
memory: 4272kb

input:

1
0 -1000 0

output:

1000000

result:

ok single line: '1000000'

Test #9:

score: 0
Accepted
time: 0ms
memory: 4248kb

input:

1
0 0 -1000

output:

1000000

result:

ok single line: '1000000'

Test #10:

score: 0
Accepted
time: 1ms
memory: 4252kb

input:

1
0 -1000 1000

output:

2000000

result:

ok single line: '2000000'

Test #11:

score: 0
Accepted
time: 1ms
memory: 4304kb

input:

2
1 2
0 0 0

output:

0

result:

ok single line: '0'

Test #12:

score: 0
Accepted
time: 1ms
memory: 4272kb

input:

2
1 2
0 -123 -456

output:

223065

result:

ok single line: '223065'

Test #13:

score: 0
Accepted
time: 1ms
memory: 4260kb

input:

3
2 2 3
0 123 456
0 123 456

output:

0

result:

ok single line: '0'

Test #14:

score: 0
Accepted
time: 1ms
memory: 4256kb

input:

3
2 2 3
0 -123 456
0 123 456

output:

60516

result:

ok single line: '60516'

Test #15:

score: 0
Accepted
time: 1ms
memory: 4208kb

input:

3
2 2 3
0 123 456
0 123 -456

output:

831744

result:

ok single line: '831744'

Test #16:

score: 0
Accepted
time: 1ms
memory: 4256kb

input:

3
2 2 3
0 -123 456
0 123 -456

output:

892260

result:

ok single line: '892260'

Test #17:

score: 0
Accepted
time: 1ms
memory: 4324kb

input:

3
2 2 3
0 -123 456
0 345 678

output:

268308

result:

ok single line: '268308'

Test #18:

score: 0
Accepted
time: 0ms
memory: 4184kb

input:

3
1 2
1 3
0 -123 -456

output:

223065

result:

ok single line: '223065'

Test #19:

score: 0
Accepted
time: 1ms
memory: 4560kb

input:

4
3 2 3 4
0 1 0
0 1 0
0 1 0

output:

1

result:

ok single line: '1'

Test #20:

score: 0
Accepted
time: 1ms
memory: 4264kb

input:

6
2 2 3
3 4 5 6
0 1 0
0 1 0
0 1 0
0 1 0

output:

4

result:

ok single line: '4'

Test #21:

score: 0
Accepted
time: 0ms
memory: 4260kb

input:

6
2 2 3
3 4 5 6
0 -1 0
0 1 0
0 1 0
0 1 0

output:

0

result:

ok single line: '0'

Test #22:

score: 0
Accepted
time: 0ms
memory: 4544kb

input:

9
2 2 3
3 4 5 6
3 7 8 9
0 1 0
0 1 0
0 1 0
0 1 0
0 1 0
0 1 0

output:

0

result:

ok single line: '0'

Test #23:

score: 0
Accepted
time: 1ms
memory: 4300kb

input:

11
2 2 3
3 5 6 7
2 4 8
3 9 10 11
0 1 0
0 1 0
0 1 0
0 0 0
0 1 0
0 1 0
0 1 0

output:

4

result:

ok single line: '4'

Test #24:

score: 0
Accepted
time: 1ms
memory: 4228kb

input:

7
2 2 3
4 4 5 6 7
0 -1 1
0 1 0
0 0 1
0 -1 0
0 0 -1

output:

10

result:

ok single line: '10'

Test #25:

score: 0
Accepted
time: 1ms
memory: 4536kb

input:

11
10 2 3 4 5 6 7 8 9 10 11
0 102 -967
0 986 -21
0 709 -570
0 -987 -692
0 571 -682
0 -926 -89
0 -872 600
0 137 -79
0 -844 100
0 -171 359

output:

14669290

result:

ok single line: '14669290'

Test #26:

score: 0
Accepted
time: 0ms
memory: 4300kb

input:

111
10 2 13 24 35 46 57 68 79 90 101
10 3 4 5 6 7 8 9 10 11 12
0 802 -636
0 314 100
0 854 515
0 564 -305
0 905 -624
0 -145 -402
0 -342 828
0 -589 776
0 -51 163
0 929 58
10 14 15 16 17 18 19 20 21 22 23
0 321 177
0 497 -114
0 905 -669
0 987 301
0 754 -48
0 594 861
0 -76 -2
0 -450 -850
0 -428 286
0 83...

output:

943392365

result:

ok single line: '943392365'

Test #27:

score: 0
Accepted
time: 2ms
memory: 4544kb

input:

1111
10 2 113 224 335 446 557 668 779 890 1001
10 3 14 25 36 47 58 69 80 91 102
10 4 5 6 7 8 9 10 11 12 13
0 -846 43
0 794 332
0 -558 -43
0 -642 -438
0 -245 936
0 -289 489
0 -643 211
0 876 -116
0 -743 290
0 -411 587
10 15 16 17 18 19 20 21 22 23 24
0 -458 -210
0 -967 244
0 -220 -827
0 632 -261
0 970...

output:

66275717341

result:

ok single line: '66275717341'

Test #28:

score: 0
Accepted
time: 6ms
memory: 5204kb

input:

7381
9 2 822 1642 2462 3282 4102 4922 5742 6562
9 3 94 185 276 367 458 549 640 731
9 4 14 24 34 44 54 64 74 84
9 5 6 7 8 9 10 11 12 13
0 -644 -151
0 -950 349
0 344 145
0 161 -819
0 571 303
0 481 531
0 -644 105
0 821 802
0 -697 909
9 15 16 17 18 19 20 21 22 23
0 -421 -543
0 -816 889
0 773 -254
0 -219...

output:

3021509835725

result:

ok single line: '3021509835725'

Test #29:

score: 0
Accepted
time: 14ms
memory: 5608kb

input:

9331
6 2 1557 3112 4667 6222 7777
6 3 262 521 780 1039 1298
6 4 47 90 133 176 219
6 5 12 19 26 33 40
6 6 7 8 9 10 11
0 -236 -302
0 39 410
0 -424 -529
0 107 319
0 -705 -271
0 9 52
6 13 14 15 16 17 18
0 -385 -363
0 -271 -170
0 611 507
0 283 -357
0 582 -994
0 687 -118
6 20 21 22 23 24 25
0 -338 394
0 -...

output:

7634291710385

result:

ok single line: '7634291710385'

Test #30:

score: 0
Accepted
time: 6ms
memory: 5180kb

input:

9901
99 2 102 202 302 402 502 602 702 802 902 1002 1102 1202 1302 1402 1502 1602 1702 1802 1902 2002 2102 2202 2302 2402 2502 2602 2702 2802 2902 3002 3102 3202 3302 3402 3502 3602 3702 3802 3902 4002 4102 4202 4302 4402 4502 4602 4702 4802 4902 5002 5102 5202 5302 5402 5502 5602 5702 5802 5902 6002...

output:

118831327360

result:

ok single line: '118831327360'

Test #31:

score: 0
Accepted
time: 9ms
memory: 4816kb

input:

9901
99 2 102 202 302 402 502 602 702 802 902 1002 1102 1202 1302 1402 1502 1602 1702 1802 1902 2002 2102 2202 2302 2402 2502 2602 2702 2802 2902 3002 3102 3202 3302 3402 3502 3602 3702 3802 3902 4002 4102 4202 4302 4402 4502 4602 4702 4802 4902 5002 5102 5202 5302 5402 5502 5602 5702 5802 5902 6002...

output:

15242981

result:

ok single line: '15242981'

Test #32:

score: 0
Accepted
time: 3ms
memory: 4648kb

input:

2047
2 2 1025
2 3 514
2 4 259
2 5 132
2 6 69
2 7 38
2 8 23
2 9 16
2 10 13
2 11 12
0 -188 -675
0 91 843
2 14 15
0 -818 -711
0 681 150
2 17 20
2 18 19
0 803 -178
0 338 49
2 21 22
0 -835 214
0 -871 -234
2 24 31
2 25 28
2 26 27
0 -505 660
0 999 -590
2 29 30
0 19 -850
0 -177 -612
2 32 35
2 33 34
0 788 6
...

output:

126635786164

result:

ok single line: '126635786164'

Test #33:

score: 0
Accepted
time: 21ms
memory: 6552kb

input:

9841
3 2 3282 6562
3 3 1096 2189
3 4 368 732
3 5 126 247
3 6 46 86
3 7 20 33
3 8 12 16
3 9 10 11
0 701 -507
0 -195 959
0 -669 -826
3 13 14 15
0 -410 -801
0 243 684
0 466 505
3 17 18 19
0 916 777
0 704 957
0 -885 -437
3 21 25 29
3 22 23 24
0 633 797
0 -155 961
0 -211 786
3 26 27 28
0 378 344
0 833 -4...

output:

8732559067380

result:

ok single line: '8732559067380'

Test #34:

score: 0
Accepted
time: 10ms
memory: 5172kb

input:

9841
3 2 3282 6562
3 3 1096 2189
3 4 368 732
3 5 126 247
3 6 46 86
3 7 20 33
3 8 12 16
3 9 10 11
0 1 1
0 1 0
0 1 1
3 13 14 15
0 0 0
0 -1 -1
0 1 -1
3 17 18 19
0 1 0
0 0 1
0 -1 0
3 21 25 29
3 22 23 24
0 0 0
0 -1 -1
0 0 -1
3 26 27 28
0 1 0
0 0 1
0 1 1
3 30 31 32
0 1 1
0 0 0
0 0 1
3 34 38 42
3 35 36 37
...

output:

17115530

result:

ok single line: '17115530'

Test #35:

score: 0
Accepted
time: 12ms
memory: 5732kb

input:

9841
3 2 3282 6562
3 3 1096 2189
3 4 368 732
3 5 126 247
3 6 46 86
3 7 20 33
3 8 12 16
3 9 10 11
0 0 1000
0 95 995
0 189 981
3 13 14 15
0 281 959
0 371 928
0 458 888
3 17 18 19
0 541 840
0 618 785
0 690 723
3 21 25 29
3 22 23 24
0 756 654
0 815 579
0 866 499
3 26 27 28
0 910 414
0 945 325
0 972 234
...

output:

2209407581365

result:

ok single line: '2209407581365'

Test #36:

score: 0
Accepted
time: 6ms
memory: 4928kb

input:

10000
3 2 3335 6668
4 3 836 1669 2502
3 4 282 559
4 5 74 143 213
2 6 40
3 7 18 29
3 8 12 15
3 9 10 11
0 -1 1
0 0 1
0 1 -1
2 13 14
0 -1 0
0 1 -1
2 16 17
0 -1 1
0 1 0
2 19 24
2 20 21
0 1 0
2 22 23
0 0 0
0 -1 0
2 25 26
0 0 -1
2 27 28
0 1 -1
0 0 -1
3 30 34 37
3 31 32 33
0 -1 0
0 1 0
0 0 -1
2 35 36
0 -1 ...

output:

10691810

result:

ok single line: '10691810'

Test #37:

score: 0
Accepted
time: 12ms
memory: 5468kb

input:

10000
3 2 3335 6668
4 3 836 1669 2502
4 4 212 420 628
2 5 108
3 6 40 74
3 7 18 29
2 8 13
2 9 12
2 10 11
0 2 5
0 -9 1
0 7 -1
2 14 17
2 15 16
0 -4 -5
0 -3 -9
0 6 -10
3 19 23 26
3 20 21 22
0 8 9
0 -2 -5
0 4 0
2 24 25
0 -6 -2
0 -3 3
2 27 28
0 -5 5
0 10 8
4 30 31 32 33
0 7 -1
0 8 0
0 -9 -8
2 34 37
2 35 3...

output:

601616561

result:

ok single line: '601616561'

Test #38:

score: 0
Accepted
time: 16ms
memory: 6328kb

input:

10000
4 2 2501 5003 7502
4 3 627 1251 1877
4 4 162 317 472
4 5 44 83 122
2 6 25
2 7 16
3 8 9 15
0 -877 478
2 10 11
0 901 93
3 12 13 14
0 259 -328
0 654 343
0 -799 -308
0 84 -629
3 17 18 19
0 -828 -51
0 950 -551
2 20 24
3 21 22 23
0 821 477
0 762 152
0 -938 402
0 -421 89
4 26 30 34 40
3 27 28 29
0 98...

output:

5618526794308

result:

ok single line: '5618526794308'

Test #39:

score: 0
Accepted
time: 22ms
memory: 6232kb

input:

10000
5 2 2005 4004 6003 8002
4 3 503 1005 1505
5 4 103 202 301 400
4 5 31 55 79
6 6 10 15 19 23 27
3 7 8 9
0 -117 69
0 737 241
0 21 317
2 11 14
2 12 13
0 907 -928
0 -479 363
0 258 345
3 16 17 18
0 379 -207
0 246 226
0 794 -667
3 20 21 22
0 929 71
0 -646 -277
0 -21 -901
3 24 25 26
0 -207 741
0 605 -...

output:

6098625216625

result:

ok single line: '6098625216625'

Test #40:

score: 0
Accepted
time: 15ms
memory: 5984kb

input:

10000
19 2 528 1059 1585 2111 2637 3163 3689 4215 4741 5267 5793 6319 6845 7371 7897 8423 8949 9475
58 3 12 21 30 39 48 57 66 75 84 93 102 111 120 129 138 147 156 165 174 183 192 201 210 219 228 237 246 255 264 273 282 291 300 309 318 327 336 345 357 366 375 384 393 402 411 420 429 438 447 456 465 4...

output:

6100955968930

result:

ok single line: '6100955968930'

Test #41:

score: 0
Accepted
time: 15ms
memory: 5668kb

input:

10000
56 2 180 358 536 714 892 1070 1248 1426 1604 1782 1960 2138 2316 2494 2672 2850 3028 3206 3384 3562 3740 3918 4096 4274 4452 4630 4808 5017 5195 5373 5551 5729 5907 6085 6263 6441 6619 6797 6975 7153 7331 7509 7687 7865 8043 8221 8399 8577 8755 8933 9111 9289 9467 9645 9823
77 3 4 5 6 7 8 9 10...

output:

3660641457281

result:

ok single line: '3660641457281'

Test #42:

score: 0
Accepted
time: 19ms
memory: 6084kb

input:

10000
29 2 346 690 1057 1401 1745 2089 2433 2777 3121 3465 3809 4153 4497 4841 5185 5529 5873 6217 6561 6905 7249 7593 7937 8281 8625 8969 9313 9657
71 3 7 11 15 19 23 27 31 35 39 43 47 51 55 59 63 67 71 75 79 83 87 91 95 99 103 107 111 115 119 123 127 131 135 139 143 147 151 155 159 163 167 171 175...

output:

5727462431965

result:

ok single line: '5727462431965'

Test #43:

score: 0
Accepted
time: 18ms
memory: 5884kb

input:

10000
62 2 163 324 485 646 807 968 1129 1290 1451 1612 1773 1934 2095 2256 2417 2578 2739 2900 3061 3239 3400 3561 3722 3883 4044 4205 4366 4527 4688 4849 5010 5171 5332 5493 5654 5815 5976 6137 6298 6459 6620 6781 6942 7103 7264 7425 7586 7747 7908 8069 8230 8391 8552 8713 8874 9035 9196 9357 9518 ...

output:

4574216127841

result:

ok single line: '4574216127841'

Test #44:

score: 0
Accepted
time: 18ms
memory: 5888kb

input:

10000
25 2 401 800 1199 1598 1997 2396 2795 3194 3593 3992 4391 4790 5189 5588 5987 6386 6785 7184 7583 8006 8405 8804 9203 9602
64 3 9 15 21 27 33 39 45 51 57 63 69 75 81 87 93 99 105 111 117 123 129 135 141 147 167 173 179 185 191 197 203 209 215 221 227 233 239 245 251 257 263 269 275 281 287 293...

output:

5748953198210

result:

ok single line: '5748953198210'

Extra Test:

score: 0
Extra Test Passed