QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#536892 | #5106. Islands from the Sky | RngBased# | AC ✓ | 1438ms | 4532kb | C++20 | 3.0kb | 2024-08-29 17:55:56 | 2024-08-29 17:55:58 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>
#define p3d tuple<double, double, double>
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1);
pdd operator+(pdd a, pdd b)
{
return pdd(a.F + b.F, a.S + b.S);
}
pdd operator-(pdd a)
{
return pdd(-a.F, -a.S);
}
pdd operator-(pdd a, pdd b)
{
return a + (-b);
}
pdd operator*(pdd a, double b)
{
return pdd(a.F * b, a.S * b);
}
double dot(pdd a, pdd b)
{
return a.F * b.F + a.S * b.S;
}
double cross(pdd a, pdd b)
{
return a.F * b.S - a.S * b.F;
}
int sign(double d)
{
return (fabs(d) < eps ? 0 : (d < 0 ? -1 : 1));
}
int ori(pdd a, pdd b, pdd c)
{
return sign(cross(b - a, c - a));
}
double abs2(pdd a)
{
return dot(a, a);
}
double abs(pdd a)
{
return sqrt(abs2(a));
}
int n, m, cover[105];
vector<pdd> land[105];
p3d st[105], en[105];
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++)
{
int b;
cin >> b;
land[i].resize(b);
for (auto &[x, y] : land[i])
cin >> x >> y;
}
for (int i = 1; i <= m; i++)
{
auto &[x1, y1, z1] = st[i];
cin >> x1 >> y1 >> z1;
auto &[x2, y2, z2] = en[i];
cin >> x2 >> y2 >> z2;
}
auto check = [&](double theta)
{
fill(cover + 1, cover + 1 + n, 0);
for (int i = 1; i <= m; i++)
{
double tant = tan(theta / 180.0 * pi);
auto &[x1, y1, z1] = st[i];
auto &[x2, y2, z2] = en[i];
pdd orth = pdd(y2 - y1, x1 - x2);
vector<pdd> quad;
quad.emplace_back(pdd(x1, y1) + orth * (z1 * tant / abs(orth)));
quad.emplace_back(pdd(x2, y2) + orth * (z2 * tant / abs(orth)));
quad.emplace_back(pdd(x2, y2) - orth * (z2 * tant / abs(orth)));
quad.emplace_back(pdd(x1, y1) - orth * (z1 * tant / abs(orth)));
for (int j = 1; j <= n; j++)
{
bool flag = true;
for (auto p : land[j])
{
for (int k = 0; k < 4; k++)
{
int l = (k + 1) % 4;
if (ori(quad[k], quad[l], p) == -1)
flag = false;
}
}
if (flag) cover[j] = 1;
}
}
return *min_element(cover + 1, cover + 1 + n) > 0;
};
double l = 0, r = 90 - eps;
int t = 200;
bool success = false;
while (t--)
{
double mid = (l + r) / 2;
if (check(mid))
r = mid, success = true;
else l = mid;
}
if (!success)
cout << "impossible\n";
else
cout << fixed << setprecision(10) << l << '\n';
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 4256kb
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: 1ms
memory: 4144kb
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: 1ms
memory: 4172kb
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: 4176kb
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: 4140kb
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: 1ms
memory: 4172kb
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: 4280kb
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: 1ms
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: 8ms
memory: 4236kb
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: 4ms
memory: 4140kb
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: 1ms
memory: 4276kb
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: 4088kb
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: 12ms
memory: 4216kb
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: 24ms
memory: 4532kb
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: 14ms
memory: 4372kb
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: 18ms
memory: 4344kb
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: 1438ms
memory: 4300kb
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: 161ms
memory: 4372kb
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: 1289ms
memory: 4280kb
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