QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#605578 | #9434. Italian Cuisine | bruteforce_ | WA | 0ms | 3616kb | C++20 | 2.6kb | 2024-10-02 18:02:10 | 2024-10-02 18:02:12 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
int epssgn(double x){
if(fabs(x) < eps) return 0;
else return x < 0?-1:1;
}
struct Point{
double x,y;
Point(double a = 0,double b = 0){x = a,y = b;}
};
Point operator - (Point a,Point b){
return Point(a.x - b.x,a.y - b.y);
}
double Dot(Point a,Point b){
return a.x * b.x + a.y * b.y;
}
double Cross(Point a,Point b){
return a.x*b.y - a.y*b.x;
}
double Cross(Point sp,Point ep,Point op){
return (sp.x - op.x) * (ep.y - op.y) - (ep.x - op.x) * (sp.y - op.y);
}
double dis(Point a,Point b){
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
Point LineCross(const Point &a,const Point &b,const Point &c,const Point &d){
double u = Cross(b,c,a),v = Cross(a,d,b);
return Point ((c.x * v + d.x * u) / (u + v),(c.y * v + d.y * u) / (u + v));
}
bool Inline(Point a,Point b,Point c){
return !epssgn(Cross(b,c,a));
}
bool PointOnSeg(const Point &a,const Point &b,const Point &c){
return Inline(b,c,a) && Dot(a - c,a - b) < eps;
}
double LineCrossCircle(const Point &a,const Point &b,const Point &r,double R){
Point fp = LineCross(r,Point(r.x + a.y - b.y,r.y + b.x - a.x),a,b);
double rtol = dis(r,fp);
double rtos = PointOnSeg(fp,a,b)? rtol:min(dis(a,r),dis(b,r));
return rtos;
}
void solve(){
int n;
cin>>n;
int cx,cy,r;
cin>>cx>>cy>>r;
Point cir(cx,cy);
vector<Point>poi(n);
for(int i = 0;i < n;i ++){
int x,y;
cin>>x>>y;
poi[i] = Point(x,y);
}
int j = 1;
long long S = (long long)Cross(poi[0],poi[1]);
long long ans = 0;
for(int st = 0;st < n;st ++){
if(j == st){
j = j + 1 >= n?(j + 1 - n):j + 1;
S = (long long)Cross(poi[st],poi[j]);
}
int nex = j + 1 >= n?(j + 1 - n):j + 1;
while(j != st){
if(epssgn(Cross(poi[j] - poi[st],cir - poi[st]) * Cross(poi[nex] - poi[st],cir - poi[st])) == -1)
break;
if(epssgn(LineCrossCircle(poi[st],poi[nex],cir,r) - r) == -1)
break;
S += (long long)Cross(poi[j],poi[nex]);
j = nex;
nex = j + 1 >= n?(j + 1 - n):j + 1;
}
ans = max(ans,S + (long long)Cross(poi[j],poi[st]));
nex = st + 1 >= n?st + 1 - n:st + 1;
S -= (long long)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: 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: 3500kb
input:
1 6 0 0 499999993 197878055 -535013568 696616963 -535013568 696616963 40162440 696616963 499999993 -499999993 499999993 -499999993 -535013568
output:
1238514776782540288
result:
wrong answer 1st numbers differ - expected: '0', found: '1238514776782540288'