QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#94920#4368. Oilnixnehc1WA 2803ms3824kbC++141.4kb2023-04-08 10:45:512023-04-08 10:45:55

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-08 10:45:55]
  • 评测
  • 测评结果:WA
  • 用时:2803ms
  • 内存:3824kb
  • [2023-04-08 10:45:51]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2010;
int n,ans;
struct Point
{
    int x,y;
    friend inline Point operator + (const Point &a,const Point &b) {return (Point){a.x+b.x,a.y+b.y};}
    friend inline Point operator - (const Point &a,const Point &b) {return (Point){a.x-b.x,a.y-b.y};}
    friend inline int operator * (const Point &a,const Point &b) {return a.x*b.y-a.y*b.x;}
    friend inline bool operator == (const Point &a,const Point &b) {return (a.x==b.x)&(a.y==b.y);}
};
struct Line
{
    Point a,b;
}a[N];

int sign(int x)
{
    if(x<0) return -1;
    if(x>0) return 1;
    return 0;
}

int work(Point A,Point B)
{
    int ans=0;
    for(int i=1;i<=n;i++)
        if(sign((a[i].a-A)*(B-A))*sign((a[i].b-A)*(B-A))!=1) ans+=abs(a[i].b.x-a[i].a.x);
    return ans;
}

signed main(void)
{
    srand(clock());
    scanf("%lld",&n);
    for(int i=1;i<=n;i++) 
    {
        int x0,x1,y;
        scanf("%lld%lld%lld",&x0,&x1,&y);
        ans=max(ans,abs(x0-x1));
        a[i]=(Line){(Point){x0,y},(Point){x1,y}};
    }
    random_shuffle(a+1,a+n+1);
    for(int i=1;i<=min(500ll,n);i++)
        for(int j=i+1;j<=min(500ll,n);j++)
            if(a[i].a.y!=a[j].a.y) ans=max({ans,work(a[i].a,a[j].a),work(a[i].a,a[j].b),work(a[i].b,a[j].a),work(a[i].b,a[j].b)});
    printf("%lld\n",ans);
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3636kb

input:

5
100 180 20
30 60 30
70 110 40
10 40 50
0 80 70

output:

200

result:

ok single line: '200'

Test #2:

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

input:

3
50 60 10
-42 -42 20
25 0 10

output:

25

result:

ok single line: '25'

Test #3:

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

input:

1
-100 180 20

output:

280

result:

ok single line: '280'

Test #4:

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

input:

1
-1000000 1000000 1

output:

2000000

result:

ok single line: '2000000'

Test #5:

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

input:

1
-1000000 1000000 1000000

output:

2000000

result:

ok single line: '2000000'

Test #6:

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

input:

1
-1000000 -999999 1000000

output:

1

result:

ok single line: '1'

Test #7:

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

input:

1
1000000 999999 1000000

output:

1

result:

ok single line: '1'

Test #8:

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

input:

2
-1000 0 200
1 1000 200

output:

1000

result:

ok single line: '1000'

Test #9:

score: 0
Accepted
time: 2746ms
memory: 3824kb

input:

1000
737368 429284 959063
-548693 513523 43074
243164 -465669 860567
422975 -244747 588631
-136535 -470055 501433
-580596 -269833 22422
476738 -448258 866889
358773 563858 950905
-923261 208187 66835
-295330 444422 360513
-903435 841952 491761
377801 520064 65247
479135 -307498 426574
-794533 -46924...

output:

490622362

result:

ok single line: '490622362'

Test #10:

score: 0
Accepted
time: 2749ms
memory: 3692kb

input:

1000
393505 133958 96751
942939 72421 396439
-822694 -718897 366172
-833366 91559 389785
28456 -507666 398767
-178646 616985 288351
465302 236829 106233
-911686 531549 436738
946908 -619546 27459
840101 -51671 27117
904596 -552691 993402
-379495 -968868 996117
-993434 826061 624577
390359 750548 209...

output:

474626777

result:

ok single line: '474626777'

Test #11:

score: 0
Accepted
time: 2803ms
memory: 3624kb

input:

1000
91153 -919136 629430
-928593 -340764 946503
-958781 151370 414466
776584 -865178 350581
266056 -678142 180528
855892 -61597 800115
-150759 821898 16625
286683 401612 387028
-104779 -495288 75284
-292434 725113 64163
925796 -886633 920311
-995416 275385 423913
-922152 395549 705834
138194 618689...

output:

482990936

result:

ok single line: '482990936'

Test #12:

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

input:

3
10 20 10
20 30 20
10 20 30

output:

30

result:

ok single line: '30'

Test #13:

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

input:

3
10 20 30
20 30 20
10 20 10

output:

30

result:

ok single line: '30'

Test #14:

score: -100
Wrong Answer
time: 649ms
memory: 3696kb

input:

1000
-500 -499 3
-499 -498 4
-498 -497 3
-497 -496 4
-496 -495 3
-495 -494 4
-494 -493 3
-493 -492 4
-492 -491 3
-491 -490 4
-490 -489 3
-489 -488 4
-488 -487 3
-487 -486 4
-486 -485 3
-485 -484 4
-484 -483 3
-483 -482 4
-482 -481 3
-481 -480 4
-480 -479 3
-479 -478 4
-478 -477 3
-477 -476 4
-476 -4...

output:

2

result:

wrong answer 1st lines differ - expected: '4', found: '2'