QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#187363 | #3854. Radar | OUYE# | WA | 1ms | 3852kb | C++14 | 2.4kb | 2023-09-24 16:38:44 | 2023-09-24 16:38:45 |
Judging History
answer
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<bitset>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
#define ENDL putchar('\n')
# define rep(i,a,b) for(int i=(a); i<=(b); ++i)
# define drep(i,a,b) for(int i=(a); i>=(b); --i)
# define rep0(i,a,b) for(int i=(a); i!=(b); ++i)
inline LL readint() {
LL f=1,x=0;int s=getchar();
while(s<'0'||s>'9') {if(s<0)return -1;if(s=='-')f=-f;s=getchar();}
while(s>='0'&&s<='9') {x=(x<<3)+(x<<1)+(s^48);s=getchar();}
return f*x;
}
using LDB = long double;
# define double LDB
const int MAXN = 100005;
struct Angle{
int x, y;
bool operator < (const Angle &t) const {
if(y == 0 && x < 0) return true;
if(y < 0 && t.y >= 0) return true;
// return atan2(y,x) < atan2(t.y,t.x);
if(y >= 0 && t.y <= 0) return false;
return 1ll*x*t.y > 1ll*y*t.x;
}
};
int radii[MAXN]; Angle angle[MAXN];
int closer(int cntr, double x){
int t = std::lower_bound(radii+1,radii+cntr+1,x)-radii;
if(t == cntr+1) return radii[cntr];
if(t == 1) return radii[1];
if(radii[t]-x < x-radii[t-1])
return radii[t];
return radii[t-1]; // closer
}
double tryit(Angle ang, int x, int y, int cntr){
double len = sqrt(1ll*ang.x*ang.x+1ll*ang.y*ang.y);
double b = double(x)*ang.x/len+double(y)*ang.y/len;
double r = closer(cntr,b); // best
// printf("angle = %.5f, r = %.5f\n",atan2(ang.y,ang.x),r);
return double(x)*x+double(y)*y+r*r-2*r*b;
}
int main(){
int cntr = readint(), cntp = readint(), n = readint();
rep(i,1,cntr) radii[i] = readint();
std::sort(radii+1,radii+cntr+1);
rep(i,1,cntp){
angle[i].x = readint();
angle[i].y = readint();
}
std::sort(angle+1,angle+cntp+1);
// rep(i,1,cntp) printf("ang[%d] = %.5f\n",i,atan2(angle[i].y,angle[i].x));
angle[0] = angle[cntp];
angle[cntp+1] = angle[1];
while(n--){
Angle arg; arg.x = readint(), arg.y = readint();
if(arg.x == 0 && arg.y == 0){
printf("%d\n",radii[1]);
continue;
}
// printf("arg = %.5f\n",arg);
int t = std::lower_bound(angle+1,angle+cntp+1,arg)-angle;
printf("%.13Lf\n",sqrt(std::min(
tryit(angle[t],arg.x,arg.y,cntr),
tryit(angle[t-1],arg.x,arg.y,cntr))));
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3852kb
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.6052910729166 0.9777722904656 1.5518451054018 1.4142135623731
result:
ok 4 numbers
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3660kb
input:
1 8 32 7 0 1 1 0 0 -1 -1 0 1 -1 -1 1 -1 -1 1 1 20 10 10 20 -20 10 10 -20 -10 20 20 -10 -10 -20 -20 -10 2 1 1 2 -2 1 1 -2 -1 2 2 -1 -1 -2 -2 -1 5 0 0 5 -5 0 0 -5 5 5 5 -5 -5 5 -5 -5 9 0 0 9 -9 0 0 -9 9 9 9 -9 -9 9 -9 -9
output:
15.8749850992576 15.8749850992576 15.8749850992576 16.4012194668567 15.8749850992576 16.4012194668567 16.4012194668567 16.4012194668567 4.9296567010457 4.9296567010457 4.9296567010457 5.0990195135928 4.9296567010457 5.0990195135928 5.0990195135928 5.0990195135928 2.0000000000000 2.0000000000000 8.60...
result:
wrong answer 4th numbers differ - expected: '15.8749851', found: '16.4012195', error = '0.0331487'