QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#187351 | #3854. Radar | szhlg# | WA | 1ms | 4112kb | C++14 | 1.9kb | 2023-09-24 16:34:37 | 2023-09-24 16:34:38 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
int read(){
int f = 1,x = 0;
char c = getchar();
while(c > '9' || c < '0'){
if(c == '-') f = -1;
c = getchar();
}
while(c >= '0' && c <= '9'){
x = x * 10 + c - '0';
c = getchar();
}
return x * f;
}
int r,f,n;
const int maxn = 100015;
const double eps = 1e-9;
double a1[maxn];
double a2[maxn];
double pi = 3.14159265359;
double js(double x1,double x2,double x3,double x4){
double x5 = x3 * cos(x4);
double x6 = x3 * sin(x4);
x1 = x1 - x5;
x2 = x2 - x6;
return sqrt(x1 * x1 + x2 * x2);
}
signed main()
{
r = read(),f = read(),n = read();
for(int i=1;i<=r;++i){
int x = read();
a1[i] = 1.0 * x;
}
sort(a1 + 1,a1 + r + 1);
for(int i=2;i<=f+1;++i){
int x = read(),y = read();
if(x == 0){
if(y > 0) a2[i] = pi/2;
else a2[i] = -pi/2;
}
else
{
double qaq = 1.0 * y / x;
if(x > 0) a2[i] = atan(qaq);
else{
if(y <= 0) a2[i] = atan(qaq) - pi;
else a2[i] = atan(qaq) + pi;
}
}
}
sort(a2 + 2,a2 + f + 2);
f += 2;
a2[f] = a2[2] + 2 * pi;
a2[1] = a2[f - 1] - 2 * pi;
while(n != 0){
--n;
int x = read(),yyy = read();
double x1 = 1.0 * x,y1 = 1.0 * yyy;
double r1 = sqrt(x1 * x1 + y1 * y1);
int z = 1,y = r;
while(z <= y){
int mid = (z+y)>>1;
if(a1[mid] < r1) z = mid + 1;
else y = mid - 1;
}
//l,l - 1
double r2,r3;
if(x == 0){
if(y > 0) r2 = pi/2;
else r2 = -pi/2;
}
else{
r3 = 1.0 * y1 / x1;
if(y <= 0) r2 = atan(r3) - pi;
else r2 = atan(r3) + pi;
}
int zz = 1,yy = f;
while(zz <= yy){
int mid = (zz+yy)>>1;
if(a2[mid] < r2) zz = mid + 1;
else yy = mid - 1;
}
//l,l - 1
double ans = 1e12;
for(int i=max(z,r);i>=min(z-1,1ll);--i){
for(int j=max(zz,f);j>=min(zz-1,1ll);--j){
ans = min(ans,js(x1,y1,a1[i],a2[j]));
}
}
printf("%.12lf\n",ans);
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 4096kb
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.551845105401 1.414213562373
result:
ok 4 numbers
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 4112kb
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.874985099258 15.874985099258 15.874985099257 15.874985099258 15.874985099257 15.874985099258 15.874985099258 15.874985099257 2.236067977500 2.236067977500 2.236067977500 2.236067977500 2.236067977500 2.236067977500 2.236067977500 2.236067977500 2.000000000000 2.000000000000 2.000000000000 2.00000...
result:
wrong answer 9th numbers differ - expected: '4.9296567', found: '2.2360680', error = '0.5464049'