编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#3506 #1008. 出行请佩戴好字符串 Compile Error 0 0 ms 0 K C++ 17 / 1.5 K s230026080 2023-11-25 15:28:29
显示原始代码
#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[]) {
    if (strlen(T) != strlen(S) + 1)
        return false;
    int i = 0, j = 0, ct = 0;
    for (i = 0; i < strlen(S); i++) {
        while (j < strlen(T)) {
            if (S[i] == T[j]) {
                ct++;
                j++;
                break;
            }
            j++;
        }
    }
    if (ct == strlen(S))
        return true;
    else
        return false;
}

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

bool c4(char T[]) {
    if (strlen(S) != strlen(T))
        return false;
    int i, ct = 0;
    for (i = 0; i < strlen(S); i++) {
        if (S[i] == T[i]) {
            ct++;
        }
    }
    if (ct == strlen(S) - 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])) {
            ct++;
            days[j++] = ct;
        }
        if (c2(T[i])) {
            ct++;
            days[j++] = ct;
        }
        if (c3(T[i])) {
            ct++;
            days[j++] = ct;
        }
        if (c4(T[i])) {
            ct++;
            days[j++] = ct;
        }
    }
    printf("%d\n", ct);
    for (i = 0; i < ct; i++) {
        printf("%d ", days[i]);
    }
    return 0;
}

编译信息

/sandbox/1/a.cpp:7:17: error: size of array 'T' exceeds maximum object size '2147483647'
    7 | char S[500001], T[500001][500001];
      |                 ^
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:85:15: error: 'T' was not declared in this scope
   85 |   scanf("%s", T[i]);
      |               ^
/sandbox/1/a.cpp:89:10: error: 'T' was not declared in this scope
   89 |   if (c1(T[i]))
      |          ^
/sandbox/1/a.cpp:94:10: error: 'T' was not declared in this scope
   94 |   if (c2(T[i]))
      |          ^
/sandbox/1/a.cpp:99:10: error: 'T' was not declared in this scope
   99 |   if (c3(T[i]))
      |          ^
/sandbox/1/a.cpp:104:10: error: 'T' was not declared in this scope
  104 |   if (c4(T[i]))
      |          ^
/sandbox/1/a.cpp:82:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   82 |  scanf("%d %s", &N, S);
      |  ~~~~~^~~~~~~~~~~~~~~~