結果

問題 No.345 最小チワワ問題
ユーザー iwotiwot
提出日時 2019-04-29 00:20:57
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 957 bytes
コンパイル時間 797 ms
コンパイル使用メモリ 175,984 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 11:16:00
合計ジャッジ時間 1,819 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 1 ms
6,676 KB
testcase_07 AC 1 ms
6,676 KB
testcase_08 AC 1 ms
6,676 KB
testcase_09 AC 1 ms
6,676 KB
testcase_10 AC 1 ms
6,676 KB
testcase_11 AC 1 ms
6,676 KB
testcase_12 AC 1 ms
6,676 KB
testcase_13 AC 1 ms
6,676 KB
testcase_14 AC 1 ms
6,676 KB
testcase_15 AC 1 ms
6,676 KB
testcase_16 AC 1 ms
6,676 KB
testcase_17 AC 1 ms
6,676 KB
testcase_18 AC 1 ms
6,676 KB
testcase_19 AC 1 ms
6,676 KB
testcase_20 AC 1 ms
6,676 KB
testcase_21 AC 1 ms
6,676 KB
testcase_22 AC 1 ms
6,676 KB
testcase_23 AC 1 ms
6,676 KB
testcase_24 AC 1 ms
6,676 KB
testcase_25 AC 1 ms
6,676 KB
testcase_26 AC 1 ms
6,676 KB
testcase_27 AC 1 ms
6,676 KB
testcase_28 AC 1 ms
6,676 KB
testcase_29 AC 1 ms
6,676 KB
testcase_30 AC 1 ms
6,676 KB
testcase_31 AC 1 ms
6,676 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused label
  --> Main.rs:11:5
   |
11 |     'start: for i in 0..input.len() {
   |     ^^^^^^
   |
   = note: `#[warn(unused_labels)]` on by default

warning: unused variable: `pos`
 --> Main.rs:6:13
  |
6 |     let mut pos = 0;
  |             ^^^ help: if this is intentional, prefix it with an underscore: `_pos`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: variable does not need to be mutable
 --> Main.rs:6:9
  |
6 |     let mut pos = 0;
  |         ----^^^
  |         |
  |         help: remove this `mut`
  |
  = note: `#[warn(unused_mut)]` on by default

warning: 3 warnings emitted

ソースコード

diff #

fn main() {
    let mut input = String::new();
    let _ = std::io::stdin().read_line(&mut input);

    let input = input.chars().collect::<Vec<char>>();
    let mut pos = 0;
    let test = vec!['c', 'w', 'w'];
    let mut check = vec![];
    let mut min = -1;

    'start: for i in 0..input.len() {
        let mut test_index = 0;
        check.clear();
        'inner: for j in i..input.len() {
            if test[test_index] == input[j] {
                check.push(j);
                test_index += 1;
                if check.len() == test.len() {
                    if min == -1 {
                        min = (check[check.len()-1] + 1 - check[0]) as i32;
                    } else if ((check[check.len()-1] + 1 - check[0]) as i32) < min {
                        min = (check[check.len()-1] + 1 - check[0]) as i32;
                    }
                    break 'inner;
                }
            }
        }
    }

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