QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#353669 | #6426. Interested in Skiing | PorNPtree | WA | 0ms | 3948kb | C++14 | 2.3kb | 2024-03-14 14:45:10 | 2024-03-14 14:45:11 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, a[N], b[N], c[N], d[N];
pair<int, int> pr[N * 2];
double f[N * 2];
mt19937 rnd;
int ins(double a, double b, double c, double d, double e, double f, double g, double h)
{
a += (double)rnd() / 1e15, b += (double)rnd() / 1e15, c += (double)rnd() / 1e15, d += (double)rnd() / 1e15;
e += (double)rnd() / 1e15, f += (double)rnd() / 1e15, g += (double)rnd() / 1e15, h += (double)rnd() / 1e15;
double k1 = (d - b) / (c - a), b1 = b - k1 * a;
double k2 = (h - f) / (g - e), b2 = f - k2 * e;
double ix = (b2 - b1) / (k1 - k2), iy = k1 * ix + b1;
return ix > min(a, c) - 1e-5 && ix < max(a, c) + 1e-5 && ix > min(e, g) - 1e-5 && ix < max(e, g) + 1e-5 && iy > min(b, d) - 1e-5 && iy < max(b, d) + 1e-5 && iy > min(f, h) - 1e-5 && iy < max(f, h) + 1e-5 && fabs(ix - a) + fabs(iy - b) > 1e-5 && fabs(ix - c) + fabs(iy - d) > 1e-5 && fabs(ix - e) + fabs(iy - f) > 1e-5 && fabs(ix - g) + fabs(iy - h) > 1e-5;
}
int check(double a, double b, double c, double d)
{
for (int i = 1; i <= n; ++i) {
if (ins(a, b, c, d, ::a[i], ::b[i], ::c[i], ::d[i])) {
return 0;
}
}
return 1;
}
signed main()
{
int m, V;
scanf("%d%d%d", &n, &m, &V);
for (int i = 1; i <= n; ++i) {
scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
pr[i * 2 - 1] = make_pair(b[i], a[i]);
pr[i * 2] = make_pair(d[i], c[i]);
}
sort(pr + 1, pr + n + n + 1);
double res = 1e10;
for (int i = 1; i <= n + n; ++i) {
f[i] = 1e10;
if (pr[i].second <= -m || pr[i].second >= m) {
continue;
}
if (check(pr[i].second, -20000, pr[i].second, pr[i].first)) {
f[i] = 0;
} else {
for (int j = 1; j < i; ++j) {
if (pr[i].first != pr[j].first && check(pr[j].second, pr[j].first, pr[i].second, pr[i].first)) {
f[i] = min(f[i], max(f[j], fabs((double)(pr[i].second - pr[j].second) / (pr[i].first - pr[j].first))));
}
}
}
if (check(pr[i].second, pr[i].first, pr[i].second, 20000)) {
res = min(res, f[i]);
}
}
if (res > 5e9) {
puts("-1");
} else {
printf("%.10lf\n", res * V);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3948kb
input:
3 2 1 -2 0 1 0 -1 4 2 4 0 1 0 3
output:
1.0000000000
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
2 1 2 -1 0 1 0 1 1 0 1
output:
-1
result:
ok found '-1.0000000', expected '-1.0000000', error '-0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
2 3 7 -3 0 2 2 3 1 -2 17
output:
1.8666666667
result:
ok found '1.8666667', expected '1.8666667', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
1 100 1 -100 0 99 0
output:
0.0000000000
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3944kb
input:
3 8 3 -8 -9 0 -9 -6 -6 6 6 8 9 0 9
output:
6.0000000000
result:
ok found '6.0000000', expected '6.0000000', error '0.0000000'
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3880kb
input:
3 8 3 -8 9 0 9 -6 6 6 -6 8 -9 0 -9
output:
0.0000000000
result:
wrong answer 1st numbers differ - expected: '6.0000000', found: '0.0000000', error = '1.0000000'