This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |