結果

問題 No.1366 交換門松列・梅
ユーザー kokatsu
提出日時 2023-04-12 23:02:35
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 1,171 bytes
コンパイル時間 17,900 ms
コンパイル使用メモリ 377,220 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-06-20 11:09:31
合計ジャッジ時間 14,585 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::{stdout, Write, BufWriter};

fn check(x: Vec<i64>) -> bool {
    if x[0] > x[1] && x[2] > x[1] && x[0] != x[2] {
        return true;
    }
    if x[0] < x[1] && x[2] < x[1] && x[0] != x[2] {
        return true;
    }
    false
}

fn main() {
    let mut a: Vec<i64> = read_vec();
    let mut b: Vec<i64> = read_vec();

    let mut is_ok: bool = false;
    for i in 0..3 {
        for j in 0..3 {
            std::mem::swap(&mut a[i], &mut b[j]);
            is_ok |= check(a.clone()) && check(b.clone());
            std::mem::swap(&mut a[i], &mut b[j]);
        }
    }

    let res: &str = if is_ok {"Yes"} else {"No"};

    let mut out = BufWriter::new(stdout().lock());
    writeln!(out, "{}", res).unwrap();
}

#[allow(dead_code)]
fn read_string() -> String {
    let mut s: String = String::new();
    std::io::stdin().read_line(&mut s).ok();

    s.trim().to_string()
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    read_string().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read_string()
        .split_whitespace()
        .map(|v| v.parse().ok().unwrap())
        .collect()
}
0