L2-1 包装机 (2021天梯赛)
AC代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
queue<char> g[110];
stack<char> lz;
int n,m,s;
cin>>n>>m>>s;
char c;
for(int i=1;i<=n;i++)
{
for(int j=0;j<m;j++)
{
cin>>c;
g[i].push(c);
}
}
int t;
while(cin>>t)
{
if(t==-1)
return 0;
if(t==0 && !lz.empty() )
{
cout<<lz.top();
lz.pop();
}
else if(t)
{
if(!g[t].empty())
{
if(lz.size()==s)
{
cout<<lz.top();
lz.pop();
}
lz.push(g[t].front());
g[t].pop();
}
}
}
return 0;
}
本文来自博客园,作者:斯文~,转载请注明原文链接:https://www.cnblogs.com/zhiweb/p/15483371.html

浙公网安备 33010602011771号