QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#134432 | #2290. Kinking Cables | Yarema# | WA | 1ms | 3708kb | C++17 | 2.2kb | 2023-08-03 19:33:55 | 2023-08-03 19:33:57 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FILL(a, b) memset(a, b, sizeof(a))
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
const int INF = 1e9 + 7;
const double EPS = 1e-6;
struct point
{
double x, y;
point() {}
point(double a, double b): x(a), y(b) {};
point operator +(const point& p) const
{
return point(x + p.x, y + p.y);
}
point operator -(const point& p) const
{
return point(x - p.x, y - p.y);
}
point operator *(double d) const
{
return point(x * d, y * d);
}
double d2()
{
return sqrt(x * x + y * y);
}
};
double dis(point a, point b)
{
a = a - b;
return a.d2();
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
double l;
cin >> l;
vector<point> ans;
int j = 0;
point a(0, 0);
ans.PB(a);
point b(n, 0);
point c(0, 1);
point d(n, m);
while (dis(a, b) + dis(b, c) + dis(c, d) < l)
{
ans.PB(b);
ans.PB(c);
a.y += 1;
b.y += 1;
c.y += 1;
l -= dis(a, b) + dis(b, c);
j++;
}
assert(l + EPS > dis(a, d));
if (l < m + (n - a.y))
{
double L = 0, R = 1;
b = point(n / 2., (m + j) / 2.);
c = point(0, m);
point v = b - c;
FOR (i, 0, 100)
{
double M = (L + R) / 2;
point v2 = v * M;
point e = c + v2;
double ds = dis(a, e) + dis(e, d);
if (ds < l)
R = M;
else
L = M;
}
ans.PB(c + v * L);
ans.PB(d);
}
else
{
b = point(n / 2., a.y);
ans.PB(b);
l -= n / 2.;
c = point(0, m);
point v = d - c;
double L = 0, R = 1;
FOR (i, 0, 100)
{
double M = (L + R) / 2;
point v2 = v * M;
point e = c + v2;
double ds = dis(b, e) + dis(e, d);
if (ds < l)
R = M;
else
L = M;
}
ans.PB(c + v * L);
ans.PB(d);
}
cout << fixed << setprecision(7) << SZ(ans) << '\n';
for (auto p : ans)
cout << p.x << ' ' << p.y << '\n';
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3708kb
input:
79 78 1980.7712136406
output:
26 0.0000000 0.0000000 79.0000000 0.0000000 0.0000000 1.0000000 79.0000000 1.0000000 0.0000000 2.0000000 79.0000000 2.0000000 0.0000000 3.0000000 79.0000000 3.0000000 0.0000000 4.0000000 79.0000000 4.0000000 0.0000000 5.0000000 79.0000000 5.0000000 0.0000000 6.0000000 79.0000000 6.0000000 0.0000000 ...
result:
wrong answer Output path has length 1934.346542063, should have length 1980.771213641