QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#609216 | #9434. Italian Cuisine | Rosmontispes | WA | 0ms | 3816kb | C++20 | 2.1kb | 2024-10-04 11:17:13 | 2024-10-04 11:17:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
struct Point{
long long x,y;
Point(long long a = 0,long long b = 0){x = a,y = b;}
};
int llsgn(long long x){
if(x == 0)
return 0;
else if(x > 0)
return 1;
return -1;
}
Point operator - (Point a,Point b){
return Point(a.x - b.x,a.y - b.y);
}
long long Dot(Point a,Point b){
return a.x * b.x + a.y * b.y;
}
long long Cross(Point a,Point b){
return a.x*b.y - a.y*b.x;
}
long long Cross(Point sp,Point ep,Point op){
return (sp.x - op.x) * (ep.y - op.y) - (ep.x - op.x) * (sp.y - op.y);
}
long long dis(Point a,Point b){
return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
int judge(Point A,Point B,Point C,long long r){
if(dis(A,B) == 0)
return dis(B,C) >= r * r;
if(Dot(B - A,C - A) < 0)
return dis(A,C) >= r * r;
if(Dot(A - B,C - B) < 0)
return dis(B,C) >= r * r;
return Cross(B - A,C - A) * Cross(B - A,C - A) >= r * r * dis(B,A);
}
void solve(){
int n;
cin>>n;
long long cx,cy,r;
cin>>cx>>cy>>r;
Point cir(cx,cy);
vector<Point>poi(n);
for(int i = 0;i < n;i ++){
long long x,y;
cin>>x>>y;
poi[i] = Point(x,y);
}
int j = 0;
long long S = 0;
long long ans = 0;
for(int st = 0;st < n;st ++){
if(j == st){
j = j + 1 >= n?(j + 1 - n):j + 1;
S = Cross(poi[st],poi[j]);
}
int nex = j + 1 >= n?(j + 1 - n):j + 1;
while(j != st){
if(llsgn(Cross(poi[j],cir,poi[st])) * llsgn(Cross(poi[nex],cir,poi[st])) <= 0)
break;
if(!judge(poi[st],poi[nex],cir,r))
break;
S += Cross(poi[j],poi[nex]);
j = nex;
nex = j + 1 >= n?(j + 1 - n):j + 1;
}
ans = max(ans,S + Cross(poi[j],poi[st]));
nex = st + 1 >= n?(st + 1 - n):st + 1;
S -= Cross(poi[st],poi[nex]);
}
cout<<ans<<"\n";
}
int main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int T;
cin>>T;
while(T --)
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3536kb
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: 3816kb
input:
1 6 0 0 499999993 197878055 -535013568 696616963 -535013568 696616963 40162440 696616963 499999993 -499999993 499999993 -499999993 -535013568
output:
688265363857191648
result:
wrong answer 1st numbers differ - expected: '0', found: '688265363857191648'