QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#740601#9434. Italian CuisinexsdgpWA 0ms3628kbC++201.4kb2024-11-13 10:40:502024-11-13 10:40:51

Judging History

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

  • [2024-11-13 10:40:51]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3628kb
  • [2024-11-13 10:40:50]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
int n,r;
double eps=1e-12;
struct VECTOR
{
	int x,y;
	int 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
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3608kb

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'