結果
| 問題 | No.430 文字列検索 |
| コンテスト | |
| ユーザー |
Dugong
|
| 提出日時 | 2016-10-04 19:23:45 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 56 ms / 2,000 ms |
| コード長 | 593 bytes |
| 記録 | |
| コンパイル時間 | 642 ms |
| コンパイル使用メモリ | 78,440 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-09 08:48:44 |
| 合計ジャッジ時間 | 1,887 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 14 |
ソースコード
#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;
}
Dugong