QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#94912#4368. Oilnixnehc1WA 412ms3784kbC++141.8kb2023-04-08 09:36:432023-04-08 09:36: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-04-08 09:36:47]
  • 评测
  • 测评结果:WA
  • 用时:412ms
  • 内存:3784kb
  • [2023-04-08 09:36:43]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2010;
int n,val[2*N],tot,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;
};
struct node
{
    Point p;
    int val;
}b[2*N];
Line a[N];
Point base;

int sign(Point x)
{
    if(x.y>0) return 0;
    return 1;
}

bool cmp(node a,node b)
{
    if(sign(a.p)!=sign(b.p)) return sign(a.p)<sign(b.p);
    if(a.p*b.p==0) return a.val>b.val;
    return a.p*b.p>0;
}

int work(Point x)
{
    base=x;
    tot=0;
    int sum=0,res=0;
    for(int i=1;i<=n;i++) 
    {
        if((a[i].a==x) || (a[i].b==x)) {sum+=a[i].b.x-a[i].a.x;continue;}
        if(a[i].a.y==x.y) continue;
        if(a[i].a.y<x.y) b[++tot]={a[i].a-base,(a[i].b.x-a[i].a.x)},b[++tot]={a[i].b-base,-(a[i].b.x-a[i].a.x)};
        else b[++tot]={a[i].b-base,(a[i].b.x-a[i].a.x)},b[++tot]={a[i].a-base,-(a[i].b.x-a[i].a.x)};
    }
    sort(b+1,b+tot+1,cmp);
    res=max(res,sum);
    for(int i=1;i<=tot;i++) 
    {
        sum+=b[i].val;
        res=max(res,sum);
    }
    return res;
}

signed main(void)
{
    scanf("%lld",&n);
    for(int i=1,x0,x1,y;i<=n;i++)
    {
        scanf("%lld%lld%lld",&x0,&x1,&y);
        if(x0>x1) swap(x0,x1);
        a[i]=(Line){(Point){x0,y},(Point){x1,y}};
    }
    for(int i=1;i<=n;i++) ans=max({ans,work(a[i].a),work(a[i].b)});
    
    printf("%lld\n",ans);
    
    return 0;
}

详细

Test #1:

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

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: 3784kb

input:

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

output:

25

result:

ok single line: '25'

Test #3:

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

input:

1
-100 180 20

output:

280

result:

ok single line: '280'

Test #4:

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

input:

1
-1000000 1000000 1

output:

2000000

result:

ok single line: '2000000'

Test #5:

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

input:

1
-1000000 1000000 1000000

output:

2000000

result:

ok single line: '2000000'

Test #6:

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

input:

1
-1000000 -999999 1000000

output:

1

result:

ok single line: '1'

Test #7:

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

input:

1
1000000 999999 1000000

output:

1

result:

ok single line: '1'

Test #8:

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

input:

2
-1000 0 200
1 1000 200

output:

1000

result:

ok single line: '1000'

Test #9:

score: -100
Wrong Answer
time: 412ms
memory: 3612kb

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:

486063334

result:

wrong answer 1st lines differ - expected: '490622362', found: '486063334'