QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#64024 | #5106. Islands from the Sky | Noobie_99 | AC ✓ | 1691ms | 4016kb | C++20 | 2.7kb | 2022-11-23 22:18:36 | 2022-11-23 22:18:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = double;
#define debug(x) cerr << "[" << __LINE__ << ' ' << #x << "]: " << (x) << endl
#define sz(x) ((int)(x).size())
using pt = complex<ld>;
constexpr ld EPS = 1e-9;
double cross(pt a, pt b) {return imag(conj(a) * b);}
int orientation(pt a, pt b, pt c) {
double orien = cross(b - a, c - a);
return (orien > EPS) - (orien < -EPS);
}
bool pointOnLineSegment(pt a, pt b, pt p) {
if (orientation(a, b, p) != 0) return false;
ld dist = norm(a - b);
return norm(a - p) <= dist && norm(b - p) <= dist;
}
bool lineSegmentIntersection(pt a, pt b, pt c, pt d) {
if (orientation(a, b, c) == 0 && orientation(a, b, d) == 0) return false;
return orientation(a, b, c) * orientation(a, b, d) <= 0 &&
orientation(c, d, a) * orientation(c, d, b) <= 0;
}
mt19937 rng(1983292);
bool inside(pt p, const vector<pt>& polygon) {//points unique
pt rayEnd = p + pt(1e9+rng(), 1e9+rng());
int counter = 0, n = sz(polygon);
for (int i = 0; i < n; i++) {
pt start = polygon[i], end = polygon[(i + 1) % n];
if (lineSegmentIntersection(p, rayEnd, start, end)) {
counter++;
}}
return counter & 1;
}
const ld PI = acosl(-1);
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, m;
cin >> n >> m;
vector<vector<pt>> polygons(n);
for (auto& polygon : polygons) {
int ni;
cin >> ni;
polygon.resize(ni);
for (auto& e : polygon) {
ld x, y;
cin >> x >> y;
e = {x, y};
}
}
array<ld, 6> a[m];
for (auto& [x, y, z, x2, y2, z2] : a) cin >> x >> y >> z >> x2 >> y2 >> z2;
ld l = 0, r = PI/2;
for (int k=0; k<40; k++) {
ld mid = (l+r) / 2;
vector<bool> covered(n);
ld f = tan(mid);
for (auto [x, y, z, x2, y2, z2] : a) {
pt ortho = {x2 - x, y2 - y};
ortho /= abs(ortho);
ortho = {imag(ortho), -real(ortho)};
pt s = {x, y};
pt t = {x2, y2};
vector<pt> poly = {s + ortho*f*z, s - ortho*f*z, t - ortho*f*z2, t + ortho*f*z2};
for (int i=0; i<n; i++) {
bool complete = true;
for (auto& p : polygons[i]) {
if (!inside(p, poly)) complete = false;
}
if (complete) covered[i] = true;
}
}
if (accumulate(covered.begin(), covered.end(), 0) == n) r = mid;
else l = mid;
}
if (abs(l-PI/2) < EPS) cout << "impossible\n";
else cout << setprecision(10) << fixed << l/PI*180 << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3752kb
input:
1 1 3 -5 0 5 0 0 5 -10 10 10 10 10 10
output:
45.0000000001
result:
ok
Test #2:
score: 0
Accepted
time: 2ms
memory: 3796kb
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: 2ms
memory: 3756kb
input:
1 1 3 -5 0 5 0 0 5 0 10 10 10 0 10
output:
46.6861433418
result:
ok
Test #4:
score: 0
Accepted
time: 2ms
memory: 3760kb
input:
1 1 3 -5 0 5 0 0 5 0 10 5 10 0 10
output:
59.4910411340
result:
ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
1 1 3 -5 0 5 0 0 5 0 10 20 -10 0 10
output:
31.2196984475
result:
ok
Test #6:
score: 0
Accepted
time: 2ms
memory: 3720kb
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: 2ms
memory: 3716kb
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:
44.9999999999
result:
ok
Test #8:
score: 0
Accepted
time: 2ms
memory: 3716kb
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: 3856kb
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: 3ms
memory: 3976kb
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: 2ms
memory: 3772kb
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: 2ms
memory: 3720kb
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.3138566582
result:
ok
Test #13:
score: 0
Accepted
time: 12ms
memory: 3800kb
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: 25ms
memory: 3932kb
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: 20ms
memory: 3920kb
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: 27ms
memory: 4016kb
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.4027966420
result:
ok
Test #17:
score: 0
Accepted
time: 1691ms
memory: 3928kb
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: 232ms
memory: 3960kb
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.4119284771
result:
ok
Test #19:
score: 0
Accepted
time: 1530ms
memory: 3896kb
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