题解:P14325 [JOI2022 预选赛 R2] 图书馆 2 / Library 2
linzeyu2012 · · 题解
这道题十分简单,直接用栈模拟即可。
code:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
stack<string> s;
int main(){
int n;
cin>>n;
while(n--){
string op;
cin>>op;
if(op!="READ") s.push(op);
else cout<<s.top()<<"\n",s.pop();
}
return 0;
}