QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#31493 | #2290. Kinking Cables | Vingying0# | WA | 3ms | 3852kb | C++17 | 2.4kb | 2022-05-08 14:42:19 | 2022-05-08 14:42:21 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
const int N = 105;
using db = long double;
int n, m;
db len;
using pdb = pair<db, db>;
vector<pdb> ans;
const db eps = 1e-9;
int dcmp(const db &x) {
return abs(x) < 1e-5?0:(x < 0?-1:1);
}
db x = 0, y = 0, lx = 0, ly = 0;
db dist(db x,db y, db _x,db _y) {
return sqrtl((x-_x)*(x-_x)+(y-_y)*(y-_y));
}
void add(db x, db y) {
::x = x, ::y = y;
ans.push_back({x, y});
len -= dist(::x, ::y, lx, ly);
lx = x, ly = y;
}
void solve()
{
add(x, y);
int f = 0;
while (len > 1e-9)
{
if (f == 0) {
if (dcmp(n + m - x - len) != -1) {
db mx = (x + m) / 2, my = (y + n) / 2;
db d = dist(mx, my, m, 0);
db vx = -(m - mx) / d, vy = my / d;
db l = 0, r = d;
db nx, ny;
while((r - l)>eps) {
db mid = (l + r) / 2;
nx = m + vx * mid, ny = vy * mid;
if (dist(nx, ny, x, y) + dist(nx, ny, m, n) > len) {
l = mid;
}
else r = mid;
}
add(nx, ny);
break;
}
else {
y = n;
add(x, y);
}
} else {
if (dcmp(sqrt(1+n*n)+dist(x+1,0,m,n) - len) != -1) {
db mx = x + 1, my = y;
db vx = 0, vy = -1;
db l = 0, r = n;
db nx, ny;
while((r - l)>eps) {
db mid = (l + r) / 2;
nx = mx + vx * mid, ny = my + vy * mid;
if (dist(nx, ny, x, y) + dist(nx, ny, m, n) < len) {
l = mid;
}
else r = mid;
}
add(nx, ny);
break;
}
else {
x++, y=0;
add(x, y);
}
}
f ^= 1;
}
add(m, n);
}
int main()
{
cout << fixed << setprecision(10);
cin >> n >> m >> len;
solve();
cout << ans.size() << "\n";
for (auto [px, py] : ans)
{
cout << px << " " << py << "\n";
}
cout.flush();
// assert(dcmp(len) == 0);
// cerr << len << endl;
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 3852kb
input:
79 78 1980.7712136406
output:
26 0.0000000000 0.0000000000 0.0000000000 79.0000000000 1.0000000000 0.0000000000 1.0000000000 79.0000000000 2.0000000000 0.0000000000 2.0000000000 79.0000000000 3.0000000000 0.0000000000 3.0000000000 79.0000000000 4.0000000000 0.0000000000 4.0000000000 79.0000000000 5.0000000000 0.0000000000 5.0000...
result:
wrong answer Double parameter [name=y_i] equals to 79, violates the range [0, 78]