結果

問題 No.1366 交換門松列・梅
コンテスト
ユーザー phspls
提出日時 2022-11-20 19:50:30
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 0 ms / 1,000 ms
+ 638µs
コード長 835 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,508 ms
コンパイル使用メモリ 191,316 KB
実行使用メモリ 9,348 KB
最終ジャッジ日時 2026-07-12 13:07:02
合計ジャッジ時間 1,990 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use std::mem::swap;


fn is_kadomatsu(a: &Vec<isize>) -> bool {
    a[0] != a[1] && a[1] != a[2] && a[2] != a[0]
    && (*a.iter().max().unwrap() == a[1] || *a.iter().min().unwrap() == a[1])
}

fn main() {
    let mut a = String::new();
    std::io::stdin().read_line(&mut a).ok();
    let mut a: Vec<isize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let mut b = String::new();
    std::io::stdin().read_line(&mut b).ok();
    let mut b: Vec<isize> = b.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();

    for i in 0..3 {
        for j in 0..3 {
            swap(&mut a[i], &mut b[j]);
            if is_kadomatsu(&a) && is_kadomatsu(&b) {
                println!("Yes");
                return;
            }
            swap(&mut a[i], &mut b[j]);
        }
    }
    println!("No");
}
0