제출 #341777

#제출 시각아이디문제언어결과실행 시간메모리
341777sunshine_unicornCarnival (CEOI14_carnival)Java
100 / 100
550 ms15708 KiB
import java.util.*;
import java.io.*;

public class carnival
{
   public static void main(String[] args) throws FileNotFoundException
   {
      // Scanner in = new Scanner(new File("carnival.in"));
      Scanner in = new Scanner(System.in);
      int n = in.nextInt();
      int[] result = new int[n + 1];
      ArrayList<Integer> list = new ArrayList<>();
      list.add(0);
      list.add(1);
      int total = 1;
      result[1] = total;
      
      for(int i = 2; i <= n; i++)
      {
         String s = "" + (total + 1);
         for(int j = 1; j <= total; j++)
            s += " " + list.get(j);
         System.out.println(s + " " + i);
         int current = in.nextInt();
         if(current > total)
         {
            list.add(i);
            total++;
            result[i] = total;
         }
         else
         {
            int a = 1;
            int b = total;
            while(current != 1)
            {
               int mid = (a + b) / 2;
               s = "" + (mid - a + 2);
               for(int j = a; j <= mid; j++)
                  s += " " + list.get(j);
               System.out.println(s + " " + i);
               current = in.nextInt();
               int colors = mid - a + 1;
               if(current > colors)
                  a = mid + 1;
               else
                  b = mid;
            }
            result[i] = a;
         }
      }
      in.close();
      
      System.out.print("0 ");
      for(int i = 1; i <= n; i++)
      {
         // PrintWriter out = new PrintWriter(new File("carnival.out"));
         System.out.print(result[i] + " ");
         System.out.flush();
         // out.println(result);
         // out.close();
      }
   }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...