QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#740629 | #9434. Italian Cuisine | xsdgp | WA | 0ms | 3616kb | C++20 | 1.4kb | 2024-11-13 10:47:54 | 2024-11-13 10:47:55 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
int n,r;
double eps=1e-8;
struct VECTOR
{
int x,y;
double operator*(const VECTOR &v)const
{
return x*v.x+y*v.y;
}
double operator^(const VECTOR &v)const
{
return x*v.y-y*v.x;
}
};
struct POINT
{
int x,y;
VECTOR operator-(const POINT &p)const
{
return {x-p.x,y-p.y};
}
}p[2005],p0,o={0,0};
bool eq(double x,double y)
{
return abs(x-y)<=eps;
}
bool check(POINT p1,POINT p2)
{
VECTOR v1=p2-p1,v2=p0-p1;
double dis=(v1^v2)/sqrt(v1*v1);
return dis>r||eq(dis,r);
}
void solve()
{
cin>>n;
cin>>p0.x>>p0.y>>r;
for(int i=0;i<n;i++)
cin>>p[i].x>>p[i].y;
int sum=0;
for(int i=0;i<n;i++)
sum+=((p[i]-o)^(p[(i+1)%n]-o));
int j=0,area=0,ans=0;
for(int i=0;i<n;i++)
{
while(check(p[i],p[(j+1)%n]))
{
area-=((p[j]-o)^(p[i]-o));
j=(j+1)%n;
area+=((p[j]-o)^(p[i]-o))+((p[(j-1+n)%n]-o)^(p[j]-o));
if(((p[j]-p[i])^(p0-p[i]))>0)ans=max(ans,area);
else ans=max(ans,sum-area);
}
area-=((p[i]-o)^(p[(i+1)%n]-o))+((p[j]-o)^(p[i]-o));
area+=((p[j]-o)^(p[(i+1)%n]-o));
}
cout<<ans<<endl;
}
signed main()
{
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int T=1;
cin>>T;
while(T--)solve();
return 0;
}
/*
4
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
6
4 2 1
2 0
4 0
6 3
4 6
2 6
0 3
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
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: 3516kb
input:
1 6 0 0 499999993 197878055 -535013568 696616963 -535013568 696616963 40162440 696616963 499999993 -499999993 499999993 -499999993 -535013568
output:
286862654137719232
result:
wrong answer 1st numbers differ - expected: '0', found: '286862654137719232'