求助,全紫,帮看看哪里出了问题

P3613 【深基15.例2】寄包柜

229074045liluzhi @ 2023-11-18 21:27:48

#include <stdio.h>

#define MAX_N 100000
#define MAX_Q 100000

long lockers[MAX_N + 1][100001]; // 二维数组模拟每个寄包柜的格子

int main(void) {
    int n, q;
    scanf("%d %d", &n, &q);

    for (int i = 0; i < q; ++i) {
        long op, x, y;
        long k;
        scanf("%ld %ld %ld", &op, &x, &y);

        if (op == 1) {
            scanf("%ld", &k);
            // 更新操作
            lockers[x][y] = k;
        } else {
            // 查询操作
            printf("%ld\n", lockers[x][y]);
        }
        printf("\n");
    }

    return 0;
}

by heyx0201 @ 2023-11-18 21:29:39

@229074045liluzhi 《10^5 \times 10^5 的数组》


by jiangjiangQwQ @ 2023-11-18 21:29:59

数组太大了。


by wxdsherry @ 2024-03-16 15:16:57

可以用动态数组


|