結果
問題 | No.764 浮動点 |
ユーザー | koba-e964 |
提出日時 | 2023-07-26 00:32:33 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,202 bytes |
コンパイル時間 | 13,282 ms |
コンパイル使用メモリ | 400,008 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-02 17:12:11 |
合計ジャッジ時間 | 14,920 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 1 ms
5,248 KB |
testcase_03 | WA | - |
testcase_04 | AC | 12 ms
5,248 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 13 ms
5,248 KB |
testcase_09 | WA | - |
testcase_10 | AC | 14 ms
5,248 KB |
testcase_11 | WA | - |
testcase_12 | AC | 14 ms
5,248 KB |
testcase_13 | AC | 15 ms
5,248 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 15 ms
5,248 KB |
testcase_19 | AC | 15 ms
5,248 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 15 ms
5,248 KB |
testcase_23 | AC | 15 ms
5,248 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
ソースコード
#[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; use std::io::{Write, BufWriter}; // https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 macro_rules! input { ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; } macro_rules! input_inner { ($next:expr) => {}; ($next:expr,) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; } macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ($(read_value!($next, $t)),*) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, usize1) => (read_value!($next, usize) - 1); ($next:expr, [ $t:tt ]) => {{ let len = read_value!($next, usize); read_value!($next, [$t; len]) }}; ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error")); } trait Change { fn chmax(&mut self, x: Self); fn chmin(&mut self, x: Self); } impl<T: PartialOrd> Change for T { fn chmax(&mut self, x: T) { if *self < x { *self = x; } } fn chmin(&mut self, x: T) { if *self > x { *self = x; } } } // Find the area of x^2 + y^2 <= a^2, (x-l)^2 + y^2 <= b^2 fn f(a: i64, b: i64, l: i64) -> f64 { if a + b <= l { return 0.0; } let pi = std::f64::consts::PI; if a + l <= b { return pi * (a * a) as f64; } if b + l <= a { return pi * (b * b) as f64; } let x0 = (l * l + a * a - b * b) as f64 / (2 * l) as f64; let height = (a as f64 * a as f64 - x0 * x0).sqrt(); let mut ans = l as f64 * height; ans = -ans; let adeg = height.atan2(x0); ans += pi * adeg * a as f64 * a as f64; let bdeg = height.atan2(l as f64 - x0); ans += pi * bdeg * b as f64 * b as f64; ans } fn main() { let out = std::io::stdout(); let mut out = BufWriter::new(out.lock()); macro_rules! puts {($($format:tt)*) => (let _ = write!(out,$($format)*););} input! { n: usize, suml: i64, l: [i64; n + 1], } let mut lft = vec![(0, 0); n]; let mut ma = 0; let mut sum = 0; for i in 1..n + 1 { sum += l[i - 1]; ma = max(ma, l[i - 1]); lft[i - 1] = (max(0, 2 * ma - sum), sum); } let mut rgt = vec![(0, 0); n]; let mut ma = 0; let mut sum = 0; for i in (1..n + 1).rev() { sum += l[i]; ma = max(ma, l[i]); rgt[i - 1] = (max(0, 2 * ma - sum), sum); } eprintln!("{:?} {:?}", lft, rgt); for i in 0..n { let (a, b) = lft[i]; let (c, d) = rgt[i]; puts!("{}\n", f(b, d, suml) - f(a, d, suml) - f(b, c, suml) + f(a, c, suml)); } }