結果
| 問題 | No.1005 BOT対策 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-31 21:04:24 |
| 言語 | Rust (1.94.0 + proconio + num + itertools) |
| 結果 |
AC
|
| 実行時間 | 0 ms / 2,000 ms |
| + 787µs | |
| コード長 | 621 bytes |
| 記録 | |
| コンパイル時間 | 6,019 ms |
| コンパイル使用メモリ | 188,660 KB |
| 実行使用メモリ | 9,408 KB |
| 最終ジャッジ日時 | 2026-07-12 08:23:22 |
| 合計ジャッジ時間 | 2,583 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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);
}