結果

問題 No.1366 交換門松列・梅
ユーザー kokatsukokatsu
提出日時 2023-04-12 23:02:35
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 1,171 bytes
コンパイル時間 6,384 ms
コンパイル使用メモリ 153,160 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-17 08:30:18
合計ジャッジ時間 1,284 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 0 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

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