QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#680570 | #9434. Italian Cuisine | yueyuey | WA | 0ms | 3496kb | C++23 | 2.3kb | 2024-10-26 21:34:55 | 2024-10-26 21:34:57 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define lowbit(x) (x&(-x))
#define pll pair<int,int>
#define int long long
const int N = 1e6+10;
const int mod = 998244353;
const ld eps = 1e-6;
typedef long long lll;
typedef pair<lll, lll> P;
#define x first
#define y second
// 叉乘
lll cross(P a, P b)
{
return a.x * b.y - a.y * b.x;
}
// 点积
lll mul(P a, P b)
{
return a.x * b.x + a.y * b.y;
}
// 点平方和
lll mul(P a)
{
return a.x * a.x + a.y * a.y;
}
// 计算矢量
P del(P a, P b)
{
return {a.x - b.x, a.y - b.y};
}
void solve()
{
int n;
cin>>(n);
P C;
cin>>(C.x);
cin>>(C.y);
lll R;
cin>>(R);
vector<P> a(n);
for (int i = 0; i < n; i++)
{
cin>>(a[i].x);
cin>>(a[i].y);
}
lll ans = 0;
lll S = 0;
for (int l = 0, r = l + 1; l < n; l++)
{
while (1)
{
// 处理首尾循环
int rr = r % n + 1;
// 计算新加点是否在左边界与圆心连线的另一侧
lll s = cross(del(a[rr], a[l]), del(C, a[l]));
// 如果在另一侧,说明新加边与圆相交或凸包包含了圆,移动l
if (s <= 0)
break;
// s同时也是新加边与圆心构成的三角形的面积的两倍,利用s=len*d计算边与圆心的距离
// 如果距离小于R,说明新加边与圆相交,移动l
if (s * s < mul(del(a[rr], a[l])) * R * R)
break;
// 利用叉乘公式计算凸包新增加的三角形面积
S += cross(del(a[r], a[l]), del(a[rr], a[l]));
// 移动r
r = rr;
}
ans = max(ans, S);
// 处理首尾循环
int ll = l % n + 1;
// 减去左边界的三角形面积
S -= cross(del(a[r], a[l]), del(a[r], a[ll]));
}
cout<<ans;
putchar('\n');
}
signed main()
{
// ios::sync_with_stdio(false), std::cin.tie(nullptr), std::cout.tie(nullptr);
int _ = 1;
// std::cin >> _;
cin>>_;
while (_--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
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:
0 24 0
result:
wrong answer 1st numbers differ - expected: '5', found: '0'