fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace KULE
  7. {
  8. class Program
  9. {
  10. private static int spheres;
  11. private static int minLeft = 1;
  12. private static int maxLeft;
  13. private static bool oddIsLight;
  14.  
  15. static void Main(string[] args)
  16. {
  17. spheres = maxLeft = int.Parse(Console.ReadLine());
  18. oddIsLight = Triage();
  19. while (minLeft != maxLeft)
  20. {
  21. Cull();
  22. }
  23. Console.WriteLine("ANSWER {0}{1}", oddIsLight ? "-" : "", minLeft);
  24. }
  25.  
  26. static bool Triage()
  27. {
  28. int third = spheres / 3;
  29. var first = Weigh(third, 1);
  30. var second = Weigh(third, third + 1);
  31. if (first == 0)
  32. {
  33. minLeft = third * 2 + 1;
  34. maxLeft = third * 3;
  35. if (second > 0) return false;
  36. if (second < 0) return true;
  37. return CheckRemainder();
  38. }
  39. if (second == 0)
  40. {
  41. maxLeft = third;
  42. return (first > 0) ? true : false;
  43. }
  44. minLeft = third + 1;
  45. maxLeft = third * 2;
  46. return (first > 0) ? false : true;
  47. }
  48.  
  49. static bool CheckRemainder()
  50. {
  51. var first = Weigh(1, spheres - 1);
  52. if (spheres % 3 == 1)
  53. {
  54. minLeft = spheres;
  55. return first > 0 ? false : true;
  56. }
  57. else
  58. {
  59. var second = Weigh(1, spheres - 2);
  60. if (second == 0)
  61. {
  62. minLeft = spheres;
  63. return first > 0 ? false : true;
  64. }
  65. minLeft = maxLeft = spheres - 1;
  66. return first > 0 ? true : false;
  67. }
  68. }
  69.  
  70. static void Cull()
  71. {
  72. var third = (maxLeft - minLeft + 1) / 3;
  73. if (third == 0) third = 1;
  74. var result = Weigh(third, minLeft);
  75. int oddThird;
  76. switch (result)
  77. {
  78. case -1:
  79. oddThird = oddIsLight ? 1 : 0;
  80. break;
  81.  
  82. case 1:
  83. oddThird = oddIsLight ? 0 : 1;
  84. break;
  85.  
  86. default:
  87. oddThird = 2;
  88. break;
  89. }
  90. minLeft = oddThird * third + minLeft;
  91. if (oddThird < 2) maxLeft = minLeft + third - 1;
  92. }
  93.  
  94. static int Weigh(int num, int from)
  95. {
  96. Console.WriteLine("WEIGHT {0} {1}", num, String.Join(" ", Enumerable.Range(from, num * 2)));
  97. var result = Console.ReadLine();
  98. return result == "LEFT" ? -1 : result == "RIGHT" ? 1 : 0;
  99. }
  100. }
  101. }
  102.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(96,61): error CS1502: The best overloaded method match for `string.Join(string, string[])' has some invalid arguments
/usr/lib/mono/2.0/mscorlib.dll (Location of the symbol related to previous error)
prog.cs(96,61): error CS1503: Argument `#2' cannot convert `System.Collections.Generic.IEnumerable<int>' expression to type `string[]'
Compilation failed: 2 error(s), 0 warnings
stdout
Standard output is empty