結果
問題 |
No.1366 交換門松列・梅
|
ユーザー |
![]() |
提出日時 | 2021-04-08 21:10:52 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 1,043 bytes |
コンパイル時間 | 10,400 ms |
コンパイル使用メモリ | 400,264 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-06-20 11:02:11 |
合計ジャッジ時間 | 11,206 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 13 |
ソースコード
fn run<'a, I: Iterator<Item = &'a str>>(mut scanner: I) { macro_rules! scan { ([$($t:tt),*]) => ([$(scan!($t)),*]); ($t:ty) => (scanner.next().unwrap().parse::<$t>().unwrap()); } macro_rules! input { ($($($v:ident)* : $t:tt),* $(,)?) => ($(let $($v)* = scan!($t);)*); } input! { mut a: [u8, u8, u8], mut b: [u8, u8, u8], } let is_kadomatsu = |a: &[u8]| { a[0] != a[1] && a[1] != a[2] && a[2] != a[0] && (a[0] < a[1] && a[1] > a[2] || a[0] > a[1] && a[1] < a[2]) }; for i in 0..3 { for j in 0..3 { std::mem::swap(&mut a[i], &mut b[j]); if is_kadomatsu(&a) && is_kadomatsu(&b) { println!("Yes"); return; } std::mem::swap(&mut a[i], &mut b[j]); } } println!("No"); } fn main() { let ref mut buf = Vec::new(); std::io::Read::read_to_end(&mut std::io::stdin(), buf).ok(); run(std::str::from_utf8(buf).unwrap().split_whitespace()); }