結果
| 問題 |
No.2564 衝突予測
|
| コンテスト | |
| ユーザー |
Kyo_s_s
|
| 提出日時 | 2023-11-18 16:16:44 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 185 ms / 2,000 ms |
| コード長 | 4,276 bytes |
| コンパイル時間 | 14,206 ms |
| コンパイル使用メモリ | 377,516 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2024-09-26 08:05:12 |
| 合計ジャッジ時間 | 17,439 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
ソースコード
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, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}
fn main() {
input! {
t: usize,
query: [(i64, i64, char, i64, i64, char); t],
}
for i in 0..t {
let (x1, y1, d1, x2, y2, d2) = query[i];
if d1 == d2 {
println!("No");
continue;
}
let (mut x1, mut y1, mut x2, mut y2) = (x1 - x1, y1 - y1, x2 - x1, y2 - y1);
if (d1, d2) == ('R', 'L') || (d1, d2) == ('L', 'R') {
if (d1, d2) == ('L', 'R') {
// (x1, y1, x2, y2) = (x2, y2, x1, y1);
std::mem::swap(&mut x1, &mut x2);
std::mem::swap(&mut y1, &mut y2);
}
if y1 == y2 && x1 < x2 {
println!("Yes");
} else {
println!("No");
}
continue;
}
if (d1, d2) == ('U', 'D') || (d1, d2) == ('D', 'U') {
if (d1, d2) == ('D', 'U') {
// (x1, y1, x2, y2) = (x2, y2, x1, y1);
std::mem::swap(&mut x1, &mut x2);
std::mem::swap(&mut y1, &mut y2);
}
if x1 == x2 && y1 < y2 {
println!("Yes");
} else {
println!("No");
}
continue;
}
if (d1, d2) == ('U', 'R') || (d1, d2) == ('R', 'U') {
if (d1, d2) == ('R', 'U') {
// (x1, y1, x2, y2) = (x2, y2, x1, y1);
std::mem::swap(&mut x1, &mut x2);
std::mem::swap(&mut y1, &mut y2);
}
let dist1 = y2 - y1;
let dist2 = x1 - x2;
if dist1 == dist2 && dist1 > 0 {
println!("Yes");
} else {
println!("No");
}
continue;
}
if (d1, d2) == ('U', 'L') || (d1, d2) == ('L', 'U') {
if (d1, d2) == ('L', 'U') {
// (x1, y1, x2, y2) = (x2, y2, x1, y1);
std::mem::swap(&mut x1, &mut x2);
std::mem::swap(&mut y1, &mut y2);
}
let dist1 = y2 - y1;
let dist2 = x2 - x1;
if dist1 == dist2 && dist1 > 0 {
println!("Yes");
} else {
println!("No");
}
continue;
}
if (d1, d2) == ('D', 'R') || (d1, d2) == ('R', 'D') {
if (d1, d2) == ('R', 'D') {
// (x1, y1, x2, y2) = (x2, y2, x1, y1);
std::mem::swap(&mut x1, &mut x2);
std::mem::swap(&mut y1, &mut y2);
}
let dist1 = y1 - y2;
let dist2 = x1 - x2;
if dist1 == dist2 && dist1 > 0 {
println!("Yes");
} else {
println!("No");
}
continue;
}
if (d1, d2) == ('D', 'L') || (d1, d2) == ('L', 'D') {
if (d1, d2) == ('L', 'D') {
// (x1, y1, x2, y2) = (x2, y2, x1, y1);
std::mem::swap(&mut x1, &mut x2);
std::mem::swap(&mut y1, &mut y2);
}
let dist1 = y1 - y2;
let dist2 = x2 - x1;
if dist1 == dist2 && dist1 > 0 {
println!("Yes");
} else {
println!("No");
}
continue;
}
println!("No");
}
}
Kyo_s_s