QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#129792 | #4368. Oil | Swarthmore# | WA | 493ms | 3884kb | C++14 | 1.8kb | 2023-07-23 00:05:39 | 2023-07-23 00:05:41 |
Judging History
answer
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
const int maxn = 2100;
const ld pi = acos(-1.0);
struct point{
ld x,y;
int dir; //-1 for left, 1 for right
int id;
};
struct rec{
ld angle;
int id;
};
ld x0[maxn],x1[maxn],y[maxn];
point p[maxn << 1];
rec 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(const rec & a,const rec & b){
if (fabs(a.angle - b.angle) > 1e-9) return a.angle < b.angle;
// priority goes to "+"
int signa = sign_line(base, p[a.id]);
int signb = sign_line(base, p[b.id]);
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;
for (int j = 1;j <= 2*n;j++){
if (j == i) continue;
if (p[j].y == p[i].y) continue;
ld angle = atan2(p[j].y - p[i].y, p[j].x - p[i].x);
if (angle < 0) angle += pi;
events[++siz] = (rec){angle, j};
}
base = p[i];
sort(events+1,events+siz+1,comp);
ld cur = x1[p[i].id] - x0[p[i].id];
ret = max(ret, (ll)cur);
for (int j = 1;j <= siz;j++){
point pt = p[events[j].id];
cur += sign_line(base, pt) * (x1[pt.id] - x0[pt.id]);
ret = max(ret, (ll)(cur + 0.1));
}
}
cout << ret << endl;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3628kb
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: 3676kb
input:
3 50 60 10 -42 -42 20 25 0 10
output:
25
result:
ok single line: '25'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
1 -100 180 20
output:
280
result:
ok single line: '280'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3556kb
input:
1 -1000000 1000000 1
output:
2000000
result:
ok single line: '2000000'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3624kb
input:
1 -1000000 1000000 1000000
output:
2000000
result:
ok single line: '2000000'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
1 -1000000 -999999 1000000
output:
1
result:
ok single line: '1'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3560kb
input:
1 1000000 999999 1000000
output:
1
result:
ok single line: '1'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3708kb
input:
2 -1000 0 200 1 1000 200
output:
1000
result:
ok single line: '1000'
Test #9:
score: 0
Accepted
time: 493ms
memory: 3764kb
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: 493ms
memory: 3880kb
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: 493ms
memory: 3760kb
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: 1ms
memory: 3680kb
input:
3 10 20 10 20 30 20 10 20 30
output:
30
result:
ok single line: '30'
Test #13:
score: 0
Accepted
time: 1ms
memory: 3496kb
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: 221ms
memory: 3884kb
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:
501
result:
wrong answer 1st lines differ - expected: '4', found: '501'