fork download
  1. using System;
  2. using static System.Console;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Text;
  6.  
  7. public class main
  8. {
  9. static void Main()
  10. {
  11. int orderAmount = Convert.ToInt32(ReadLine());
  12. StringBuilder strBuilder = new StringBuilder();
  13.  
  14. List<int> list = new List<int>();
  15. Queue<int> que = new Queue<int>();
  16. for(int i = 0; i < orderAmount; i++)
  17. {
  18. string order = ReadLine();
  19. switch (order[1])
  20. {
  21. case 'u':
  22. {
  23. string[] temp = order.Split();
  24. que.Enqueue(Convert.ToInt32(temp[1]));
  25. break;
  26. }
  27. case 'o':
  28. {
  29. if(que.Count > 0)
  30. strBuilder.Append(que.Dequeue() + "\n");
  31. else
  32. strBuilder.Append("-1\n");
  33. break;
  34. }
  35. case 'i':
  36. {
  37. strBuilder.Append(que.Count+"\n");
  38. break;
  39. }
  40. case 'm':
  41. {
  42. if(que.Count == 0)
  43. strBuilder.Append("1\n");
  44. else
  45. strBuilder.Append("0\n");
  46. break;
  47. }
  48. case 'r':
  49. {
  50. if(que.Count == 0)
  51. strBuilder.Append("-1\n");
  52. else
  53. strBuilder.Append(que.Peek()+"\n");
  54. break;
  55. }
  56. case 'a':
  57. {
  58. if(que.Count == 0)
  59. strBuilder.Append("-1\n");
  60. else if(que.Count == 1)
  61. strBuilder.Append(que.Peek()+"\n");
  62. else
  63. {
  64. int queCount = que.Count;
  65. for(int j = 0; j < que.Count-1; j++)
  66. list.Add(que.Dequeue());
  67. list.Add(que.Peek());
  68. strBuilder.Append(que.Dequeue()+"\n");
  69.  
  70. for(int j = 0; j < queCount; j++)
  71. que.Enqueue(list[j]);
  72. }
  73. list.Clear();
  74. break;
  75. }
  76. }
  77. }
  78. WriteLine(strBuilder.ToString());
  79. }
  80. }
Runtime error #stdin #stdout #stderr 0.03s 24236KB
stdin
4
push 1
push 2
push 3
back
stdout
Standard output is empty
stderr
Unhandled Exception:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in <6649516e5b3542319fb262b421af0adb>:0 
  at main.Main () [0x0020d] in <ec486b05d5904f0188061fefa13769c1>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in <6649516e5b3542319fb262b421af0adb>:0 
  at main.Main () [0x0020d] in <ec486b05d5904f0188061fefa13769c1>:0