結果

問題 No.430 文字列検索
ユーザー BucchimanBucchiman
提出日時 2020-04-17 00:57:53
言語 C
(gcc 12.3.0)
結果
RE  
実行時間 -
コード長 811 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 32,136 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-14 08:28:58
合計ジャッジ時間 12,575 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 433 ms
6,944 KB
testcase_02 AC 1,127 ms
6,944 KB
testcase_03 AC 673 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 RE -
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 1,617 ms
6,944 KB
testcase_12 AC 1,617 ms
6,940 KB
testcase_13 AC 1,614 ms
6,948 KB
testcase_14 AC 1,574 ms
6,940 KB
testcase_15 AC 1,421 ms
6,940 KB
testcase_16 AC 694 ms
6,940 KB
testcase_17 AC 634 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
 * FileName:     string_search
 * CreatedDate:  2020-04-17 00:49:10 +0900
 * LastModified: 2020-04-17 00:57:14 +0900
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define str_max 50000
int main(void){
    char *s=(char *)calloc(str_max,sizeof(char));
    scanf("%s",s);
    int m;
    scanf("%d",&m);
    int count=0,j,k;
    for(int i=0;i<m;i++){
        char *string = (char*)calloc(10,sizeof(char));
        scanf("%s",string);
        for(j=0;j<strlen(s)-strlen(string)+1;j++){
            for(k=0;k<strlen(string);k++){
                if(s[j+k]!=string[k]){
                    break;
                }
            }
            if(k==strlen(string)){
                count++;
            }
        }
        free(string);
    }
    printf("%d\n",count);
    free(s);
    return 0;
}
0