using System; using System.Linq; using System.Collections.Generic; using System.Text.RegularExpressions; using System.Text; using System.Net; public class Program { public void Proc() { Reader.IsDebug = false; try { int posX = GetX(0, 100000); int posY = GetY(0, 100000); GetPos(posX, posY); } catch(Exception e) { } } Dictionary> dic = new Dictionary>(); private int GetY(int min, int max) { int idx1 = min + ((max-min)/3); int idx2 = min + ((max-min)*2/3); int minPos = GetPos(0,min); int idx1Pos = GetPos(0,idx1); int idx2Pos = GetPos(0,idx2); int maxPos = GetPos(0,max); int[] arr = new int[]{minPos, idx1Pos, idx2Pos, maxPos}; if(max-min<=3) { if(arr.Min() == minPos) { return min; } else if(arr.Min() == idx1Pos) { return idx1; } else if(arr.Min() == idx2Pos) { return idx2; } else { return max; } } if(arr.Min() == minPos) { return GetX(min, idx1); } else if(arr.Min() == idx1Pos) { return GetX(min, idx2); } else if(arr.Min() == idx2Pos) { return GetX(idx1, maxPos); } else { return GetX(idx2, max); } } private int GetX(int min, int max) { if(max-min<=1) { int num1 = GetPos(min, 0); int num2 = GetPos(max, 0); if(num1<=num2) { return min; } else { return max; } } int idx1 = min + ((max-min)/3); int idx2 = min + ((max-min)*2/3); int minPos = GetPos(min, 0); int idx1Pos = GetPos(idx1, 0); int idx2Pos = GetPos(idx2, 0); int maxPos = GetPos(max, 0); int[] arr = new int[]{minPos, idx1Pos, idx2Pos, maxPos}; if(max-min<=3) { if(arr.Min() == minPos) { return min; } else if(arr.Min() == idx1Pos) { return idx1; } else if(arr.Min() == idx2Pos) { return idx2; } else { return max; } } if(arr.Min() == minPos) { return GetX(min, idx1); } else if(arr.Min() == idx1Pos) { return GetX(min, idx2); } else if(arr.Min() == idx2Pos) { return GetX(idx1, maxPos); } else { return GetX(idx2, max); } } private int GetPos(int x, int y) { if(!dic.ContainsKey(x)) { dic.Add(x, new Dictionary()); } if(dic[x].ContainsKey(y)) { return dic[x][y]; } Console.WriteLine(x + " " + y); int ans = int.Parse(Reader.ReadLine()); if(ans == 0) { throw new Exception(); } dic[x][y] = ans; return ans; } public class Reader { public static bool IsDebug = true; private static System.IO.StringReader SReader; private static string InitText = @" 19 57 9 5 16 48 144 432 1296 3888 11664 34992 "; public static string ReadLine() { if(IsDebug) { if(SReader == null) { SReader = new System.IO.StringReader(InitText.Trim()); } return SReader.ReadLine(); } else { return Console.ReadLine(); } } } public static void Main(string[] args) { Program prg = new Program(); prg.Proc(); } }