結果

問題 No.653 E869120 and Lucky Numbers
ユーザー phsplsphspls
提出日時 2022-12-25 14:35:39
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,244 bytes
コンパイル時間 12,514 ms
コンパイル使用メモリ 379,868 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 20:16:37
合計ジャッジ時間 13,549 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 0 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 0 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused import: `std::collections::VecDeque`
 --> src/main.rs:1:5
  |
1 | use std::collections::VecDeque;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

ソースコード

diff #

use std::collections::VecDeque;


fn main() {
    let mut p = String::new();
    std::io::stdin().read_line(&mut p).ok();
    let p = p.trim().chars().map(|c| c as usize - '0' as usize).collect::<Vec<_>>();

    if p.len() == 1 {
        println!("No");
        return;
    } else if p.len() == 2 {
        if p[1] == 2 || p[1] == 3 || p[1] == 4 {
            if p[0] == 1 || p[0] == 7 || p[0] == 8 {
                println!("Yes");
                return;
            }
        }
    } else {
        let n = p.len()-1;
        if p[n] == 2 || p[n] == 3 || p[n] == 4 {
            if p[0] == 1 || p[0] == 6 || p[0] == 7 || p[0] == 8 {
                let end = (1..n).filter(|&i| p[i] == 3 || p[i] == 4 || p[i] == 5).nth(0).unwrap_or(n);
                let end_ok = (end..n).filter(|&i| p[i] == 3 || p[i] == 4 || p[i] == 5).count() == n-end;
                let middle_ok = end == 1 || p[end-1] == 7 || p[end-1] == 8;
                let start_ok = (end == 1 && p[0] != 6) || end == 2 || (1..=end-2).filter(|&i| p[i] == 6 || p[i] == 7).count() == end-2;
                if end_ok && middle_ok && start_ok {
                    println!("Yes");
                    return;
                }
            }
        }
    }
    println!("No");
}
0