QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#253273 | #3854. Radar | oogerbooger# | WA | 2ms | 4068kb | C++14 | 5.2kb | 2023-11-16 20:36:36 | 2023-11-16 20:36:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ld = long double;
using ll = long long;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
const int INF = 1e7;
struct Point {
int x, y, id; // jak id < 0 tzn, że jestem pałągiem
};
ll scalar(Point a, Point b) {
return a.x * 1LL * b.x + a.y * 1LL * b.y;
}
double len(Point a) {
return sqrt(scalar(a, a));
}
ll det(Point a, Point b) {
return a.x * 1LL * b.y - a.y * 1LL * b.x;
}
ld dl_rzutu_a_na_b(Point a, Point b) {
return (ld)scalar(a, b) / len(b);
}
int32_t main() {
ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0);
int R, F, N; cin >> R >> F >> N;
vector<int> radii(R + 2, 0);
for (int i = 1; i <= R; i++) {
cin >> radii[i];
}
radii[R + 1] = INF;
sort(begin(radii), end(radii));
vector<Point> all_pts(F + N), pts(N), paly(F);
for (int i = 0; i < F; i++) {
int fx, fy; cin >> fx >> fy;
all_pts[i] = {fx, fy, -(i + 1)};
paly[i] = all_pts[i];
}
for (int i = 0; i < N; i++) {
int x, y; cin >> x >> y;
all_pts[i + F] = {x, y, (i + 1)};
pts[i] = all_pts[i + F];
}
auto pom = [&](Point p) {
if (p.x >= 0 && p.y == 0) return 0; // na prawej półprostej
if (p.y > 0) return 1; // na górnym półokregu
if (p.x < 0 && p.y == 0) return 2; // na lewej półprostej
return 3; // na dole
};
int pom_a, pom_b; // zmienne pomocnicze
auto cmp = [&](Point a, Point b) {
pom_a = pom(a), pom_b = pom(b);
if (pom_a != pom_b) return pom_a < pom_b;
if (det(a, b) == 0) return a.id < b.id; // lz więc porównuję id
return det(a, b) >= 0;
};
sort(all_pts.begin(), all_pts.end(), cmp);
vector<int> Left(N), Right(N);
int M = N + F;
int it = 0;
while (all_pts[it].id > 0) it = (it - 1 + M) % M;
int pre_left = all_pts[it].id;
for (int i = 0; i < F + N; i++) {
if (all_pts[i].id < 0) pre_left = all_pts[i].id;
else {
Left[all_pts[i].id - 1] = pre_left;
}
}
it = M - 1;
while (all_pts[it].id > 0) it = (it + 1) % M;
int pre_right = all_pts[it].id;
for (int i = F + N - 1; i >= 0; i--) {
if (all_pts[i].id < 0) pre_right = all_pts[i].id;
else {
Right[all_pts[i].id - 1] = pre_right;
}
}
cout << fixed << setprecision(15);
auto cur_mini = [&](int i, int idx) {
ld mini = INF;
ld rzut = dl_rzutu_a_na_b(pts[i], paly[idx]);
it = int(upper_bound(begin(radii), end(radii), rzut) - begin(radii));
if(it > 0 && it < R+1) {
int r = radii[it];
ld norma = sqrt((ld)paly[idx].x*paly[idx].x+(ld)paly[idx].y*paly[idx].y);
ld ax = (ld)paly[idx].x*r/norma;
ld ay = (ld)paly[idx].y*r/norma;
mini = min(mini, sqrt((ax-pts[i].x)*(ax-pts[i].x)+(ay-pts[i].y)*(ay-pts[i].y) ));
}
it--;
if(it > 0 && it < R+1) {
int r = radii[it];
ld norma = sqrt((ld)paly[idx].x*paly[idx].x+(ld)paly[idx].y*paly[idx].y);
ld ax = (ld)paly[idx].x*r/norma;
ld ay = (ld)paly[idx].y*r/norma;
mini = min(mini, sqrt((ax-pts[i].x)*(ax-pts[i].x)+(ay-pts[i].y)*(ay-pts[i].y) ));
}
return mini;
};
for (int i = 0; i < N; i++) {
ld mini = cur_mini(i, -Left[i]-1);
ld mini2 = cur_mini(i, -Right[i]-1);
cout << min(mini, mini2) << "\n";
// int lewy = -Left[i] - 1; // indeks lewego
// ld rzut = dl_rzutu_a_na_b(pts[i], paly[lewy]);
// it = int(upper_bound(begin(radii), end(radii), rzut) - begin(radii));
// if(it > 0 && it < R+1) {
// int r = radii[it];
// ld norma = sqrt((ld)paly[lewy].x*paly[lewy].x+(ld)paly[lewy].y*paly[lewy].y);
// ld ax = (ld)paly[lewy].x*r/norma;
// ld ay = (ld)paly[lewy].y*r/norma;
// mini = min(mini, sqrt((ax-pts[i].x)*(ax-pts[i].x)+(ay-pts[i].y)*(ay-pts[i].y) ));
// }
// int prawy = -Right[i] - 1;
// rzut = dl_rzutu_a_na_b(pts[i], paly[prawy]);
// int it2 = int(lower_bound(begin(radii), end(radii), rzut) - begin(radii));
// it2--;
// if(it2 > 0 && it2 < R+1) {
// int r = radii[it2];
// ld norma = sqrt((ld)paly[prawy].x*paly[prawy].x+(ld)paly[prawy].y*paly[prawy].y);
// ld ax = (ld)paly[prawy].x*r/norma;
// ld ay = (ld)paly[prawy].y*r/norma;
// mini = min(mini, sqrt((ax-pts[i].x)*(ax-pts[i].x)+(ay-pts[i].y)*(ay-pts[i].y) ));
// }
// cout << mini << "\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3916kb
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.605291072916640 0.977772290465605 1.551845105401790 1.414213562373095
result:
ok 4 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3816kb
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.874985099257575 15.874985099257575 15.874985099257575 15.874985099257575 15.874985099257575 15.874985099257575 15.874985099257575 15.874985099257575 4.929656701045723 4.929656701045723 4.929656701045723 4.929656701045723 4.929656701045723 4.929656701045723 4.929656701045723 4.929656701045723 2.00...
result:
ok 32 numbers
Test #3:
score: 0
Accepted
time: 1ms
memory: 4068kb
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.055385138137417 4.123105625617661 3.605551275463989 11.045361017187261 15.297058540778354 1.414213562373095 8.246211251235321 7.000000000000000 8.944271909999159 3.000000000000000 12.165525060596439 5.000000000000000 5.099019513592785 11.180339887498948 1.414213562373095 2.000000000000000 2.000000...
result:
ok 1681 numbers
Test #4:
score: 0
Accepted
time: 1ms
memory: 3872kb
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.777372119303551 4.631593682590214 6.895656100977256 12.291422905366941 6.555964003580544 4.270304206047021 4.392536000447645 6.367825885745278 6.555964003580544 2.990316379370501 10.187520359495127 2.833626166508712 2.977064831365349 4.696779860161953 4.352239888693120 11.328455809796768 3.384030...
result:
ok 1681 numbers
Test #5:
score: 0
Accepted
time: 0ms
memory: 3880kb
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.000000000000000 4.000000000000000 4.000000000000000 4.000000000000000 5.000000000000000 5.000000000000000 5.000000000000000 5.000000000000000 1.000000000000000 1.000000000000000 1.000000000000000 1.000000000000000 8.062257748298550 8.062257748298550 8.062257748298550 8.062257748298550
result:
ok 16 numbers
Test #6:
score: 0
Accepted
time: 1ms
memory: 3924kb
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.000000000000000 2.000000000000000 4.000000000000000 8.000000000000000 16.000000000000000 32.000000000000000 64.000000000000000 128.000000000000000 256.000000000000000 512.000000000000000 1024.000000000000000 2048.000000000000000 4096.000000000000000 8192.000000000000000 16384.000000000000000 32768...
result:
ok 120 numbers
Test #7:
score: 0
Accepted
time: 2ms
memory: 3876kb
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.393071595899558 16.453441243476639 14.475640085235758 19.043231368144237 16.182932417451168 19.043231368144237 19.010576536590187 3.305893553660572 11.763187620795244 14.667308360055634 16.295525639797088 7.617705510947693 16.692652903019119 25.870057685088936 16.182932198759698 20.084870431584898...
result:
ok 1681 numbers
Test #8:
score: 0
Accepted
time: 1ms
memory: 3792kb
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.000000000000000 3.000000000000000 2.000000000000000 1.000000000000000 0.000000000000000 1.000000000000000 2.000000000000000 1.000000000000000 0.000000000000000 1.000000000000000 2.000000000000000 3.000000000000000 4.000000000000000 3.000000000000000 2.000000000000000 1.000000000000000 0.0000000000...
result:
ok 108 numbers
Test #9:
score: 0
Accepted
time: 1ms
memory: 4008kb
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.219544457292887 3.162277660168379 15.033296378372908 6.708203932499369 6.000000000000000 19.104973174542800 12.000000000000000 1.000000000000000 5.656854249492380 4.123105625617661 1.414213562373095 5.099019513592785 12.369316876852982 19.235384061671345 6.000000000000000 9.486832980505138 6.32455...
result:
ok 1681 numbers
Test #10:
score: 0
Accepted
time: 1ms
memory: 3792kb
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.414213562373095 18.439088914585775 4.472135954999579 12.041594578792295 14.317821063276353 10.440306508910550 19.026297590440448 15.033296378372908 3.605551275463989 8.544003745317531 18.027756377319946 17.464249196572981 20.000000000000000 5.000000000000000 13.341664064126334 10.049875621120890 1...
result:
ok 1681 numbers
Test #11:
score: 0
Accepted
time: 1ms
memory: 3784kb
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.341667965588257 7.615773105863908 19.235399881681894 17.262680444705100 14.142135623730950 18.027764372990675 10.198046879676520 11.704699910719625 6.000000000000000 16.031219541881397 14.035676835267186 3.000000000000000 7.280125289047176 20.099751242241781 14.142139587489014 13.000000000000000 ...
result:
ok 1681 numbers
Test #12:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
3 2 1 1 2 4 0 1 0 -1 -7 0
output:
7.071067811865475
result:
ok found '7.0710678', expected '7.0710678', error '0.0000000'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
3 2 1 1 2 4 0 1 -1 -999001 -7 0
output:
7.071066820925964
result:
ok found '7.0710668', expected '7.0710668', error '0.0000000'
Test #14:
score: -100
Wrong Answer
time: 0ms
memory: 3852kb
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.000000000000000 0.000000000000000 1.000000000000000 0.000000000000000 1.000000000000000 2.000000000000000 1.000000000000000 0.000000000000000 1.000000000000000 10000000.000000000000000 10000000.000000000000000 10000000.000000000000000 10000000.000000000000000 10000000.000000000000000 10000000.0000...
result:
wrong answer 10th numbers differ - expected: '2.0000000', found: '10000000.0000000', error = '4999999.0000000'