結果

問題 No.430 文字列検索
ユーザー BucchimanBucchiman
提出日時 2020-04-17 01:02:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,604 ms / 2,000 ms
コード長 881 bytes
コンパイル時間 214 ms
コンパイル使用メモリ 33,152 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 08:34:35
合計ジャッジ時間 13,189 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 443 ms
6,940 KB
testcase_02 AC 1,428 ms
6,940 KB
testcase_03 AC 858 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 4 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 1,603 ms
6,944 KB
testcase_12 AC 1,604 ms
6,944 KB
testcase_13 AC 1,596 ms
6,944 KB
testcase_14 AC 1,530 ms
6,940 KB
testcase_15 AC 1,400 ms
6,944 KB
testcase_16 AC 810 ms
6,940 KB
testcase_17 AC 748 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
 * FileName:     string_search
 * CreatedDate:  2020-04-17 00:49:10 +0900
 * LastModified: 2020-04-17 01:02:02 +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);
        if(strlen(s)<strlen(string)){
            continue;
        }
        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