不知道为什么会错
查看原帖
不知道为什么会错
814343
bc2_cryeggy楼主2023/11/23 19:44
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;

using ll = long long;

const int kMaxN = 1e5 + 10, kMaxM = 330, kInf = (((1 << 30) - 1) << 1) + 1;

int n, m, t, a[kMaxN], x;
queue<int> q1, q2[kMaxM];
string op;

int main() {
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; ++ i) {
    cin >> a[i];
  }
  cin >> t;
  for (; t; -- t) {
    cin >> op;
    if (op == "push") {
      cin >> x;
      if (!q2[a[x]].size()) {
        q1.push(a[x]);
      }
      q2[a[x]].push(x);
    } else {
      cout << q2[q1.front()].front() << '\n';
      q2[q1.front()].pop();
      if (!q2[q1.front()].size()) {
        q1.pop();
      }
    }
  }
  return 0;
}
2023/11/23 19:44
加载中...