結果
問題 | No.675 ドットちゃんたち |
ユーザー | koba-e964 |
提出日時 | 2022-01-04 20:01:20 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,882 bytes |
コンパイル時間 | 13,044 ms |
コンパイル使用メモリ | 378,772 KB |
実行使用メモリ | 8,192 KB |
最終ジャッジ日時 | 2024-10-14 15:52:48 |
合計ジャッジ時間 | 14,275 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | AC | 0 ms
5,248 KB |
testcase_04 | AC | 1 ms
5,248 KB |
testcase_05 | AC | 128 ms
8,192 KB |
testcase_06 | AC | 137 ms
8,192 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
ソースコード
#[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; use std::io::Read; #[allow(dead_code)] fn getline() -> String { let mut ret = String::new(); std::io::stdin().read_line(&mut ret).ok().unwrap(); ret } fn get_word() -> String { let stdin = std::io::stdin(); let mut stdin=stdin.lock(); let mut u8b: [u8; 1] = [0]; loop { let mut buf: Vec<u8> = Vec::with_capacity(16); loop { let res = stdin.read(&mut u8b); if res.unwrap_or(0) == 0 || u8b[0] <= b' ' { break; } else { buf.push(u8b[0]); } } if buf.len() >= 1 { let ret = String::from_utf8(buf).unwrap(); return ret; } } } #[allow(dead_code)] fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() } /// Complex numbers. /// Verified by: ATC001-C (http://atc001.contest.atcoder.jp/submissions/1175487) mod complex { use std::ops::{Add, Sub, Mul}; #[derive(Clone, Copy, Debug)] pub struct Complex<T = f64> { pub x: T, pub y: T, } impl<T> Complex<T> { pub fn new(x: T, y: T) -> Self { Complex { x: x, y: y } } } impl<T> Add for Complex<T> where T: Add<Output = T> { type Output = Self; fn add(self, other: Self) -> Self { Self::new(self.x + other.x, self.y + other.y) } } impl<T> Sub for Complex<T> where T: Sub<Output = T> { type Output = Self; fn sub(self, other: Self) -> Self { Self::new(self.x - other.x, self.y - other.y) } } impl<T: Copy> Mul for Complex<T> where T: Add<Output = T> + Sub<Output = T> + Mul<Output = T> { type Output = Self; fn mul(self, other: Self) -> Self { Self::new(self.x * other.x - self.y * other.y, self.x * other.y + self.y * other.x) } } } // complex type Comp = complex::Complex<i64>; fn main() { let n: usize = get(); let px: i64 = get(); let py: i64 = get(); let mut dat = vec![]; for _ in 0..n { let ty: i32 = get(); let mut me = (Comp::new(1, 0), Comp::new(0, 0)); if ty != 3 { let d: i64 = get(); if ty == 1 { me.1.x = d; } else { me.1.y = d; } } else { me.0 = Comp::new(0, 1); } dat.push(me); } let mut acc = vec![(Comp::new(1, 0), Comp::new(0, 0)); n + 1]; for i in (0..n).rev() { let (x, y) = acc[i + 1]; let (z, w) = dat[i]; acc[i] = (z * x, w * x + y); } for i in 0..n { let (x, y) = acc[i]; let p = Comp::new(px, py) * x + y; println!("{} {}", p.x, p.y); } }