QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#628443 | #9434. Italian Cuisine | yangbalu | WA | 11ms | 3764kb | C++17 | 2.5kb | 2024-10-10 20:15:54 | 2024-10-10 20:15:55 |
Judging History
answer
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef __int128 ll;
const int N=2e5+5;
inline void read(__int128 &X)
{
X = 0;
int w=0; char ch=0;
while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
if (w) X = -X;
}
void print(__int128 x)
{
if (!x) return ;
if (x < 0) putchar('-'),x = -x;
print(x / 10);
putchar(x % 10 + '0');
}
int sgn(ll x){
if(x<0) return -1;
else if(x>0) return 1;
return 0;
}
struct oi{
ll x,y;
oi(){}
oi(ll x,ll y):x(x),y(y){}
oi operator -(const oi &b)const{
return oi(x - b.x,y - b.y);
}
ll operator ^(const oi &b)const{
return x*b.y - y*b.x;
}
ll operator *(const oi &b)const{
return x*b.x + y*b.y;
}
};
ll r;
oi o,c[N];
ll dot(const oi &a,const oi &b){return (a*b);}
ll det(const oi &a,const oi &b){return (a^b);}
ll dots(const oi &p0,const oi &p1,const oi &p2){return (p1-p0)*(p2-p0);}
ll dets(const oi &p0,const oi &p1,const oi &p2){return (p1-p0)^(p2-p0);}
ll norm(const oi &a,const oi &b){return (b-a)*(b-a);}
bool getd(oi p,oi s,oi t){
ll x=det(s-p,t-p),y=norm(s,t);
return x*x>=r*r*y;
}
bool ck(int i,int j){
if(dets(c[i],c[j+1],o)<=0) return 0;
return getd(o,c[i],c[j+1]);
}
bool ck2(int i,int j){
if(dets(c[i],c[j+1],o)>=0) return 0;
return getd(o,c[i],c[j+1]);
}
int main(){int T=1;
// ios::sync_with_stdio(0);
// cin.tie(0),cout.tie(0);
cin>>T;
while(T--){
int n;cin>>n;
ll x,y;
read(x),read(y),read(r);
o=oi(x,y);
for(int i=1;i<=n;i++){
read(x),read(y);
c[i]=oi(x,y);
c[i+n]=c[i];
}
c[2*n+1]=c[1];
ll s=0,ans=0;
for(int i=1,j=2;i<=2*n;i++){
if(i==j) j++;
while(j+1<=2*n&&dets(c[i],c[i+1],c[j])<dets(c[i],c[i+1],c[j+1])&&ck(i,j)){
s+=dets(c[i],c[j],c[j+1]);
j=j+1;
}
ans=max(ans,s);
s-=dets(c[j],c[i],c[i+1]);
}
// int ri=1,rj=2*n;
// while(ri<rj){swap(c[ri++],c[rj--]);}
// c[2*n+1]=c[1];
// s=0;
// for(int i=1,j=2;i<=2*n;i++){
// if(i==j) j++;
// while(j+1<=2*n&&dets(c[i],c[i+1],c[j])>dets(c[i],c[i+1],c[j+1])&&ck2(i,j)){
// s+=dets(c[i],c[j],c[j+1]);
// j=j+1;
// }
// ans=max(ans,-s);
// s-=dets(c[j],c[i],c[i+1]);
// }
if(ans) print(ans);
else printf("0");
printf("\n");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3764kb
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: 0ms
memory: 3704kb
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: 3760kb
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:
5093 3086 2539 668 3535 7421 4883 5711 5624 1034 2479 3920 4372 2044 4996 5070 2251 4382 4175 1489 1154 3231 4038 1631 5086 13994 1692 6066 627 1512 4488 5456 2757 6599 8557 7444 862 5076 9576 6042 5412 4480 2303 2728 1739 2187 3385 4266 5512 909 4334 1518 948 5036 1449 2376 3180 4810 1443 1786 4783...
result:
wrong answer 26th numbers differ - expected: '14444', found: '13994'