結果
問題 | No.2355 Unhappy Back Dance |
ユーザー | koba-e964 |
提出日時 | 2023-06-16 23:16:27 |
言語 | Rust (1.77.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,763 bytes |
コンパイル時間 | 1,560 ms |
コンパイル使用メモリ | 156,268 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-06 22:13:09 |
合計ジャッジ時間 | 8,876 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 0 ms
4,376 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 0 ms
4,376 KB |
testcase_06 | AC | 245 ms
4,376 KB |
testcase_07 | AC | 247 ms
4,376 KB |
testcase_08 | AC | 246 ms
4,376 KB |
testcase_09 | AC | 34 ms
4,376 KB |
testcase_10 | AC | 189 ms
4,380 KB |
testcase_11 | AC | 221 ms
4,376 KB |
testcase_12 | AC | 285 ms
4,376 KB |
testcase_13 | AC | 279 ms
4,380 KB |
testcase_14 | AC | 200 ms
4,376 KB |
testcase_15 | RE | - |
testcase_16 | AC | 417 ms
4,380 KB |
testcase_17 | AC | 425 ms
4,380 KB |
testcase_18 | AC | 422 ms
4,380 KB |
testcase_19 | AC | 420 ms
4,376 KB |
testcase_20 | AC | 418 ms
4,380 KB |
testcase_21 | AC | 167 ms
4,380 KB |
testcase_22 | AC | 29 ms
4,376 KB |
testcase_23 | AC | 30 ms
4,380 KB |
testcase_24 | AC | 373 ms
4,380 KB |
testcase_25 | AC | 195 ms
4,380 KB |
testcase_26 | AC | 194 ms
4,376 KB |
testcase_27 | AC | 167 ms
4,380 KB |
testcase_28 | AC | 4 ms
4,380 KB |
testcase_29 | AC | 8 ms
4,380 KB |
testcase_30 | AC | 341 ms
4,380 KB |
testcase_31 | AC | 246 ms
4,380 KB |
testcase_32 | AC | 22 ms
4,380 KB |
testcase_33 | AC | 134 ms
4,380 KB |
testcase_34 | AC | 2 ms
4,380 KB |
testcase_35 | AC | 4 ms
4,380 KB |
testcase_36 | AC | 168 ms
4,376 KB |
testcase_37 | AC | 86 ms
4,380 KB |
testcase_38 | AC | 108 ms
4,376 KB |
testcase_39 | AC | 83 ms
4,380 KB |
ソースコード
use std::cmp::*; // 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; } } } type Coord = i128; // the type of coordinates fn half((x, y, _): (Coord, Coord, i32)) -> i32 { assert_ne!((x, y), (0, 0)); if y >= 0 { if x > 0 || y > 0 { 1 } else { 2 } } else { 2 } } // arg sort // Verified by: https://yukicoder.me/submissions/706856 fn arg_sort(xy: &mut [(Coord, Coord, i32)]) { xy.sort_unstable_by(|&a, &b| { half(a).cmp(&half(b)).then_with( || 0.cmp(&(a.0 * b.1 - a.1 * b.0)) .then_with(|| a.2.cmp(&b.2))) }); } fn main() { input! { n: usize, a: [(i128, i128); n], } let mut ans = 0; for i in 0..n { let (xi, yi) = a[i]; let mut b = vec![]; for j in 0..n { if i != j { b.push((a[j].0 - xi, a[j].1 - yi, j as i32)); } } arg_sort(&mut b); for i in 0..b.len() - 1 { let a = b[i]; let b = b[i + 1]; if half(a).cmp(&half(b)).then_with( || 0.cmp(&(a.0 * b.1 - a.1 * b.0))) == Ordering::Equal { ans += 1; break; } } } println!("{}", ans); }