QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#387302 | #5106. Islands from the Sky | ucup-team1209# | AC ✓ | 3ms | 4484kb | C++20 | 2.2kb | 2024-04-12 12:30:18 | 2024-04-12 12:30:18 |
Judging History
answer
#include<bits/stdc++.h>
using std::cin;
using std::cout;
using ll = long long;
using u64 = unsigned long long;
using db = double;
const int mod = 998244353;
const int N = 1000005;
const db eps = 1e-9;
using pr = std::pair<int, int>;
struct p2 {
db x, y;
db abs() {
return std::sqrt(x * x + y * y);
}
};
p2 r90(p2 x) {
return {-x.y, x.x};
}
p2 operator + (p2 x, p2 y) { return {x.x + y.x, x.y + y.y}; }
p2 operator - (p2 x, p2 y) { return {x.x - y.x, x.y - y.y}; }
p2 operator * (db y, p2 x) { return {x.x * y, x.y * y}; }
db operator * (p2 x, p2 y) {
return x.x * y.y - x.y * y.x;
}
std::vector<std::vector<p2>> is;
struct plane {
p2 a; db h1;
p2 b; db h2;
};
std::vector<plane> pl;
bool check(db th, std::vector<p2> & a) {
for(plane p : pl) {
p2 r = r90(p.b - p.a);
db rr = r.abs();
r.x /= rr;
r.y /= rr;
p2 x[4] = {
p.a + p.h1 * th * r,
p.b + p.h2 * th * r,
p.b - p.h2 * th * r,
p.a - p.h1 * th * r,
};
if((x[1] - x[0]) * (x[2] - x[0]) < 0) {
std::reverse(x + 1, x + 4);
}
auto valid = [&](const p2 & x, const p2 & y, const p2 & z) {
return (y - x) * (z - x) >= 0;
};
int ok = 1;
for(const auto & o : a) {
if(!valid(x[0], x[1], o)) {
ok = 0;
break;
}
if(!valid(x[1], x[2], o)) {
ok = 0;
break;
}
if(!valid(x[2], x[3], o)) {
ok = 0;
break;
}
if(!valid(x[3], x[0], o)) {
ok = 0;
break;
}
}
if(ok) return true;
}
return false;
}
int main() {
std::ios::sync_with_stdio(false), cin.tie(0);
int n, m; cin >> n >> m;
is.resize(n);
for(auto & x : is) {
int m; cin >> m;
x.resize(m);
for(auto & [x, y] : x) {
cin >> x >> y;
}
}
std::mt19937 gen;
shuffle(is.begin(), is.end(), gen);
pl.resize(m);
for(auto & x : pl) {
cin >> x.a.x >> x.a.y >> x.h1;
cin >> x.b.x >> x.b.y >> x.h2;
}
db ans = 0;
for(auto x : is) {
if(check(ans + eps, x)) {
continue;
}
db l = ans, r = 1e7;
for(int i = 0;i < 55;++i) {
db mid = (l + r) / 2;
if(check(mid, x)) {
r = mid;
} else {
l = mid;
}
}
ans = l;
}
if(ans >= 5e6) {
cout << "impossible" << '\n';
} else {
printf("%.10lf\n", atan(ans) * 180 / acos(-1));
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4252kb
input:
1 1 3 -5 0 5 0 0 5 -10 10 10 10 10 10
output:
44.9999999929
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 4288kb
input:
1 1 3 -5 0 5 0 0 5 -10 0 10 10 0 10
output:
26.5650511650
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 4220kb
input:
1 1 3 -5 0 5 0 0 5 0 10 10 10 0 10
output:
46.6861433379
result:
ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 4248kb
input:
1 1 3 -5 0 5 0 0 5 0 10 5 10 0 10
output:
59.4910411312
result:
ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 4264kb
input:
1 1 3 -5 0 5 0 0 5 0 10 20 -10 0 10
output:
31.2196984456
result:
ok
Test #6:
score: 0
Accepted
time: 1ms
memory: 4280kb
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.5288076977
result:
ok
Test #7:
score: 0
Accepted
time: 0ms
memory: 4324kb
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.9999999929
result:
ok
Test #8:
score: 0
Accepted
time: 0ms
memory: 4188kb
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.4349488139
result:
ok
Test #9:
score: 0
Accepted
time: 0ms
memory: 3748kb
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: 0ms
memory: 3808kb
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: 4252kb
input:
1 1 4 0 0 40 0 40 40 0 40 -100 -100 20 100 100 10
output:
63.6657521526
result:
ok
Test #12:
score: 0
Accepted
time: 0ms
memory: 4192kb
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.3138566526
result:
ok
Test #13:
score: 0
Accepted
time: 1ms
memory: 4328kb
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.7906384303
result:
ok
Test #14:
score: 0
Accepted
time: 3ms
memory: 4032kb
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: 3ms
memory: 4456kb
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.6907956081
result:
ok
Test #16:
score: 0
Accepted
time: 3ms
memory: 4348kb
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.4027966412
result:
ok
Test #17:
score: 0
Accepted
time: 0ms
memory: 4484kb
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.1890016363
result:
ok
Test #18:
score: 0
Accepted
time: 3ms
memory: 4416kb
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.4119284733
result:
ok
Test #19:
score: 0
Accepted
time: 3ms
memory: 4452kb
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.5754489212
result:
ok
Extra Test:
score: 0
Extra Test Passed