QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#616960 | #9434. Italian Cuisine | masterhuang | WA | 0ms | 3816kb | C++23 | 1.2kb | 2024-10-06 13:15:26 | 2024-10-06 13:15:26 |
Judging History
answer
#include<bits/stdc++.h>
#define LL long long
#define LD long double
#define fr(x) freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);
using namespace std;
const int N=1e5+5;
int T,n;LD r;
struct comp{LD x,y;}a[N],O;
inline LD p2(LD x){return x*x;}
inline comp operator+(comp A,comp B){return {A.x+B.x,A.y+B.y};}
inline comp operator-(comp A,comp B){return {A.x-B.x,A.y-B.y};}
inline LD operator*(comp A,comp B){return A.x*B.y-A.y*B.x;}
inline LD dis(comp A,comp B){return p2(A.x-B.x)+p2(A.y-B.y);}
inline bool chk(comp A,comp B)
{
if(A.x==B.x) return fabsl(A.x-O.x)>=r;
if(A.y==B.y) return fabsl(A.y-O.y)>=r;
LD k=(A.y-B.y)/(A.x-B.x),b=A.y-k*A.x,_k=-1/k,_b=O.y-_k*O.x;
LD X=(_b-b)/(k-_k),Y=k*X+b;
return dis({X,Y},O)>=r*r;
}
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin>>T;
while(T--)
{
cin>>n>>O.x>>O.y>>r;LL ans=0,s=0;
for(int i=1;i<=n;i++) cin>>a[i].x>>a[i].y,a[i+n]=a[i];
for(int i=1,j=1;i<=n;i++)
{
while(j+1<i+n&&chk(a[i],a[j+1])&&(O-a[i])*(a[j+1]-a[i])<=0) s+=fabsl((a[j]-a[i])*(a[j+1]-a[j])),j++;
ans=max(ans,s);s-=fabsl((a[j]-a[i+1])*(a[i+1]-a[i]));
}cout<<ans<<"\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3816kb
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: 3804kb
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'