QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#129781#4368. OilSwarthmore#WA 465ms3876kbC++141.7kb2023-07-22 23:40:322023-07-22 23:40:33

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-22 23:40:33]
  • 评测
  • 测评结果:WA
  • 用时:465ms
  • 内存:3876kb
  • [2023-07-22 23:40:32]
  • 提交

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];

bool comp(const rec & a,const rec & b){
    return a.angle < b.angle;
}

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};
        }
        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];
          if ((pt.y > p[i].y && pt.dir == 1)
          || (pt.y < p[i].y && pt.dir == -1)){
              cur += x1[pt.id] - x0[pt.id];
          }
          if ((pt.y > p[i].y && pt.dir == -1) || (pt.y < p[i].y && pt.dir == 1)){
              cur -= x1[pt.id] - x0[pt.id];
          }
          ret = max(ret, (ll)cur);
        }
    }
    cout << ret << endl;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3672kb

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: 1ms
memory: 3632kb

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

input:

1
-100 180 20

output:

280

result:

ok single line: '280'

Test #4:

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

input:

1
-1000000 1000000 1

output:

2000000

result:

ok single line: '2000000'

Test #5:

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

input:

1
-1000000 1000000 1000000

output:

2000000

result:

ok single line: '2000000'

Test #6:

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

input:

1
-1000000 -999999 1000000

output:

1

result:

ok single line: '1'

Test #7:

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

input:

1
1000000 999999 1000000

output:

1

result:

ok single line: '1'

Test #8:

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

input:

2
-1000 0 200
1 1000 200

output:

1000

result:

ok single line: '1000'

Test #9:

score: 0
Accepted
time: 459ms
memory: 3876kb

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: 464ms
memory: 3852kb

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: 465ms
memory: 3812kb

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

input:

3
10 20 10
20 30 20
10 20 30

output:

30

result:

ok single line: '30'

Test #13:

score: -100
Wrong Answer
time: 1ms
memory: 3496kb

input:

3
10 20 30
20 30 20
10 20 10

output:

20

result:

wrong answer 1st lines differ - expected: '30', found: '20'