結果
| 問題 |
No.1005 BOT対策
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-31 21:04:24 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 621 bytes |
| コンパイル時間 | 12,599 ms |
| コンパイル使用メモリ | 394,936 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-06-20 00:51:54 |
| 合計ジャッジ時間 | 13,833 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
use std::io::*;
fn main() {
let mut s: String = String::new();
std::io::stdin().read_to_string(&mut s).ok();
let mut itr = s.trim().split_whitespace();
let s: String = itr.next().unwrap().to_string();
let t: &str = itr.next().unwrap();
if t.len() == 1 && s.find(t) != None {
println!("-1");
return;
}
let mut idx = 0;
let mut ans = 0;
while idx < s.len() {
if idx + t.len() <= s.len() && &s[idx..idx + t.len()] == t {
idx += t.len() - 1;
ans += 1;
} else {
idx += 1;
}
}
println!("{}", ans);
}