QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#187543 | #3854. Radar | Nax_hueux# | WA | 0ms | 2324kb | C++14 | 2.3kb | 2023-09-24 17:58:46 | 2023-09-24 17:58:50 |
Judging History
answer
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cctype>
#define y0 _y0
#define y1 _y1
using namespace std;
inline int read(){
int x=0,f=0; char c=getchar();
while(!isdigit(c)) f|=c=='-',c=getchar();
while(isdigit(c)) x=x*10+(c^'0'),c=getchar();
return f?-x:x;
}
const int maxn=100010;
const double eps=1e-8;
const double pi=acos(-1);
int cir[maxn];
struct Point{
double x,y;
bool operator<(const Point &p)const{
return atan2(y,x)<atan2(p.y,p.x);
}
};
typedef Point Line;
inline double dot(Point p,Point q){ return p.x*q.x+p.y*q.y; }
inline double len(Point p){ return sqrt(dot(p,p)); }
inline double cross(Point p,Point q){ return p.x*q.y-p.y*q.x; }
Line line[maxn];
int R,F,N;
Line get1_line(double x,double y){
Line res=(Line){x,y};
int l=1,r=F;
while(l<r){
int mid=l+r+1>>1;
if(res<line[mid]) r=mid-1;
else l=mid;
}
if(l==1&&res<line[l]) return line[F];
return line[l];
}
Line get2_line(double x,double y){
Line res=(Line){x,y};
int l=1,r=F;
while(l<r){
int mid=l+r+1>>1;
if(res<line[mid]) r=mid-1;
else l=mid;
}
if(l<F) return line[l+1];
if(line[F]<res) return line[1];
return line[l];
}
inline double check(Line l,Point p){
double t=atan2(p.y,p.x)-atan2(l.y,l.x);
if(t<0) t+=2*pi;
if(t>=2*pi) t-=2*pi;
if(t>pi) t=2*pi-t;
double ll=len(p);
// printf("ll = %lf\n",ll);
int pp=lower_bound(cir+1,cir+R+1,ll)-cir,qq=0;
if(pp<=R) qq=pp-1;
if(qq==0) qq=1;
if(pp==R+1) pp=R;
// printf("%d %d\n",pp,qq);
double d1=sqrt((ll*cos(t)-cir[pp])*(ll*cos(t)-cir[pp])+ll*ll*sin(t)*sin(t));
double d2=sqrt((ll*cos(t)-cir[qq])*(ll*cos(t)-cir[qq])+ll*ll*sin(t)*sin(t));
return min(d1,d2);
}
int main(){
R=read(),F=read(),N=read();
for(int i=1;i<=R;i++) cir[i]=read();
sort(cir+1,cir+R+1);
for(int i=1;i<=F;i++) line[i].x=read(),line[i].y=read();
sort(line+1,line+F+1);
while(N--){
int x=read(),y=read();
Point p={x,y};
int tmp=lower_bound(line+1,line+F+1,p)-line;
Line l1=line[min(tmp,F)],l2=line[min(tmp+1,F)];
// Line l1=get1_line(x,y),l2=get2_line(x,y);
printf("%.12lf\n",min(check(l1,p),min(check(line[1],p),check(l2,p))));
}
}
/*
3 7 5
2
4
7
8 4
2 8
-1 5
-7 2
-4 -4
1 -8
6 -3
3 -1
8 1
2 6
-5 2
-1 -1
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 2324kb
input:
3 8 4 2 4 7 1 0 2 1 0 1 -1 1 -5 -2 -5 -6 -2 -7 6 -1 -1 -1 3 1 -5 -3 8 1
output:
0.605291072917 0.977772290466 1.551845105402 2.750120773895
result:
wrong answer 4th numbers differ - expected: '1.4142136', found: '2.7501208', error = '0.9446290'