fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. queue <string> alumnos, trabajadores;
  7. string accion, nombre, tipo;
  8.  
  9. cin >> n;
  10. for(int i=1;i<n;i++){
  11. cin >> accion >> tipo;
  12. if(accion=="LLEGA" && tipo=="ALUMNO"){
  13. cin >> nombre;
  14. alumnos.push(nombre);
  15. }
  16. else if(accion=="LLEGA" && tipo=="TRABAJADOR"){
  17. cin >> nombre;
  18. trabajadores.push(nombre);
  19. }
  20. else if(accion=="ATIENDE"){
  21. while(!trabajadores.empty()){
  22. cout << trabajadores.front();
  23. trabajadores.pop();
  24. }
  25. cout << alumnos.front();
  26. alumnos.pop();
  27. }
  28. }
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0.01s 5280KB
stdin
7
LLEGA ALUMNO luis
LLEGA TRABAJADOR ana
LLEGA ALUMNO jorge
ATIENDE
ATIENDE
LLEGA TRABAJADOR juan
ATIENDE
stdout
analuisjuanjorge