思路:
水题,略过
Tip:
无
#include <bits/stdc++.h> using namespace std; const int maxn = 1000 + 5; queue<char> que[maxn]; stack<char> s; int main() { int n, m, smax; cin >> n >> m >> smax; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { char c; cin >> c; que[i].push(c); } int nop; while (cin >> nop) { if (nop == -1) break; if (nop == 0) { if (!s.empty()) { cout << s.top(); s.pop(); } } else { if (que[nop].empty()) continue; if (s.size() == smax) { cout << s.top(); s.pop(); } s.push(que[nop].front()); que[nop].pop(); } } return 0; }