結果
問題 | No.430 文字列検索 |
ユーザー | yaoshimax |
提出日時 | 2016-10-03 09:28:47 |
言語 | C++11 (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 745 bytes |
コンパイル時間 | 384 ms |
コンパイル使用メモリ | 58,360 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2024-11-10 00:08:08 |
合計ジャッジ時間 | 3,729 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | |
other | AC * 1 TLE * 1 |
ソースコード
#include <iostream> #include <vector> #include <string> using namespace std; int main(){ string S; cin >> S; int M; cin >> M; int ans = 0; int len = S.size(); for( int i = 0 ; i < M; i++){ string C; cin >> C; int size=C.size(); long long hash=0; long long offset=1LL; for( int j = 0 ; j < size; j++ ){ hash*=26; hash+=C[j]-'A'; offset*=26; } long long curHash=0; for( int j =0; j+1 <size; j++ ){ curHash*=26; curHash+=S[j]-'A'; } for( int j=size-1; j<len; j++){ curHash*=26; curHash+=S[j]-'A'; curHash%=offset; if( curHash==hash ) ans++; } } cout << ans << endl; }