結果

問題 No.430 文字列検索
ユーザー yaoshimax
提出日時 2016-10-02 23:51:45
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 878 bytes
コンパイル時間 814 ms
コンパイル使用メモリ 68,744 KB
実行使用メモリ 13,640 KB
最終ジャッジ日時 2024-11-10 00:05:23
合計ジャッジ時間 4,862 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#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();
      int skip[size];
      skip[0]=0;
      for( int j=1; j<size; j++){
         for( int k=1; k<=j ; k++ ){
           bool ok = true;
           for( int l = 0 ; k+l < j; l++){
             if( C[l]!=C[k+l] ) ok = false;
           }
           if( ok ){
              skip[j] = k-1;
              break;
           }
         }
      }
      for( int j = 0 ; j+size-1 < len; j++ ){
         for( int k = 0 ; k < size; k++ ){
            if( S[j+k]!=C[k] ){
               j+=skip[k];
               break;
            }
            if( k == size-1 ) ans++;
         }
      }
   }
   cout << ans << endl;
}
0