QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#623258 | #9434. Italian Cuisine | ptit_noodles | WA | 0ms | 3708kb | C++14 | 2.3kb | 2024-10-09 10:54:37 | 2024-10-09 10:54:41 |
Judging History
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)) > r * (double)(std::sqrt(A * A + B * B));
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 < 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: 3596kb
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: 3708kb
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'