QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#623241#9434. Italian Cuisineptit_noodlesWA 32ms3688kbC++142.2kb2024-10-09 10:48:482024-10-09 10:48:48

Judging History

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

  • [2024-10-09 10:48:48]
  • 评测
  • 测评结果:WA
  • 用时:32ms
  • 内存:3688kb
  • [2024-10-09 10:48:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long 
struct point{
    int x,y;
};
vector<point> points;
int x,y,r;
int n;
bool check(int xa,int ya,int xb,int yb)
{
    int A = ya - yb;
    int B = xb - xa;
    int C = -A * xa - B * ya;

    
    // Tính khoảng cách
    return (double)(std::abs(A * x + B * y + C)) / (double)(std::sqrt(A * A + B * B)) > r;

}

double areaOfTriangle(int x1, int y1, int x2, int y2, int x3, int y3) {
    return std::abs(x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2));
}

void solve()
{
    int l = 0, r = 1;
    int cur_area = 0;
    int max_area = 0;
    // cout<<points[1].x<<" "<<points[1].y<<" "<<points[4].x<<" "<<points[4].y<<"\n";
    // cout<<check(points[1].x, points[1].y, points[4].x, points[4].y)<<"\n";
    // return;
    for (int l = 0; l < n; l++) 
    {
        while (r < n && check(points[l].x, points[l].y, points[r].x, points[r].y)) 
        {
            cur_area += areaOfTriangle(points[l].x, points[l].y, points[r-1].x, points[r-1].y, points[r].x, points[r].y);
            r++;
        }
        max_area = max(max_area, cur_area);
        // cout<<l<<" "<<r<<" "<<cur_area<<"\n";
        cur_area -= areaOfTriangle(points[l].x, points[l].y, points[l+1].x, points[l+1].y, points[r-1].x, points[r-1].y);
    }
    reverse(points.begin(), points.end());
    l = 0, r = 1;
    cur_area = 0;
    for (int l = 0; l < n; l++) 
    {
        while (r < n && check(points[l].x, points[l].y, points[r].x, points[r].y)) 
        {
            cur_area += areaOfTriangle(points[l].x, points[l].y, points[r-1].x, points[r-1].y, points[r].x, points[r].y);
            max_area = max(max_area, cur_area);
            r++;
        }
        cur_area -= areaOfTriangle(points[l].x, points[l].y, points[l+1].x, points[l+1].y, points[r-1].x, points[r-1].y);
    }
    cout<<max_area<<"\n";
}

signed main()
{
    // if (fopen("thu.inp", "r"))
    //     freopen("thu.inp", "r", stdin);
    int tc; cin>>tc;
    while (tc--)
    {
        points.clear();
        cin>>n;
        cin>>x>>y>>r;
        for (int i = 1; i <= n; i++)
        {
            point a;
            cin>>a.x>>a.y;
            points.push_back(a);
        }
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
5
1 1 1
0 0
1 0
5 0
3 3
0 5
6
2 4 1
2 0
4 0
6 3
4 6
2 6
0 3
4
3 3 1
3 0
6 3
3 6
0 3

output:

5
24
0

result:

ok 3 number(s): "5 24 0"

Test #2:

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

input:

1
6
0 0 499999993
197878055 -535013568
696616963 -535013568
696616963 40162440
696616963 499999993
-499999993 499999993
-499999993 -535013568

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: -100
Wrong Answer
time: 32ms
memory: 3688kb

input:

6666
19
-142 -128 26
-172 -74
-188 -86
-199 -157
-200 -172
-199 -186
-195 -200
-175 -197
-161 -188
-144 -177
-127 -162
-107 -144
-90 -126
-87 -116
-86 -104
-89 -97
-108 -86
-125 -80
-142 -74
-162 -72
16
-161 -161 17
-165 -190
-157 -196
-154 -197
-144 -200
-132 -200
-128 -191
-120 -172
-123 -163
-138...

output:

5093
2862
1753
668
3535
7421
4883
10757
10121
1034
1642
3777
4372
1774
4996
5070
2251
3225
4175
1489
1104
3231
12164
1631
5086
25218
1692
6066
2381
1512
3375
5097
2757
13418
8073
14005
1843
11759
17426
12386
10307
4480
2303
2728
773
2187
3385
4266
10877
901
4334
1518
948
13832
1449
2376
3180
4810
14...

result:

wrong answer 2nd numbers differ - expected: '3086', found: '2862'