QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#142592#6517. Computational GeometryBUET_POTATOES#WA 2ms3668kbC++201.7kb2023-08-19 13:27:242023-08-19 13:27:26

Judging History

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

  • [2023-08-19 13:27:26]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3668kb
  • [2023-08-19 13:27:24]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using pll = pair<LL, LL>;
using pii = pair<int, int>;

LL dis(pii a, pii b){
    LL x = a.first - b.first, y = a.second - b.second;
    return  x * x + y * y;
}
const int N = 5e3 + 5;
LL dp[N][N];
LL dp2[N][N];
pii points[N];
LL area(pii a, pii b, pii c){
    return a.first * b.second + b.first * c.second + c.first * a.second - a.second * b.first - b.second * c.first - a.first * c.second;
}
void testcase(int cs){
    int n;
    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> points[i].first >> points[i].second;
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++)dp[i][j] = dp2[i][j] = 0;
    }

    for(int len = 1; len < n; len++){
        for(int i = 0; i < n; i++){
            dp[i][(i + len) % n] = max(dp[i][(i + len - 1) % n], max(dp[(i + 1) % n][(i + len) % n], dis(points[i], points[(i + len) % n])));
            dp2[i][(i + len) % n] = dp2[(i + 1) % n][(i + len - 1) % n] + area(points[i], points[(i + 1) % n], points[(i + len) % n]);
        }
    }
//    for(int i = 0; i < n; i++){
//        for(int j = 0; j < n; j++){
//            cout << dp[i][j] << ' ';
//        }
//        cout << endl;
//    }


    LL ans = LLONG_MAX;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(dp2[i][j] > 0 && dp2[j][i] > 0){
                ans = min(ans, dp[i][j] + dp[j][i]);

            }
        }
    }
    cout << ans << "\n";



}

/*
2
4
1 0
2 0
1 1
0 0
6
10 4
9 7
5 7
4 5
6 4
9 3

*/

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int T;
    cin >> T;
    for(int i = 1; i <= T; i++){
        testcase(i);
    }
    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3464kb

input:

2
4
1 0
2 0
1 1
0 0
6
10 4
9 7
5 7
4 5
6 4
9 3

output:

4
44

result:

ok 2 number(s): "4 44"

Test #2:

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

input:

713
8
8 25
3 15
0 5
10 0
19 2
24 6
23 15
15 34
8
25 16
18 25
10 32
1 23
0 14
21 0
27 2
32 6
7
16 15
8 20
1 16
0 12
16 0
21 1
24 5
7
15 1
18 0
24 8
27 15
4 19
0 17
7 8
4
10 20
0 30
15 0
14 10
6
15 0
24 10
21 14
12 14
7 11
0 3
7
18 7
16 9
12 10
6 9
0 4
5 0
15 1
9
0 23
8 13
14 6
24 0
34 1
41 11
37 20
1...

output:

1075
1389
706
687
1550
497
300
1668
471
162
519
190
786
983
367
930
580
524
509
275
617
298
146
1330
494
965
599
1321
866
1210
233
398
560
1548
871
938
366
500
371
1118
1222
1994
712
586
858
624
697
575
1274
882
1035
406
934
670
990
1231
513
2871
939
2735
1610
834
721
585
203
198
1666
617
1166
326
2...

result:

ok 713 numbers

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 3508kb

input:

723
6
219724071 0
454078946 131628774
497404433 165947891
427997418 299842932
68283732 510015817
0 327227140
5
277969751 0
576739203 275664810
244855879 638262097
13873538 700473186
0 59956198
10
69526931 509564969
0 395765436
101436487 0
273066511 46581979
904969235 467379058
942000353 535129295
93...

output:

320990950510053393
968884527011601758
1163242582706157378
879865062732368658
687212580211797154
676902408919929130
1149257533361626411
1299507111430287834
845514798756141601
410893515758460170
340494552567169125
1081804053405835929
1220017957053127490
1287649707801629195
993125871111020743
938163905...

result:

wrong answer 2nd numbers differ - expected: '818929519958899381', found: '968884527011601758'