QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#623419#9434. Italian Cuisineptit_noodlesWA 0ms3676kbC++142.4kb2024-10-09 11:52:252024-10-09 11:52:26

Judging History

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

  • [2024-10-09 11:52:26]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3676kb
  • [2024-10-09 11:52:25]
  • 提交

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;
    // return (double)(std::abs(A * x + B * y + C)) - r * (double)(std::sqrt(A * A + B * B)) > 1e-9;

}

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 < points.size(); 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);
        }
        for (int i = 0; i < n; i++) 
            points.push_back(points[i]);
        solve();
    }
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: -100
Wrong Answer
time: 0ms
memory: 3676kb

input:

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

output:

286862654137719264

result:

wrong answer 1st numbers differ - expected: '0', found: '286862654137719264'