这道题,每个柜子都有很多个格子,但是具体多少格子是不确定的,我们知道的是格子的总数一共不超过10的7次方
这道题,如果我们用数组的话,10的五次方乘10的五次方是一定会超时的
所以我们只能用vector来解决这道问题,一共才会开不到10的7次方个格子
#include <iostream>
#include <vector>
using namespace std;
const int N = 1e5+10;
//int a[N][N]//空间太大,程序运行不了
vector<int> a[N];//正确√
int n,q;
int main()
{
cin >> n >> q;
while(q--)
{
int op,i,j;cin >> op >> i >> j;
if(op == 1)
{
int x;cin >> x;
if(a[i].size() < j)
{
a[i].resize(j+1);
}
a[i][j] = x;
}
else if(op == 2)
{
cout << a[i][j] << endl;
}
}
return 0;
}