QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#596764 | #9434. Italian Cuisine | ucup-team3282# | WA | 0ms | 3612kb | C++20 | 1.9kb | 2024-09-28 16:24:33 | 2024-09-28 16:24:33 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cmath>
#include<vector>
using namespace std;
#define pr pair<int,int>
#define x first
#define y second
deque<pr>que;
long long ans=0,anser=0;
pr pos;
int rds;
pr a[1000050];
int n;
long long S(pr a,pr b,pr c){
long long x1,x2,y1,y2;
x1=b.x-a.x;
x2=c.x-a.x;
y1=b.y-a.y;
y2=c.y-a.y;
return abs(x1*y2-y1*x2);
}
void PUSH(pair<int,int>p){
// cout<<"PUSH"<<endl;
ans=ans+S(que.front(),que.back(),p);
que.push_back(p);
return;
}
void POP(){
// cout<<"POP"<<endl;
pair<int,int>p=que.front();
que.pop_front();
ans-=S(que.front(),que.back(),p);
}
bool ch1(pr l,pr r){
double a,b,c;
a=r.y-l.y;
b=-(r.x-l.x);
c=a*l.y+b*l.x;
if(b==0){
return abs(l.x-pos.x)>rds;
}
if(a==0){
return abs(l.y-pos.y)>rds;
}
return (a*pos.x+b*pos.y+c)*(a*pos.x+b*pos.y+c)/(a*a+b*b)>rds*rds;
}
bool ch2(pr l,pr r){
return (r.x-l.x)*(pos.y-l.y)-(pos.x-l.x)*(r.y-l.y)<0;
}
int main(){
int t;cin>>t;while(t--){
que.clear();
ans=0;anser=0;
cin>>n;
cin>>pos.x>>pos.y>>rds;
for(int i=1;i<=n;i++){
cin>>a[i].x>>a[i].y;
a[i+n]=a[i];
}
que.push_back(a[1]);
que.push_back(a[2]);
for(int i=3;i<=n+n;i++){
PUSH(a[i]);
while(que.size()>n)POP();
while(que.size()>=3&&(ch1(que.front(),que.back())==false||ch2(que.front(),que.back())==true)){
POP();
}
// cout<<ans<<endl;
anser=max(anser,ans);
}
for(int i=1;i<=2*n;i++){
a[i]=a[0];
}
cout<<anser<<endl;
}
return 0;
}
/*
{
Ax1+By1+1=Ax0+By1+1;
A(x1+x0)=B()
}
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
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: 3544kb
input:
1 6 0 0 499999993 197878055 -535013568 696616963 -535013568 696616963 40162440 696616963 499999993 -499999993 499999993 -499999993 -535013568
output:
2477029553565080632
result:
wrong answer 1st numbers differ - expected: '0', found: '2477029553565080632'