QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#94919 | #4368. Oil | nixnehc1 | TL | 2ms | 3776kb | C++14 | 1.3kb | 2023-04-08 10:44:00 | 2023-04-08 10:44:01 |
Judging History
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)
{
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}};
}
for(int i=1;i<=n;i++)
for(int j=i+1;j<=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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3776kb
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: 3532kb
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: 3584kb
input:
1 -100 180 20
output:
280
result:
ok single line: '280'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3488kb
input:
1 -1000000 1000000 1
output:
2000000
result:
ok single line: '2000000'
Test #5:
score: 0
Accepted
time: 2ms
memory: 3508kb
input:
1 -1000000 1000000 1000000
output:
2000000
result:
ok single line: '2000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
1 -1000000 -999999 1000000
output:
1
result:
ok single line: '1'
Test #7:
score: 0
Accepted
time: 2ms
memory: 3528kb
input:
1 1000000 999999 1000000
output:
1
result:
ok single line: '1'
Test #8:
score: 0
Accepted
time: 2ms
memory: 3768kb
input:
2 -1000 0 200 1 1000 200
output:
1000
result:
ok single line: '1000'
Test #9:
score: -100
Time Limit Exceeded
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...