校长邮箱
原题链接:60966.WA聊天室2025-07-27 18:44:08
发布于:河北
#include<bits/stdc++.h>
using namespace std;
int main(){
stack<string>st;
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
char s;
cin>>s;
if(s=='C'){
string k;
cin>>k;
if(st.size()>=m)continue;
st.push(k);
}
else {
if(st.size()){
cout<<st.top()<<'\n';
st.pop();
}
else cout<<"Everyone, come and deliver it.\n";
}
}
}
全部评论 2
6奥
2025-07-27 来自 河北
0#include <bits/stdc++.h>
using namespace std;
stack <string> stk;
int n,m;
string us;
string post;
int main(){
cin >> n >> m;
int num=0;
while (n--){
cin >> us;
if (us=="C"){
cin >> post;
stk.push(post);
if (num>=stk.size())continue;
num++;
}else if (us=="Q"&&stk.empty()){
cout << "Everyone, come and deliver it." << endl;
}else if (us=="Q"&&stk.size()>0){
cout << stk.top() << endl;
stk.pop();
num--;
}} return 0;
}
2025-07-27 来自 河北
0
有帮助,赞一个