結果
問題 | No.2594 Mix shake!! |
ユーザー | akakimidori |
提出日時 | 2023-12-22 23:29:30 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,229 bytes |
コンパイル時間 | 13,643 ms |
コンパイル使用メモリ | 399,936 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-27 11:32:23 |
合計ジャッジ時間 | 16,196 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,820 KB |
testcase_02 | AC | 1 ms
6,816 KB |
testcase_03 | AC | 1 ms
6,944 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 1 ms
6,940 KB |
testcase_06 | AC | 1 ms
6,940 KB |
testcase_07 | AC | 1 ms
6,940 KB |
testcase_08 | AC | 1 ms
6,944 KB |
testcase_09 | AC | 1 ms
6,940 KB |
testcase_10 | AC | 1 ms
6,944 KB |
testcase_11 | AC | 1 ms
6,944 KB |
testcase_12 | AC | 1 ms
6,944 KB |
testcase_13 | AC | 1 ms
6,940 KB |
testcase_14 | AC | 1 ms
6,940 KB |
testcase_15 | AC | 1 ms
6,944 KB |
testcase_16 | AC | 1 ms
6,940 KB |
testcase_17 | AC | 1 ms
6,940 KB |
testcase_18 | AC | 1 ms
6,940 KB |
testcase_19 | AC | 1 ms
6,944 KB |
testcase_20 | AC | 1 ms
6,940 KB |
testcase_21 | AC | 1 ms
6,940 KB |
testcase_22 | AC | 1 ms
6,944 KB |
testcase_23 | AC | 1 ms
6,944 KB |
testcase_24 | AC | 1 ms
6,940 KB |
testcase_25 | AC | 1 ms
6,940 KB |
testcase_26 | WA | - |
testcase_27 | AC | 1 ms
6,940 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | AC | 1 ms
6,944 KB |
testcase_33 | AC | 1 ms
6,940 KB |
testcase_34 | AC | 6 ms
6,940 KB |
testcase_35 | WA | - |
testcase_36 | AC | 6 ms
6,940 KB |
testcase_37 | WA | - |
testcase_38 | AC | 5 ms
6,940 KB |
testcase_39 | WA | - |
testcase_40 | AC | 6 ms
6,940 KB |
testcase_41 | WA | - |
testcase_42 | AC | 5 ms
6,944 KB |
testcase_43 | WA | - |
testcase_44 | AC | 6 ms
6,940 KB |
testcase_45 | WA | - |
testcase_46 | AC | 6 ms
6,940 KB |
testcase_47 | WA | - |
testcase_48 | AC | 6 ms
6,940 KB |
testcase_49 | WA | - |
testcase_50 | AC | 6 ms
6,940 KB |
testcase_51 | WA | - |
testcase_52 | AC | 6 ms
6,944 KB |
testcase_53 | WA | - |
testcase_54 | AC | 1 ms
6,944 KB |
testcase_55 | AC | 1 ms
6,940 KB |
testcase_56 | AC | 1 ms
6,944 KB |
testcase_57 | AC | 1 ms
6,940 KB |
testcase_58 | AC | 1 ms
6,944 KB |
testcase_59 | AC | 1 ms
6,944 KB |
testcase_60 | AC | 1 ms
6,940 KB |
testcase_61 | AC | 1 ms
6,944 KB |
testcase_62 | AC | 1 ms
6,940 KB |
testcase_63 | AC | 1 ms
6,940 KB |
testcase_64 | AC | 1 ms
6,940 KB |
testcase_65 | AC | 1 ms
6,944 KB |
testcase_66 | AC | 1 ms
6,944 KB |
testcase_67 | AC | 1 ms
6,940 KB |
testcase_68 | AC | 1 ms
6,944 KB |
testcase_69 | AC | 1 ms
6,940 KB |
testcase_70 | AC | 1 ms
6,940 KB |
testcase_71 | AC | 1 ms
6,944 KB |
testcase_72 | AC | 1 ms
6,944 KB |
testcase_73 | AC | 1 ms
6,944 KB |
testcase_74 | AC | 1 ms
6,940 KB |
testcase_75 | AC | 1 ms
6,944 KB |
testcase_76 | AC | 1 ms
6,944 KB |
testcase_77 | AC | 1 ms
6,944 KB |
testcase_78 | AC | 1 ms
6,940 KB |
testcase_79 | AC | 1 ms
6,944 KB |
testcase_80 | AC | 1 ms
6,940 KB |
testcase_81 | AC | 1 ms
6,944 KB |
testcase_82 | AC | 1 ms
6,940 KB |
testcase_83 | AC | 1 ms
6,944 KB |
testcase_84 | AC | 1 ms
6,940 KB |
testcase_85 | AC | 1 ms
6,944 KB |
testcase_86 | AC | 1 ms
6,940 KB |
testcase_87 | AC | 1 ms
6,940 KB |
コンパイルメッセージ
warning: unused import: `std::io::Write` --> src/main.rs:2:5 | 2 | use std::io::Write; | ^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: type alias `Map` is never used --> src/main.rs:4:6 | 4 | type Map<K, V> = BTreeMap<K, V>; | ^^^ | = note: `#[warn(dead_code)]` on by default warning: type alias `Set` is never used --> src/main.rs:5:6 | 5 | type Set<T> = BTreeSet<T>; | ^^^ warning: type alias `Deque` is never used --> src/main.rs:6:6 | 6 | type Deque<T> = VecDeque<T>; | ^^^^^
ソースコード
use std::collections::*; use std::io::Write; type Map<K, V> = BTreeMap<K, V>; type Set<T> = BTreeSet<T>; type Deque<T> = VecDeque<T>; fn main() { input! { n: usize, a: [i128; n], b: [i128; n], c: [i128; n], d: [i128; n], } let ans = if solve(a, b, c, d) { "Yes" } else { "No" }; println!("{}", ans); } fn solve(a: Vec<i128>, b: Vec<i128>, c: Vec<i128>, d: Vec<i128>) -> bool { let p = a.into_iter().zip(b).collect::<Vec<_>>(); let q = c.into_iter().zip(d).collect::<Vec<_>>(); if !yokohama(p.clone(), q.clone()) { return false; } for i in 0..p.len() { for j in 0..i { let mut p = p.clone(); let v = p.remove(i); p[j].0 += v.0; p[j].1 += v.1; if yokohama(p.clone(), q.clone()) { return true; } } } let mut ord = (0..p.len()).collect::<Vec<_>>(); ord.sort_by(|a, b| { let x = q[*a]; let y = q[*b]; let z = p[*a]; let w = p[*b]; (x.0 * y.1 - x.1 * y.0) .cmp(&0) .then((z.0 * w.1 - z.1 * w.0).cmp(&0)) }); let mut s = ord.iter().map(|x| p[*x]).collect::<Vec<_>>(); let mut t = ord.iter().map(|x| q[*x]).collect::<Vec<_>>(); if valid(s.clone(), t.clone()) { return true; } while t.len() > 0 { let a = s[0]; let b = t[0]; if a.0 * b.1 == a.1 * b.0 { if a.0 < b.0 { return false; } if 1 < s.len() { s[1].0 += a.0 - b.0; s[1].1 += a.1 - b.1; } } else if let Some(x) = (1..s.len()).max_by(|x, y| { let a = s[*x]; let b = s[*y]; (a.0 * b.1 - a.1 * b.0).cmp(&0) }) { let c = s[x]; if b.0 * a.1 > b.1 * a.0 { s[x].0 = a.0 + c.0 - b.0; s[x].1 = a.1 + c.1 - b.1; } else { let d = (a.0 + c.0, a.1 + c.1); if b.0 * d.1 >= b.1 * d.0 { return true; } else { return false; } } } else { return false; } s.remove(0); t.remove(0); } true } fn yokohama(mut p: Vec<(i128, i128)>, mut q: Vec<(i128, i128)>) -> bool { p.sort_by(|a, b| (a.0 * b.1 - a.1 * b.0).cmp(&0)); q.sort_by(|a, b| (a.0 * b.1 - a.1 * b.0).cmp(&0)); valid(p, q) } fn valid(p: Vec<(i128, i128)>, q: Vec<(i128, i128)>) -> bool { { let mut p = p.clone(); p.insert(0, (0, 0)); for i in 1..p.len() { p[i].0 += p[i - 1].0; p[i].1 += p[i - 1].1; } let mut x = 0; let mut y = 0; let mut pos = 0; for q in q.iter() { x += q.0; y += q.1; while x > p[pos + 1].0 { pos += 1; } let s = p[pos]; let t = p[pos + 1]; if (y - s.1) * (t.0 - s.0) > (t.1 - s.1) * (x - s.0) { return false; } } } { let mut q = q.clone(); q.insert(0, (0, 0)); for i in 1..q.len() { q[i].0 += q[i - 1].0; q[i].1 += q[i - 1].1; } let mut x = 0; let mut y = 0; let mut pos = 0; for p in p.iter() { x += p.0; y += p.1; while x > q[pos + 1].0 { pos += 1; } let s = q[pos]; let t = q[pos + 1]; if (y - s.1) * (t.0 - s.0) < (t.1 - s.1) * (x - s.0) { return false; } } } true } // ---------- begin input macro ---------- // reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 #[macro_export] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s }; let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } #[macro_export] macro_rules! input_inner { ($iter:expr) => {}; ($iter:expr, ) => {}; ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } #[macro_export] macro_rules! read_value { ($iter:expr, ( $($t:tt),* )) => { ( $(read_value!($iter, $t)),* ) }; ($iter:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>() }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::<Vec<char>>() }; ($iter:expr, bytes) => { read_value!($iter, String).bytes().collect::<Vec<u8>>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } // ---------- end input macro ----------