fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. typedef vector <int> vi;
  5. typedef pair <int, int> ii;
  6. typedef vector <vi> vvi;
  7. typedef vector <ii> vii;
  8. typedef vector <vii> vvii;
  9. #define PB push_back
  10. #define MP make_pair
  11. #define OO (1000000000)
  12. #define EPS (1e-9)
  13. #define all(v) ((v).begin()),((v).end())
  14. #define DEBUG(x) cout<< #x <<" = "<<"\""<< (x) <<"\""<<endl
  15. void read_file(bool outToFile = true){
  16. #ifdef LOCAL_TEST
  17. freopen("in.in", "rt", stdin);
  18. if(outToFile)
  19. freopen("out.out", "wt", stdout);
  20. #endif
  21. }
  22. //
  23. typedef unsigned int uint;
  24. #define nmMax 1000000+9
  25. map < uint, queue <int> > q;
  26. int n, m;
  27. uint x;
  28. char cmd;
  29. int rnk;
  30. //
  31. int main()
  32. {
  33. read_file();
  34.  
  35. rnk = 1;
  36. scanf("%d %d\n", &n, &m);
  37.  
  38. while(n--)
  39. {
  40. scanf("%u ", &x);
  41. q[x].push(rnk++);
  42. }
  43.  
  44. while(m--)
  45. {
  46. scanf("%c %u\n", &cmd, &x);
  47. if(cmd == 'I')
  48. {
  49. printf("%d\n", rnk);
  50. q[x].push(rnk++);
  51. }
  52. else if(cmd == 'S')
  53. {
  54. if(q[x].empty())
  55. printf("NONE\n");
  56. else
  57. printf("%d\n", q[x].front());
  58. }
  59. else
  60. {
  61. if(q[x].empty())
  62. printf("NONE\n");
  63. else
  64. printf("%d\n", q[x].front()), q[x].pop();
  65. }
  66. }
  67. }
  68.  
Success #stdin #stdout 0s 3144KB
stdin
Standard input is empty
stdout
Standard output is empty