using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace KULE { class Program { private static int spheres; private static int minLeft = 1; private static int maxLeft; private static bool oddIsLight; static void Main(string[] args) { spheres = maxLeft = int.Parse(Console.ReadLine()); oddIsLight = Triage(); while (minLeft != maxLeft) { Cull(); } Console.WriteLine("ANSWER {0}{1}", oddIsLight ? "-" : "", minLeft); } static bool Triage() { int third = spheres / 3; var first = Weigh(third, 1); var second = Weigh(third, third + 1); if (first == 0) { minLeft = third * 2 + 1; maxLeft = third * 3; if (second > 0) return false; if (second < 0) return true; return CheckRemainder(); } if (second == 0) { maxLeft = third; return (first > 0) ? true : false; } minLeft = third + 1; maxLeft = third * 2; return (first > 0) ? false : true; } static bool CheckRemainder() { var first = Weigh(1, spheres - 1); if (spheres % 3 == 1) { minLeft = spheres; return first > 0 ? false : true; } else { var second = Weigh(1, spheres - 2); if (second == 0) { minLeft = spheres; return first > 0 ? false : true; } minLeft = maxLeft = spheres - 1; return first > 0 ? true : false; } } static void Cull() { var third = (maxLeft - minLeft + 1) / 3; if (third == 0) third = 1; var result = Weigh(third, minLeft); int oddThird; switch (result) { case -1: oddThird = oddIsLight ? 1 : 0; break; case 1: oddThird = oddIsLight ? 0 : 1; break; default: oddThird = 2; break; } minLeft = oddThird * third + minLeft; if (oddThird < 2) maxLeft = minLeft + third - 1; } static int Weigh(int num, int from) { Console.WriteLine("WEIGHT {0} {1}", num, String.Join(" ", Enumerable.Range(from, num * 2))); var result = Console.ReadLine(); return result == "LEFT" ? -1 : result == "RIGHT" ? 1 : 0; } } }