結果
| 問題 |
No.430 文字列検索
|
| コンテスト | |
| ユーザー |
Dugong
|
| 提出日時 | 2016-10-04 19:23:45 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 74 ms / 2,000 ms |
| コード長 | 593 bytes |
| コンパイル時間 | 547 ms |
| コンパイル使用メモリ | 62,612 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-10 00:09:03 |
| 合計ジャッジ時間 | 1,686 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 14 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf("%s %d",s,&m);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:17:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
17 | scanf("%s",c[i]);
| ~~~~~^~~~~~~~~~~
ソースコード
#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