QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#623367 | #9434. Italian Cuisine | ptit_noodles | WA | 36ms | 3680kb | C++14 | 2.4kb | 2024-10-09 11:33:43 | 2024-10-09 11:33:48 |
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);
}
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: 3680kb
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: 3584kb
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: 36ms
memory: 3552kb
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'