結果

問題 No.279 木の数え上げ
ユーザー m0ntBL4Ncm0ntBL4Nc
提出日時 2019-10-21 12:05:37
言語 Rust
(1.77.0)
結果
TLE  
実行時間 -
コード長 1,557 bytes
コンパイル時間 538 ms
コンパイル使用メモリ 141,052 KB
実行使用メモリ 8,648 KB
最終ジャッジ日時 2023-09-15 14:57:24
合計ジャッジ時間 4,281 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,620 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn main() {
    let line = getline();
    let s = line.trim();

    let mut char_use_table: Vec<bool> = Vec::new();     // 使用済->true 未使用->false
    for _ in 0..s.len() {
        char_use_table.push(false);
    }

    let mut tree_chars: Vec<char> = Vec::new();
    tree_chars.push('t');
    tree_chars.push('r');
    tree_chars.push('e');
    tree_chars.push('e');
    let mut tree_chars_index: usize = 0;

    let mut valid_chars: Vec<char> = Vec::new();
    for c in s.chars().into_iter() {
        if c == 't' || c == 'r' || c == 'e' {
            valid_chars.push(c);
        }
    }

    let mut tree_count = 0;     // 何個treeができたか
    loop {
        let mut can_make_tree = false;

        for _ in 0..4 {
            let mut s_index = 0;
            for c in s.chars().into_iter() {
                if char_use_table[s_index] == false && c == tree_chars[tree_chars_index] {
                    tree_chars_index += 1;
                    if tree_chars_index >= tree_chars.len() {
                        can_make_tree = true;
                        tree_chars_index = 0;
                    }
                    char_use_table[s_index] = true;
                    break;
                }
                s_index += 1;
            }
        }

        if can_make_tree == true {
            tree_count += 1;
        } else {
            break;
        }
    }

    println!("{}", tree_count);
}
0