結果
| 問題 |
No.2594 Mix shake!!
|
| コンテスト | |
| ユーザー |
akakimidori
|
| 提出日時 | 2023-12-22 20:34:55 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 3,048 bytes |
| コンパイル時間 | 13,601 ms |
| コンパイル使用メモリ | 403,380 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-27 11:27:47 |
| 合計ジャッジ時間 | 16,209 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | AC * 46 RE * 39 |
コンパイルメッセージ
warning: unused import: `std::io::Write` --> src/main.rs:1:5 | 1 | 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::io::Write;
use std::collections::*;
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;
}
}
}
todo!()
}
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));
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;
}
}
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 ----------
akakimidori