E.cpp 432 B

1234567891011121314151617181920212223
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4. ios::sync_with_stdio(false);
  5. int n, q;
  6. cin >> n >> q;
  7. vector<queue<int>> S(n);
  8. while (q--) {
  9. int op, t;
  10. cin >> op >> t;
  11. if (op == 0) {
  12. int x;
  13. cin >> x;
  14. S[t].push(x);
  15. } else if (op == 1) {
  16. if (S[t].size()) cout << S[t].front() << endl;
  17. } else if (op == 2) {
  18. if (S[t].size()) S[t].pop();
  19. }
  20. }
  21. return 0;
  22. }