QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#187414 | #3854. Radar | OUYE# | WA | 144ms | 5192kb | C++14 | 2.8kb | 2023-09-24 17:05:30 | 2023-09-24 17:05:31 |
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];
angle[cntp+2] = angle[2];
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;
double ouye = tryit(angle[t],arg.x,arg.y,cntr);
ouye = std::min(ouye,tryit(angle[t-1],arg.x,arg.y,cntr));
ouye = std::min(ouye,tryit(angle[t+1],arg.x,arg.y,cntr));
if(t != 1)
ouye = std::min(ouye,tryit(angle[t-2],arg.x,arg.y,cntr));
else if(cntp != 1)
ouye = std::min(ouye,tryit(angle[cntp-1],arg.x,arg.y,cntr));
printf("%.13Lf\n",sqrt(ouye));
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4020kb
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: 0
Accepted
time: 0ms
memory: 4152kb
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 15.8749850992576 15.8749850992576 15.8749850992576 15.8749850992576 15.8749850992576 4.9296567010457 4.9296567010457 4.9296567010457 4.9296567010457 4.9296567010457 4.9296567010457 4.9296567010457 4.9296567010457 2.0000000000000 2.0000000000000 2.00...
result:
ok 32 numbers
Test #3:
score: 0
Accepted
time: 1ms
memory: 4048kb
input:
3 4 1681 16 8 4 -1 0 0 -1 0 1 1 0 -9 17 -4 -7 2 -13 -11 -17 15 -19 -7 1 -8 14 -8 -7 -8 20 -16 -3 12 14 -3 12 9 -5 -18 11 3 -1 2 0 -18 0 0 -19 -1 -19 18 -8 2 20 5 -8 -8 -19 -9 -16 20 -19 14 -1 3 10 -1 -4 4 10 16 17 19 -7 -17 4 1 -12 -5 -12 -5 -10 -15 -5 -10 -19 -2 -10 -4 -16 -2 4 -14 8 -17 16 4 1 16 ...
output:
9.0553851381374 4.1231056256177 3.6055512754640 11.0453610171873 15.2970585407784 1.4142135623731 8.2462112512353 7.0000000000000 8.9442719099992 3.0000000000000 12.1655250605964 5.0000000000000 5.0990195135928 11.1803398874989 1.4142135623731 2.0000000000000 2.0000000000000 3.0000000000000 3.162277...
result:
ok 1681 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 4032kb
input:
3 4 1681 16 8 4 -1 -1 1 -1 -1 1 1 1 17 1 13 7 -13 -18 -1 18 4 -12 -9 3 5 10 -10 1 -12 -4 14 10 -18 19 0 -3 -7 3 -16 11 -15 9 16 1 -8 -12 3 1 0 -2 15 -18 -14 20 9 -19 17 12 20 5 -3 -6 12 -1 9 10 -13 -9 -20 -15 -11 6 17 -2 -10 -19 15 -8 -6 17 18 15 2 -3 18 -12 8 -3 -11 -6 19 -15 20 0 3 4 2 -16 -6 -17 ...
output:
11.7773721193036 4.6315936825902 6.8956561009773 12.2914229053669 6.5559640035805 4.2703042060470 4.3925360004476 6.3678258857453 6.5559640035805 2.9903163793705 10.1875203594951 2.8336261665087 2.9770648313654 4.6967798601620 4.3522398886931 11.3284558097968 3.3840301477099 1.8364593657444 2.947251...
result:
ok 1681 numbers
Test #5:
score: 0
Accepted
time: 1ms
memory: 4032kb
input:
1 4 16 7 0 1 1 0 0 -1 -1 0 3 0 0 3 -3 0 0 -3 3 3 3 -3 -3 3 -3 -3 8 0 0 8 -8 0 0 -8 8 8 8 -8 -8 8 -8 -8
output:
4.0000000000000 4.0000000000000 4.0000000000000 4.0000000000000 5.0000000000000 5.0000000000000 5.0000000000000 5.0000000000000 1.0000000000000 1.0000000000000 1.0000000000000 1.0000000000000 8.0622577482985 8.0622577482985 8.0622577482985 8.0622577482985
result:
ok 16 numbers
Test #6:
score: 0
Accepted
time: 0ms
memory: 3904kb
input:
30 4 120 128 1 2 256 4 512 1024 2048 8 4096 32768 131072 262144 524288 8192 268167 16 536334 16384 1047 32 2095 8380 64 134083 65536 4190 67041 33520 16760 536334 0 -536335 0 0 536334 0 -536335 -1 1 -2 2 -4 4 -8 8 -16 16 -32 32 -64 64 -128 128 -256 256 -512 512 -1024 1024 -2048 2048 -4096 4096 -8192...
output:
1.0000000000000 2.0000000000000 4.0000000000000 8.0000000000000 16.0000000000000 32.0000000000000 64.0000000000000 128.0000000000000 256.0000000000000 512.0000000000000 1024.0000000000000 2048.0000000000000 4096.0000000000000 8192.0000000000000 16384.0000000000000 32768.0000000000000 65536.000000000...
result:
ok 120 numbers
Test #7:
score: 0
Accepted
time: 1ms
memory: 4144kb
input:
4 4 1681 1000 1 999000 999 999000 999000 -999001 999000 999000 -999001 -999001 -999001 9 2 -17 -3 15 3 -19 -6 -6 -16 19 6 -12 -16 1 4 4 12 4 -15 -1 -17 5 7 12 13 19 -19 6 -16 -9 -19 6 -10 1 -20 18 17 -2 -20 13 -13 2 -7 13 14 -15 -7 7 -2 -3 4 -15 11 13 -15 20 -20 13 5 14 -5 13 11 20 0 -4 18 -2 -2 -18...
output:
8.3930715958996 16.4534412434766 14.4756400852358 19.0432313681442 16.1829324174512 19.0432313681442 19.0105765365902 3.3058935536606 11.7631876207952 14.6673083600556 16.2955256397971 7.6177055109477 16.6926529030191 25.8700576850889 16.1829321987597 20.0848704315849 10.6945116845406 19.29511600746...
result:
ok 1681 numbers
Test #8:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
3 3 108 8 16 4 0 1 0 -1 -1 0 0 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 0 17 0 18 0 19 0 0 0 -1 0 -2 0 -3 0 -4 0 -5 0 -6 0 -7 0 -8 0 -9 0 -10 0 -11 0 -12 0 -13 0 -14 0 -15 0 -16 0 -17 0 -18 0 -19 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16...
output:
4 3.0000000000000 2.0000000000000 1.0000000000000 0.0000000000000 1.0000000000000 2.0000000000000 1.0000000000000 0.0000000000000 1.0000000000000 2.0000000000000 3.0000000000000 4.0000000000000 3.0000000000000 2.0000000000000 1.0000000000000 0.0000000000000 1.0000000000000 2.0000000000000 3.00000000...
result:
ok 108 numbers
Test #9:
score: 0
Accepted
time: 1ms
memory: 4192kb
input:
3 3 1681 8 16 4 -1 0 0 1 0 -1 9 2 -17 -3 15 3 -19 -6 -6 -16 19 6 -12 -16 1 4 4 12 4 -15 -1 -17 5 7 12 13 19 -19 6 -16 -9 -19 6 -10 1 -20 18 17 -2 -20 13 -13 2 -7 13 14 -15 -7 7 -2 -3 4 -15 11 13 -15 20 -20 13 5 14 -5 13 11 20 0 -4 18 -2 -2 -18 7 6 -3 -9 -9 -8 -12 -16 20 -1 -13 14 20 -7 -14 13 -14 19...
output:
9.2195444572929 3.1622776601684 15.0332963783729 6.7082039324994 6.0000000000000 19.1049731745428 12.0000000000000 1.0000000000000 5.6568542494924 4.1231056256177 1.4142135623731 5.0990195135928 12.3693168768530 19.2353840616713 6.0000000000000 9.4868329805051 6.3245553203368 4.1231056256177 18.0277...
result:
ok 1681 numbers
Test #10:
score: 0
Accepted
time: 1ms
memory: 4068kb
input:
3 2 1681 16 8 4 0 1 0 -1 -1 -17 -18 -12 4 -6 12 17 -14 -11 -10 19 -19 -15 -15 -17 2 13 -8 -13 -18 7 -17 12 -20 16 3 12 -13 13 10 5 18 -9 -16 4 1 17 -19 -6 -17 -4 12 -18 -10 -17 -9 -20 13 6 11 0 4 5 2 -15 8 -12 1 9 17 -10 1 -13 -8 1 -12 11 5 0 20 -16 -5 8 -13 -2 7 12 -8 14 -4 9 10 -11 19 -3 -18 8 -4 ...
output:
1.4142135623731 18.4390889145858 4.4721359549996 12.0415945787923 14.3178210632764 10.4403065089106 19.0262975904404 15.0332963783729 3.6055512754640 8.5440037453175 18.0277563773199 17.4642491965730 20.0000000000000 5.0000000000000 13.3416640641263 10.0498756211209 18.0277563773199 16.0000000000000...
result:
ok 1681 numbers
Test #11:
score: 0
Accepted
time: 1ms
memory: 4036kb
input:
3 2 1681 16 8 4 -1 -999001 0 1 13 -1 -7 19 19 -13 17 -1 -14 14 18 -9 10 -10 11 20 6 16 -16 7 14 -7 -3 4 7 -14 -20 2 14 -6 13 16 -16 -13 2 0 -8 20 -3 20 0 14 -18 1 -15 12 -3 -12 -13 -14 14 0 12 4 -14 9 -10 -9 20 15 -20 0 19 4 16 -8 3 -14 19 -15 -11 19 6 -9 -17 -5 -17 13 18 12 6 12 -16 -10 12 7 8 -6 -...
output:
13.3416679655883 7.6157731058639 19.2353998816819 17.2626804447051 14.1421356237310 18.0277643729907 10.1980468796765 11.7046999107196 6.0000000000000 16.0312195418814 14.0356768352672 3.0000000000000 7.2801252890472 20.0997512422418 14.1421395874890 13.0000000000000 16.2788048544176 4.4721359549996...
result:
ok 1681 numbers
Test #12:
score: 0
Accepted
time: 1ms
memory: 4080kb
input:
3 2 1 1 2 4 0 1 0 -1 -7 0
output:
7.0710678118655
result:
ok found '7.0710678', expected '7.0710678', error '0.0000000'
Test #13:
score: 0
Accepted
time: 1ms
memory: 3956kb
input:
3 2 1 1 2 4 0 1 -1 -999001 -7 0
output:
7.0710668209260
result:
ok found '7.0710668', expected '7.0710668', error '0.0000000'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3880kb
input:
4 1 36 8 1 2 4 0 1 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 -1 0 -2 0 -3 0 -4 0 -5 0 -6 0 -7 0 -8 0 -9 -1 0 -2 0 -3 0 -4 0 -5 0 -6 0 -7 0 -8 0 -9 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0
output:
0.0000000000000 0.0000000000000 1.0000000000000 0.0000000000000 1.0000000000000 2.0000000000000 1.0000000000000 0.0000000000000 1.0000000000000 2.0000000000000 3.0000000000000 4.0000000000000 5.0000000000000 6.0000000000000 7.0000000000000 8.0000000000000 9.0000000000000 10.0000000000000 1.414213562...
result:
ok 36 numbers
Test #15:
score: 0
Accepted
time: 1ms
memory: 4064kb
input:
4 5 8 8 1 2 4 0 1 1 1 1 -1 -3 2 -2 -5 -4 0 -4 -1 -4 -2 -8 -1 -8 -2 -8 -3 -8 -4 -9 -3
output:
2.3182731895074 3.1473792392236 3.0430036645565 5.6011396576375 6.2947584784471 6.5534384968573 6.0860073291131 7.4801645331180
result:
ok 8 numbers
Test #16:
score: 0
Accepted
time: 138ms
memory: 5124kb
input:
99999 99999 99999 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 480 490 500 510 520 530 540 550 560 570 580 590 600 610 620 630 640 650 660 670 680 690 700 710 720 730...
output:
10.9988657018687 14.5254230187611 21.0731021177943 31.8431891132411 115.9248950136157 49.9913910549399 60.5066297164416 69.9581300395858 134.9023081512422 90.1725614314229 100.2201514116682 110.1548528850700 119.8381380576503 169.2592599248305 139.8577138099724 149.9038626120958 159.8130340193177 16...
result:
ok 99999 numbers
Test #17:
score: -100
Wrong Answer
time: 144ms
memory: 5192kb
input:
99999 99999 99999 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 480 490 500 510 520 530 540 550 560 570 580 590 600 610 620 630 640 650 660 670 680 690 700 710 720 730...
output:
10 15.2958413089682 21.4720815031587 30.8393085198004 35.0065552725237 50.9314581074773 60.5066198289978 70.3637954422017 80.0070389371158 90.0561713216274 100.0006332930519 110.0505082797739 119.8381280857213 129.8851979892816 134.8680764761586 149.8338746362690 159.9504696769169 169.9239989400186 ...
result:
wrong answer 50102nd numbers differ - expected: '2.2313620', found: '2.2313557', error = '0.0000028'