結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
|
提出日時 | 2019-04-29 00:03:41 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 633 bytes |
コンパイル時間 | 12,103 ms |
コンパイル使用メモリ | 404,064 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-21 14:22:20 |
合計ジャッジ時間 | 11,883 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 14 |
コンパイルメッセージ
warning: unused variable: `pos` --> src/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 --> src/main.rs:6:9 | 6 | let mut pos = 0; | ----^^^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default
ソースコード
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 mut check = vec![]; let test = vec!['c', 'w', 'w']; let mut test_index = 0; for i in 0..input.len() { if test[test_index] == input[i] { check.push(i); test_index += 1; if check.len() == test.len() { break; } } } if check.len() == test.len() { println!("{}", check[check.len()-1] + 1 - check[0]); } else { println!("-1"); } }