QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#603642 | #9434. Italian Cuisine | Sound_Medium# | WA | 11ms | 5828kb | C++23 | 2.4kb | 2024-10-01 18:03:31 | 2024-10-01 18:03:31 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int N=2e5+10;
const double eps=1e-13;
int n;
int x,y;int r;
struct Point{
int x,y;
Point(){}
Point(int xx,int yy){
x=xx,y=yy;
}
Point operator+(const Point &o)const{
return Point(x+o.x,y+o.y);
}
Point operator-(const Point &o)const{
return Point(x-o.x,y-o.y);
}
int operator*(const Point&o)const{
return x*o.x+y*o.y;
}
int operator^(const Point&o)const{
return x*o.y-y*o.x;
}
bool operator<(const Point&o)const{
if(x!=o.x)return x<o.x;
return y<o.y;
}
}p[N],st[N];
int xmult(Point p1,Point p2,Point p0){
return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
}
bool check(Point x,Point a,Point b){
if(x*a<=r*r||x*b<=r*r)return 1;
Point t=x;
t.x+=a.y-b.y;
t.y+=b.x-a.x;
double k=xmult(x,a,b);
return xmult(a,x,t)<eps&&k/(sqrtl((b-a)*(b-a)))-r<eps;
}
void solve () {
cin>>n;
cin>>x>>y>>r;
p[0]={x,y};
for(int i=1;i<=n;i++){
int x,y;
cin>>x>>y;
p[i]=p[n+i]={x,y};
}
int maxx=0,res;
vector<int>pre(2*n+2,0);
for(int i=2;i<=2*n;i++){
pre[i]=pre[i-1]+(p[i-1]^p[i]);
}
auto f=[&](int st,int ed)->bool {
{}
if(((p[ed]-p[st])^(p[0]-p[st]))>0&&!check(p[0],p[st],p[ed])){
return 1;
}
return 0;
};
// auto f2=[&](int st,int ed)->bool {
// {}
// if(((p[ed]-p[st])^(p[0]-p[st]))<0&&!check(p[0],p[st],p[ed])){
// return 1;
// }
// return 0;
// };
for(int i=1;i<=n;i++){
int l=i+1,r=n+i-1;
while(l<r){
int mid=l+r+1>>1;
if(f(i,mid))l=mid;
else r=mid-1;
}
maxx=max(maxx,abs(pre[l]-pre[i]+(p[l]^p[i])));
}
for(int i=2*n;i>=n+1;i--){
int l=i-n+1,r=i-1;
while(l<r){
int mid=l+r>>1;
if(f(mid,i))r=mid;
else l=mid+1;
}
// cerr<<i<<" "<<l<<endl;
maxx=max(maxx,abs(pre[i]-pre[l]+(p[i]^p[l])));
}
cout<<maxx<<'\n';
}
signed main () {
ios::sync_with_stdio (false);
cin.tie (nullptr);
int T = 1;
cin >> T;
while (T --) {
solve ();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5828kb
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: 0
Accepted
time: 1ms
memory: 5828kb
input:
1 6 0 0 499999993 197878055 -535013568 696616963 -535013568 696616963 40162440 696616963 499999993 -499999993 499999993 -499999993 -535013568
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: -100
Wrong Answer
time: 11ms
memory: 5696kb
input:
6666 19 -142 -128 26 -172 -74 -188 -86 -199 -157 -200 -172 -199 -186 -195 -200 -175 -197 -161 -188 -144 -177 -127 -162 -107 -144 -90 -126 -87 -116 -86 -104 -89 -97 -108 -86 -125 -80 -142 -74 -162 -72 16 -161 -161 17 -165 -190 -157 -196 -154 -197 -144 -200 -132 -200 -128 -191 -120 -172 -123 -163 -138...
output:
11997 5228 5308 3593 7868 13142 8628 5711 7154 2930 3177 7134 8288 3610 12181 13259 5112 10141 11587 2268 2382 5344 6860 3691 7777 15756 3803 11309 1347 2643 5596 9598 6697 9767 13519 10585 1162 6190 11541 6650 6360 7507 5572 5704 2643 3833 4795 12688 7002 2667 12382 2426 6630 7895 2756 11458 4495 6...
result:
wrong answer 1st numbers differ - expected: '5093', found: '11997'