結果
| 問題 |
No.764 浮動点
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-12-12 16:12:25 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,450 bytes |
| コンパイル時間 | 2,636 ms |
| コンパイル使用メモリ | 155,812 KB |
| 実行使用メモリ | 9,376 KB |
| 最終ジャッジ日時 | 2024-06-13 02:13:36 |
| 合計ジャッジ時間 | 8,131 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | TLE * 2 -- * 21 |
ソースコード
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}
void main()
{
int n; readV(n);
real[] l; readC(n+2, l);
auto l0 = l[0], lc = l.cumulativeSum;
auto ll = new real[](n+2), lr = new real[](n+2);
ll[1] = l[1];
foreach (i; 2..n+2) ll[i] = max(ll[i-1], l[i]);
lr[n+1] = l[n+1];
foreach_reverse (i; 1..n+1) lr[i] = max(lr[i+1], l[i]);
writeln(0);
foreach (i; 2..n) {
auto a = lc[1..i+1], b = max(2*ll[i]-a, 0);
auto c = lc[i+1..$], d = max(2*lr[i+1]-c, 0);
real f(real x)
{
auto ay = 0.0L, by = 0.0L, cy = 0.0L, dy = 0.0L;
if (-a < x && x < a) ay = sqrt(a^^2-x^^2);
if (-b < x && x < b) by = sqrt(b^^2-x^^2);
if (l0-c < x && x < l0+c) cy = sqrt(c^^2-(x-l0)^^2);
if (l0-d < x && x < l0+d) dy = sqrt(d^^2-(x-l0)^^2);
return max(0.0L, min(ay, cy)-max(by, dy));
}
writefln("%.7f", integrate!real((x) => f(x), -a, l0+c)*2);
}
writeln(0);
}
class CumulativeSum(T)
{
size_t n;
T[] s;
this(T[] a)
{
n = a.length;
s = new T[](n+1);
s[0] = T(0);
foreach (i; 0..n) s[i+1] = s[i] + a[i];
}
T opSlice(size_t l, size_t r) { return s[r]-s[l]; }
size_t opDollar() { return n; }
}
auto cumulativeSum(T)(T[] a) { return new CumulativeSum!T(a); }
real integrate(T)(T delegate(T) f, T lo, T hi, T eps = 1e-8)
{
import std.math;
const auto th = eps / 1e-14;
T rec(T x0, T x6, T y0, T y6, int d)
{
const auto a = sqrt(2.0/3.0), b = 1.0 / sqrt(5.0);
auto x3 = (x0+x6)/2, y3 = f(x3), h = (x6-x0)/2;
auto x1 = x3-a*h, x2 = x3-b*h, x4 = x3+b*h, x5 = x3+a*h;
auto y1 = f(x1), y2 = f(x2), y4 = f(x4), y5 = f(x5);
auto i1 = (y0 + y6 + (y2 + y4) * 5) * (h/6);
auto i2 = ((y0 + y6) * 77 + (y1 + y5) * 432 + (y2 + y4) * 625 + y3 * 672) * (h/1470);
if (x3 + h == x3 || d > 50) return 0.0;
if (d > 4 && th + (i1 - i2) == th) return i2;
return rec(x0, x1, y0, y1, d+1) + rec(x1, x2, y1, y2, d+1) +
rec(x2, x3, y2, y3, d+1) + rec(x3, x4, y3, y4, d+1) +
rec(x4, x5, y4, y5, d+1) + rec(x5, x6, y5, y6, d+1);
}
return rec(lo, hi, f(lo), f(hi), 0);
}