为啥报错????

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

Kyleshao @ 2023-08-11 10:53:04

代码:

#include <iostream>
using namespace std;
int a[100005][100005];
int main()
{
    int n,q;
    cin>>n>>q;
    for (int i=1;i<=q;i++)
    {
        int op;
        cin>>op;
        if (op==1)
        {
            int x,y,p;
            cin>>x>>y>>p;
            a[x][y]=p;
        }
        else
        {
            int x,y;
            cin>>x>>y;
            cout<<a[x][y]<<endl;
        }
    }
    return 0;
}

by Pink_Cut_Tree @ 2023-08-11 11:02:39

@Kyleshao 数组开太大了,建议开 vector 动态数组


by OIer_Tan @ 2023-08-11 11:05:28

数组炸了。

10^5\times 10^5 = 10^{10}$ 个 int ,大约为 $9356 MB

by XRRRRcode @ 2023-08-11 11:05:29

@Kyleshao MLE


|