結果
| 問題 |
No.430 文字列検索
|
| コンテスト | |
| ユーザー |
alorie10
|
| 提出日時 | 2020-03-16 08:53:20 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 434 ms / 2,000 ms |
| コード長 | 512 bytes |
| コンパイル時間 | 508 ms |
| コンパイル使用メモリ | 64,848 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-10 00:41:29 |
| 合計ジャッジ時間 | 5,283 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 14 |
ソースコード
#include <iostream>
#define base 950527
using namespace std;
typedef long long ll;
string s,t;
ll lh,ns,nt,LH,tmp=1,n,ans;
int main(void){
cin>>s>>n;
for(int i=0;i<n;i++){
lh=LH=0,tmp=1;
cin>>t;
ns=s.size();
nt=t.size();
for(int i=0;i<nt;i++){
lh=lh*base+s[i];
LH=LH*base+t[i];
tmp*=base;
}
if(lh==LH){ans++;}
for(int i=0;i<ns-nt;i++){
lh=lh*base-tmp*s[i];
lh+=s[i+nt];
if(LH==lh){ans++;}
}
}
cout<<ans<<endl;
}
alorie10