結果

問題 No.430 文字列検索
ユーザー DugongDugong
提出日時 2016-10-04 19:23:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 593 bytes
コンパイル時間 506 ms
コンパイル使用メモリ 66,096 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-15 17:45:00
合計ジャッジ時間 2,027 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 79 ms
4,380 KB
testcase_02 AC 47 ms
4,384 KB
testcase_03 AC 58 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 28 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 79 ms
4,376 KB
testcase_12 AC 80 ms
4,376 KB
testcase_13 AC 80 ms
4,376 KB
testcase_14 AC 63 ms
4,376 KB
testcase_15 AC 56 ms
4,376 KB
testcase_16 AC 54 ms
4,376 KB
testcase_17 AC 46 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<cstring>
#include<map>
#include<set>
#include<string>
#include<algorithm>
using namespace std;

char s[50001];
char c[5000][11];
int m,ans;
set<string> st;

int main(){
  scanf("%s %d",s,&m);
  for(int i=0;i<m;i++){
    scanf("%s",c[i]);
    string str(c[i]);
    st.insert(str);
  }
  int l = strlen(s);
  for(int i=0;i<l;i++){
    for(int j=1;j<=10&&i+j<=l;j++){
      char c = s[i+j];
      s[i+j] = '\0';
      string str(s+i); // attention!
      if(st.find(str)!=st.end()){
        ans++;
      }
      s[i+j] = c;
    }
  }
  printf("%d\n",ans);
  return 0;
}
0