結果

問題 No.138 化石のバージョン
ユーザー yo-kondoyo-kondo
提出日時 2019-05-18 18:41:57
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,349 bytes
コンパイル時間 1,095 ms
コンパイル使用メモリ 173,180 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 07:39:37
合計ジャッジ時間 1,881 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 0 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 0 ms
4,348 KB
testcase_19 AC 0 ms
4,348 KB
testcase_20 WA -
testcase_21 AC 0 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 1 ms
4,348 KB
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 1 ms
4,348 KB
testcase_30 AC 1 ms
4,348 KB
testcase_31 AC 1 ms
4,348 KB
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 1 ms
4,348 KB
testcase_34 AC 1 ms
4,348 KB
testcase_35 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::stdin;

/// エントリポイント
fn main() {
    let input = read_lines();
    println!("{}", version_check(input.0, input.1));
}

/// 標準入力から文字列を取得します。
fn read_lines() -> (String, String) {
    let mut str1 = String::new();
    stdin().read_line(&mut str1).unwrap();
    str1 = str1.trim().to_string();

    let mut str2 = String::new();
    stdin().read_line(&mut str2).unwrap();
    str2 = str2.trim().to_string();
    (str1, str2)
}

///対象のバージョンか化石のバージョンかどうかを返します。
/// ## arguments
/// * `fossil` - 化石のバージョン
/// * `target_version` - 対象のバージョン
fn version_check(fossil: String, target_version: String) -> String {
    let old_version = fossil
        .split(".")
        .collect::<Vec<&str>>()
        .iter()
        .map(|&x| x.parse().unwrap())
        .collect::<Vec<i32>>();

    let new_version = target_version
        .split(".")
        .collect::<Vec<&str>>()
        .iter()
        .map(|&x| x.parse().unwrap())
        .collect::<Vec<i32>>();

    for i in 0..(old_version.len() - 1) {
        if old_version[i] < new_version[i] {
            return "NO".to_string();
        }
        if old_version[i] > new_version[i] {
            return "YES".to_string();
        }
    }
    "YES".to_string()
}
0