結果
問題 | No.2628 Shrinkage |
ユーザー | naut3 |
提出日時 | 2024-02-16 21:52:40 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,760 bytes |
コンパイル時間 | 11,394 ms |
コンパイル使用メモリ | 405,068 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-09-28 20:07:36 |
合計ジャッジ時間 | 11,996 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
コンパイルメッセージ
warning: unused variable: `cx` --> src/main.rs:88:13 | 88 | let cx = (b1 * c2 - b2 * c1) as f64 / d as f64; | ^^ help: if this is intentional, prefix it with an underscore: `_cx` | = note: `#[warn(unused_variables)]` on by default warning: unused variable: `cy` --> src/main.rs:89:13 | 89 | let cy = (a2 * c1 - a1 * c2) as f64 / d as f64; | ^^ help: if this is intentional, prefix it with an underscore: `_cy`
ソースコード
#![allow(non_snake_case, unused_imports, unused_must_use)] use std::io::{self, prelude::*, BufWriter, StdinLock, StdoutLock}; use std::str; fn main() { let (stdin, stdout) = (io::stdin(), io::stdout()); let mut scan = Scanner::new(stdin.lock()); let mut out = io::BufWriter::new(stdout.lock()); macro_rules! input { ($T: ty) => { scan.token::<$T>() }; ($T: ty, $N: expr) => { (0..$N).map(|_| scan.token::<$T>()).collect::<Vec<_>>() }; } let t = input!(usize); for _ in 0..t { solve(&mut scan, &mut out); } } fn solve(scan: &mut Scanner<StdinLock>, out: &mut BufWriter<StdoutLock>) { macro_rules! input { ($T: ty) => { scan.token::<$T>() }; ($T: ty, $N: expr) => { (0..$N).map(|_| scan.token::<$T>()).collect::<Vec<_>>() }; } let (x1, y1, x2, y2, X1, Y1, X2, Y2) = ( input!(i128), input!(i128), input!(i128), input!(i128), input!(i128), input!(i128), input!(i128), input!(i128), ); // (x1, y1), (X1, Y1) を通る直線の方程式と (x2, y2), (X2, Y2) を通る直線の方程式を求める // (x1 < X1 < cx) or (cx < x1 < X1) みたいな位置関係でないなら一致できない? let is_parallel = { let a1 = Y1 - y1; let b1 = x1 - X1; let a2 = Y2 - y2; let b2 = x2 - X2; a1 * b2 - a2 * b1 == 0 }; if is_parallel { if (x1 < X1 && X1 < X2 && X2 < x2) || (x2 < X2 && X2 < X1 && X1 < x1) { if (y1 < Y1 && Y1 < Y2 && Y2 < y2) || (y2 < Y2 && Y2 < Y1 && Y1 < y1) { let a1 = Y1 - y1; let b1 = x1 - X1; let a2 = Y2 - y2; let b2 = x2 - X2; let c1 = X1 * y1 - x1 * Y1; let c2 = X2 * y2 - x2 * Y2; if a1 * b2 == a2 * b1 && a1 * c2 == a2 * c1 { writeln!(out, "Yes"); return; } } } writeln!(out, "No"); return; } else { let a1 = Y1 - y1; let b1 = x1 - X1; let a2 = Y2 - y2; let b2 = x2 - X2; let c1 = X1 * y1 - x1 * Y1; let c2 = X2 * y2 - x2 * Y2; let d = a1 * b2 - a2 * b1; let cx = (b1 * c2 - b2 * c1) as f64 / d as f64; let cy = (a2 * c1 - a1 * c2) as f64 / d as f64; // cx == X1 とか cy == Y1 とかだと一致できない if (b1 * c2 - b2 * c1) == X1 * d || (b1 * c2 - b2 * c1) == X2 * d { writeln!(out, "No"); return; } if (a2 * c1 - a1 * c2) == Y1 * d || (a2 * c1 - a1 * c2) == Y2 * d { writeln!(out, "No"); return; } let e1 = b1 * c2 - b2 * c1; let e2 = a2 * c1 - a1 * c2; if d > 0 { if (e1 < X1 * d && X1 < x1) || (x1 < X1 && X1 * d < e1) { if (e1 < X2 * d && X2 < x2) || (x2 < X2 && X2 * d < e1) { if (e2 < Y1 * d && Y1 < y1) || (y1 < Y1 && Y1 * d < e2) { if (e2 < Y2 * d && Y2 < y2) || (y2 < Y2 && Y2 * d < e2) { writeln!(out, "Yes"); return; } } } } } else { if (e1 > X1 * d && X1 < x1) || (x1 < X1 && X1 * d > e1) { if (e1 > X2 * d && X2 < x2) || (x2 < X2 && X2 * d > e1) { if (e2 > Y1 * d && Y1 < y1) || (y1 < Y1 && Y1 * d > e2) { if (e2 > Y2 * d && Y2 < y2) || (y2 < Y2 && Y2 * d > e2) { writeln!(out, "Yes"); return; } } } } } writeln!(out, "No"); } } struct Scanner<R> { reader: R, buf_str: Vec<u8>, buf_iter: str::SplitWhitespace<'static>, } impl<R: BufRead> Scanner<R> { fn new(reader: R) -> Self { Self { reader, buf_str: vec![], buf_iter: "".split_whitespace(), } } fn token<T: str::FromStr>(&mut self) -> T { loop { if let Some(token) = self.buf_iter.next() { return token.parse().ok().expect("Failed parse"); } self.buf_str.clear(); self.reader .read_until(b'\n', &mut self.buf_str) .expect("Failed read"); self.buf_iter = unsafe { let slice = str::from_utf8_unchecked(&self.buf_str); std::mem::transmute(slice.split_whitespace()) } } } }