编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#3774 #1008. 出行请佩戴好字符串 Compile Error 0 0 ms 0 K C / 1.6 K s230026080 2023-11-25 16:49:39
显示原始代码
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>

int N;
char S[500001], T[500001][500001];

bool c1(char T[]) {
    if (!strcmp(S, T))
        return true;
    else
        return false;
}

bool c2(char T[]) {
    int lenT = strlen(T), lenS = strlen(S);
    if (strlen(T) != strlen(S) + 1)
        return false;
    int i = 0, j = 0, ct = 0;
    for (i = 0; i < lenS; i++) {
        while (j < lenT) {
            if (S[i] == T[j]) {
                ct++;
                j++;
                break;
            }
            j++;
        }
    }
    if (ct == lenS)
        return true;
    else
        return false;
}

bool c3(char T[]) {
    int lenT = strlen(T), lenS = strlen(S);
    if (strlen(S) != strlen(T) + 1)
        return false;
    int i = 0, j = 0, ct = 0;
    for (i = 0; i < lenT; i++) {
        while (j < lenS) {
            if (T[i] == S[j]) {
                ct++;
                j++;
                break;
            }
            j++;
        }
    }
    if (ct == lenT)
        return true;
    else
        return false;
}

bool c4(char T[]) {
    int lenS = strlen(S);
    if (strlen(S) != strlen(T))
        return false;
    int i, ct = 0;
    for (i = 0; i < lenS; i++) {
        if (S[i] == T[i]) {
            ct++;
        }
    }
    if (ct == lenS - 1)
        return true;
    else
        return false;
}

int main() {
    int i, j = 0, ct = 0, days[500001];
    scanf("%d %s", &N, S);
    for (i = 0; i < N; i++) {
        scanf("%s", T[i]);
    }
    for (i = 0; i < N; ++i) {
        if (c1(T[i]) == true) {
            ct++;
            days[j++] = i + 1;
        }
        if (c2(T[i])) {
            ct++;
            days[j++] = i + 1;
        }
        if (c3(T[i])) {
            ct++;
            days[j++] = i + 1;
        }
        if (c4(T[i])) {
            ct++;
            days[j++] = i + 1;
        }
    }
    printf("%d\n", ct);
    for (i = 0; i < ct; i++) {
        printf("%d ", days[i]);
    }
    return 0;
}

编译信息

/sandbox/1/a.c:7:19: error: array is too large (500001 elements)
char S[500001], T[500001][500001];
                  ^~~~~~
1 error generated.