結果
| 問題 |
No.1005 BOT対策
|
| コンテスト | |
| ユーザー |
amaridekinai
|
| 提出日時 | 2020-03-06 21:58:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 700 bytes |
| コンパイル時間 | 1,721 ms |
| コンパイル使用メモリ | 162,692 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-20 00:48:32 |
| 合計ジャッジ時間 | 2,415 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(void){
string S,T; cin >> S >> T;
int n = (int)S.size(); int m = (int)T.size();
// m == 1がコーナーケース
if( m == 1 ){
char c = T[0];
for(int i = 0; i < n; i++){
if( S[i] == c ){ cout << "-1" << endl; return 0;}
}
cout << 0 << endl; return 0;
}
if( n < m ){ cout << 0 << endl; return 0;}
int head = 0; int tail = 0;
int pos = 0; int cnt = 0;
for(int pos = 0; pos+m <= n; ){
string test = S.substr(pos,m);
if( test != T ){ pos++; continue;}
else{
cnt++; pos = pos+m-1;
}
}
cout << cnt << endl;
return 0;
}
amaridekinai