結果
| 問題 | No.430 文字列検索 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-20 07:04:46 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 589 ms / 2,000 ms |
| コード長 | 604 bytes |
| 記録 | |
| コンパイル時間 | 262 ms |
| コンパイル使用メモリ | 39,424 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-09 08:58:38 |
| 合計ジャッジ時間 | 4,385 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 14 |
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static void *xmalloc(size_t size){
void *m = malloc(size);
if (!m) {
perror("malloc()");
exit(1);
}
return m;
}
int main(int argc, char *argv[]){
char S[50001];
int M;
fscanf(stdin, "%s", S);
fscanf(stdin, "%d", &M);
int i;
char *point = (char*)xmalloc(sizeof(char*));
char str[11];
int count = 0;
for (i=0;i<M;i++) {
fscanf(stdin, "%s", str);
point = S;
while ((point = strstr(point, str)) != NULL) {
count++;
point += 1;
}
}
free(point);
printf("%d\n", count);
exit(0);
}