QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#346698 | #3854. Radar | Kirill22# | WA | 4ms | 4104kb | C++23 | 2.2kb | 2024-03-08 21:20:28 | 2024-03-08 21:20:28 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
#define ld long double
#define point pair<ld, ld>
#define x first
#define y second
point operator-(point a, point b) {
return {a.x - b.x, a.y - b.y};
}
point operator*(point a, ld d) {
return {a.x * d, a.y * d};
}
ld sq(point a) {
return sqrtl(a.x * a.x + a.y * a.y);
}
ld sin(point a, point b) {
return a.x * b.y - a.y * b.x;
}
int id(point a) {
if (a.y > 0 || (a.y == 0 && a.x >= 0)) {
return 0;
}
return 1;
}
bool cmp(point a, point b) {
if (id(a) != id(b)) return id(a) < id(b);
if (sin(a, b) == 0) return a < b;
return sin(a, b) > 0;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int R, n, q;
cin >> R >> n >> q;
vector<ld> r(R);
for (auto& x : r) {
cin >> x;
}
std::sort(r.begin(), r.end());
vector<point> a(n);
for (auto& x : a) {
cin >> x.x >> x.y;
x = x * (1 / (ld) sq(x));
}
std::sort(a.begin(), a.end(), cmp);
while (q--) {
point t;
cin >> t.x >> t.y;
ld ans = 1e18;
int it = std::lower_bound(a.begin(), a.end(), t, cmp) - a.begin();
for (int x = -10; x <= 10; x++) {
int i = (it + x) % n;
if (i < 0) i += n;
// if (i == n - 1) {
// cout << a[i].x << " " << a[i].y << endl;
// cout << a[i].x * 4 << " " << a[i].y * 4 << endl;
// }
// ans = min(ans, sq(t - a[i] * r[j]));
ld alpha = sin(a[i], t) / sq(a[i]) / sq(t);
ld d = cos(alpha) * sq(t);
int it2 = std::lower_bound(r.begin(), r.end(), d) - r.begin();
// cout << d << " " << it << endl;
// for (int i = 0; i < R; i++) upd(i);
if (it2 < r.size()) {
ans = min(ans, sq(t - a[i] * r[it2]));
}
if (it2 + 1 < r.size()) {
ans = min(ans, sq(t - a[i] * r[it2 + 1]));
}
if (it2) {
ans = min(ans, sq(t - a[i] * r[it2 - 1]));
}
}
cout << fixed << setprecision(15) << ans << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3920kb
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: 3956kb
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: 4ms
memory: 3924kb
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: 4ms
memory: 3996kb
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: 4104kb
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: -100
Wrong Answer
time: 1ms
memory: 3844kb
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.258268211684977 2048.539235650613552 4097.078471301227103 8194.156942602454206 16388.313885204908413 32776...
result:
wrong answer 11th numbers differ - expected: '1024.0000000', found: '1024.2582682', error = '0.0002522'