QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#524190 | #5106. Islands from the Sky | Andycipation | AC ✓ | 96ms | 4364kb | C++20 | 2.6kb | 2024-08-19 12:00:32 | 2024-08-19 12:00:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...) 42
#endif
struct P {
double x, y;
explicit P(double x_ = 0, double y_ = 0) : x(x_), y(y_) {}
P operator-(P p) const { return P(x - p.x, y - p.y); }
double dot(P p) const { return x * p.x + y * p.y; }
double cross(P p) const { return x * p.y - y * p.x; }
double cross(P a, P b) const { return (a - *this).cross(b - *this); }
};
template<class P> bool onSegment(P s, P e, P p) {
return abs(p.cross(s, e)) < 1e-9 && (s - p).dot(e - p) <= 0;
}
bool InPolygon(vector<P>& p, P a) {
int n = p.size();
int cnt = 0;
for (int i = 0; i < n; i++) {
P q = p[(i + 1) % n];
if (onSegment(p[i], q, a)) return true;
cnt ^= ((a.y < p[i].y) - (a.y < q.y)) * a.cross(p[i], q) > 0;
}
return cnt;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
vector<vector<P>> sets(n);
for (auto& v : sets) {
int k;
cin >> k;
v.resize(k);
for (P& p : v) {
cin >> p.x >> p.y;
}
}
vector<int> x1(m), y1(m), z1(m), x2(m), y2(m), z2(m);
for (int i = 0; i < m; i++) {
cin >> x1[i] >> y1[i] >> z1[i];
cin >> x2[i] >> y2[i] >> z2[i];
}
const double pi = acosl(-1);
auto Works = [&](double theta) -> bool {
vector<int> ok(n, false);
for (int i = 0; i < m; i++) {
double dx = x2[i] - x1[i];
double dy = y2[i] - y1[i];
double norm = hypot(dx, dy);
dx /= norm;
dy /= norm;
double len1 = z1[i] * tan(theta / 180 * pi);
P p1r(x1[i] + dy * len1, y1[i] - dx * len1);
P p1l(x1[i] - dy * len1, y1[i] + dx * len1);
double len2 = z2[i] * tan(theta / 180 * pi);
P p2r(x2[i] + dy * len2, y2[i] - dx * len2);
P p2l(x2[i] - dy * len2, y2[i] + dx * len2);
vector<P> quad = {p1l, p1r, p2r, p2l};
for (int j = 0; j < n; j++) {
bool all = [&] {
for (P& p : sets[j]) {
if (!InPolygon(quad, p)) {
return false;
}
}
return true;
}();
if (all) {
ok[j] = true;
}
}
}
return ranges::count(ok, true) == n;
};
double low = 0.0, high = 90.0 - 1e-7;
for (int it = 0; it < 100; it++) {
double mid = (low + high) / 2;
if (Works(mid)) {
high = mid;
} else {
low = mid;
}
}
if (low > 90.0 - 1e-6) {
cout << "impossible\n";
} else {
cout.precision(10);
cout << fixed;
cout << low << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4112kb
input:
1 1 3 -5 0 5 0 0 5 -10 10 10 10 10 10
output:
44.9999999999
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 4228kb
input:
1 1 3 -5 0 5 0 0 5 -10 0 10 10 0 10
output:
26.5650511768
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 4156kb
input:
1 1 3 -5 0 5 0 0 5 0 10 10 10 0 10
output:
46.6861433415
result:
ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 4092kb
input:
1 1 3 -5 0 5 0 0 5 0 10 5 10 0 10
output:
59.4910411336
result:
ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 4164kb
input:
1 1 3 -5 0 5 0 0 5 0 10 20 -10 0 10
output:
31.2196984472
result:
ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 4052kb
input:
1 3 3 -5 0 5 0 0 5 -10 0 25 10 0 20 -5 10 10 10 -5 20 -4 1 100 5 10 100
output:
12.5288077090
result:
ok
Test #7:
score: 0
Accepted
time: 0ms
memory: 4164kb
input:
1 2 4 0 0 20 0 20 40 0 40 -10 30 30 30 30 30 -10 10 30 30 10 30
output:
45.0000000000
result:
ok
Test #8:
score: 0
Accepted
time: 0ms
memory: 4136kb
input:
1 4 4 0 0 20 0 20 40 0 40 -10 30 30 30 30 30 -10 20 30 30 20 30 -10 10 30 30 10 30 10 -10 30 10 50 30
output:
18.4349488229
result:
ok
Test #9:
score: 0
Accepted
time: 3ms
memory: 4364kb
input:
1 2 4 0 0 40 0 40 40 0 40 10 10 10 20 20 20 30 10 10 10 30 20
output:
impossible
result:
ok
Test #10:
score: 0
Accepted
time: 10ms
memory: 4156kb
input:
1 3 4 0 0 20 0 20 40 0 40 -10 30 30 15 30 30 5 30 30 30 30 30 1 50 30 21 50 30
output:
impossible
result:
ok
Test #11:
score: 0
Accepted
time: 0ms
memory: 4200kb
input:
1 1 4 0 0 40 0 40 40 0 40 -100 -100 20 100 100 10
output:
63.6657521531
result:
ok
Test #12:
score: 0
Accepted
time: 0ms
memory: 4124kb
input:
1 4 4 -10 -10 10 -10 10 10 -10 10 -100 0 10 100 0 10 0 100 10 0 -100 10 50 50 15 -50 -50 15 -50 50 15 50 -50 15
output:
43.3138566583
result:
ok
Test #13:
score: 0
Accepted
time: 2ms
memory: 4280kb
input:
1 100 100 822286 0 856789 53904 986567 124632 629039 119995 732157 187986 691605 224716 728650 288493 591087 278144 801573 440668 425257 269876 614456 446428 424157 350893 645680 606334 406524 432904 545628 659551 359831 495265 367048 578376 251435 457360 319990 680014 336526 849968 214009 658652 23...
output:
53.7906384311
result:
ok
Test #14:
score: 0
Accepted
time: 18ms
memory: 4320kb
input:
100 1 100 461002 481444 460618 481480 460584 481512 460833 481595 460670 481605 460545 481607 460942 481801 460526 481672 460912 481923 460765 481903 460505 481781 460430 481766 460589 481959 460593 482032 460477 481972 460440 481994 460510 482183 460285 481888 460387 482179 460246 481963 460303 482...
output:
impossible
result:
ok
Test #15:
score: 0
Accepted
time: 19ms
memory: 4352kb
input:
100 1 100 461002 481444 460618 481480 460584 481512 460833 481595 460670 481605 460545 481607 460942 481801 460526 481672 460912 481923 460765 481903 460505 481781 460430 481766 460589 481959 460593 482032 460477 481972 460440 481994 460510 482183 460285 481888 460387 482179 460246 481963 460303 482...
output:
33.6907956097
result:
ok
Test #16:
score: 0
Accepted
time: 19ms
memory: 4360kb
input:
100 1 100 461002 481444 460618 481480 460584 481512 460833 481595 460670 481605 460545 481607 460942 481801 460526 481672 460912 481923 460765 481903 460505 481781 460430 481766 460589 481959 460593 482032 460477 481972 460440 481994 460510 482183 460285 481888 460387 482179 460246 481963 460303 482...
output:
66.4027966421
result:
ok
Test #17:
score: 0
Accepted
time: 91ms
memory: 4324kb
input:
100 100 100 461002 481444 460618 481480 460584 481512 460833 481595 460670 481605 460545 481607 460942 481801 460526 481672 460912 481923 460765 481903 460505 481781 460430 481766 460589 481959 460593 482032 460477 481972 460440 481994 460510 482183 460285 481888 460387 482179 460246 481963 460303 4...
output:
4.1890016471
result:
ok
Test #18:
score: 0
Accepted
time: 75ms
memory: 4320kb
input:
100 11 100 461002 481444 460618 481480 460584 481512 460833 481595 460670 481605 460545 481607 460942 481801 460526 481672 460912 481923 460765 481903 460505 481781 460430 481766 460589 481959 460593 482032 460477 481972 460440 481994 460510 482183 460285 481888 460387 482179 460246 481963 460303 48...
output:
32.4119284772
result:
ok
Test #19:
score: 0
Accepted
time: 96ms
memory: 4324kb
input:
100 90 100 461002 481444 460618 481480 460584 481512 460833 481595 460670 481605 460545 481607 460942 481801 460526 481672 460912 481923 460765 481903 460505 481781 460430 481766 460589 481959 460593 482032 460477 481972 460440 481994 460510 482183 460285 481888 460387 482179 460246 481963 460303 48...
output:
5.5754489360
result:
ok
Extra Test:
score: 0
Extra Test Passed