题解:AT_joi2022_yo2_a Library 2
Update:修改格式。
题意
有
题解
这道题可以直接用栈模拟。输入不为
#include<bits/stdc++.h>
using namespace std;
int q; //代表题目中的 Q
string x;
stack<string>s; //创建一个类型为字符串的栈
int main()
{
cin>>q;
while(q--)
{
cin>>x; //此处数据范围 2*10^5 不会超时
if(x=="READ") //若为 READ 输出栈顶
{
cout<<s.top()<<endl; //记得换行
s.pop(); //弹出
}
else s.push(x);
}
return 0;
}