QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#129800 | #4368. Oil | Swarthmore# | WA | 305ms | 3636kb | C++14 | 1.8kb | 2023-07-23 00:28:46 | 2023-07-23 00:28:48 |
Judging History
answer
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
const int maxn = 2100;
struct point{
ll x,y;
int dir; //-1 for left, 1 for right
int id;
};
ll x0[maxn],x1[maxn],y[maxn];
point p[maxn << 1];
int events[maxn << 1];
point base;
int sign_line(point base,point p){
if ((p.y > base.y && p.dir == 1)
|| (p.y < base.y && p.dir == -1)) return 1;
else return -1;
}
bool comp(int a,int b){
// priority goes to "+"
if ((p[a].x - base.x) * (p[b].y - base.y)
!= (p[b].x - base.x) * (p[a].y - base.y))
return
(p[a].x - base.x) * (p[b].y - base.y)
> (p[b].x - base.x) * (p[a].y - base.y);
int signa = sign_line(base, p[a]);
int signb = sign_line(base, p[b]);
return signa > signb;
}
int main(){
int n;
cin >> n;
for (int i = 1;i <= n;i++){
cin >> x0[i] >> x1[i] >> y[i];
y[i] *= -1;
if (x0[i] > x1[i]) swap(x0[i],x1[i]);
p[2*i-1] = (point){x0[i], y[i], -1, i};
p[2*i] = (point){x1[i], y[i], 1, i};
}
ll ret = 0;
for (int i = 1;i <= 2*n;i++){
int siz = 0;
// printf("i = %d\n",i);
for (int j = 1;j <= 2*n;j++){
if (j == i) continue;
if (p[j].y == p[i].y) continue;
events[++siz] = j;
}
base = p[i];
sort(events+1,events+siz+1,comp);
ll cur = x1[p[i].id] - x0[p[i].id];
ret = max(ret, cur);
for (int j = 1;j <= siz;j++){
point pt = p[events[j]];
// printf("Event: point (%lld,%lld) with sign %d; cur = %lld\n", pt.x, pt.y, sign_line(base,pt), cur);
cur += sign_line(base, pt) * (x1[pt.id] - x0[pt.id]);
ret = max(ret, cur);
}
}
cout << ret << endl;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
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: 0ms
memory: 3584kb
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: 3632kb
input:
1 -100 180 20
output:
280
result:
ok single line: '280'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3420kb
input:
1 -1000000 1000000 1
output:
2000000
result:
ok single line: '2000000'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3480kb
input:
1 -1000000 1000000 1000000
output:
2000000
result:
ok single line: '2000000'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3440kb
input:
1 -1000000 -999999 1000000
output:
1
result:
ok single line: '1'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
1 1000000 999999 1000000
output:
1
result:
ok single line: '1'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
2 -1000 0 200 1 1000 200
output:
1000
result:
ok single line: '1000'
Test #9:
score: -100
Wrong Answer
time: 305ms
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:
485034187
result:
wrong answer 1st lines differ - expected: '490622362', found: '485034187'