結果

問題 No.430 文字列検索
ユーザー yaoshimaxyaoshimax
提出日時 2016-10-02 23:51:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 878 bytes
コンパイル時間 481 ms
コンパイル使用メモリ 67,300 KB
実行使用メモリ 7,928 KB
最終ジャッジ日時 2023-08-13 18:27:14
合計ジャッジ時間 4,569 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 533 ms
4,380 KB
testcase_02 TLE -
testcase_03 AC 1,304 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1,692 ms
4,380 KB
testcase_12 AC 1,724 ms
4,380 KB
testcase_13 AC 1,711 ms
4,380 KB
testcase_14 AC 1,708 ms
4,380 KB
testcase_15 AC 1,558 ms
4,376 KB
testcase_16 AC 1,194 ms
4,376 KB
testcase_17 AC 1,139 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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