2525: 【普及-】【P3613】寄包柜

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:41 解决:17

题目描述

超市里有 lns="http://www.w3.org/1998/Math/MathML">(1105) 个寄包柜。每个寄包柜格子数量不一,第 lns="http://www.w3.org/1998/Math/MathML"> 个寄包柜有 lns="http://www.w3.org/1998/Math/MathML">(1105) 个格子,不过我们并不知道各个 lns="http://www.w3.org/1998/Math/MathML"> 的值。对于每个寄包柜,格子编号从 1 开始,一直到 lns="http://www.w3.org/1998/Math/MathML">。现在有 lns="http://www.w3.org/1998/Math/MathML">(1105) 次操作:

  • 1 i j k:在第 lns="http://www.w3.org/1998/Math/MathML"> 个柜子的第 lns="http://www.w3.org/1998/Math/MathML"> 个格子存入物品 lns="http://www.w3.org/1998/Math/MathML">(0109)。当 lns="http://www.w3.org/1998/Math/MathML">=0 时说明清空该格子。
  • 2 i j:查询第 lns="http://www.w3.org/1998/Math/MathML"> 个柜子的第 lns="http://www.w3.org/1998/Math/MathML"> 个格子中的物品是什么,保证查询的柜子有存过东西。

已知超市里共计不会超过 lns="http://www.w3.org/1998/Math/MathML">107 个寄包格子,lns="http://www.w3.org/1998/Math/MathML"> 是确定然而未知的,但是保证一定不小于该柜子存物品请求的格子编号的最大值。当然也有可能某些寄包柜中一个格子都没有。

输入

第一行 2 个整数 lns="http://www.w3.org/1998/Math/MathML"> 和 lns="http://www.w3.org/1998/Math/MathML">,寄包柜个数和询问次数。

接下来 lns="http://www.w3.org/1998/Math/MathML"> 个整数,表示一次操作。

输出

对于查询操作时,输出答案,以换行隔开。

样例输入 复制

5 4
1 3 10000 118014
1 1 1 1
2 3 10000
2 1 1

样例输出 复制

118014
1

提示

#include<bits/stdc++.h>
using namespace std;
int n,q,i,j,k,opt;
int main(){
	cin>>n>>q;
	vector<vector<int> > locker(n+1);
	while (q--) {
		cin>>opt;
		if (opt==1) {
			cin>>i>>j>>k;
			if (locker[i].size()<j+1) {
				locker[i].resize(j+1);
			}
			locker[i][j]=k;
		}else if (opt==2) {
			cin>>i>>j;
			cout<<locker[i][j]<<endl;
		}
	} 
	return 0;
}