結果

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

ソースコード

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