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.io.*;
import java.util.*;
public class carnival {
public static int[] top;
public static Scanner scanner;
public static void main(String[] args) throws IOException {
scanner = new Scanner(System.in);
int n = scanner.nextInt();
top = new int[n];
int[] ans = new int[n];
int c = 0;
int count = 1;
for(int i=0; i<n; i++) {
System.out.print((i+1)+" ");
for(int j=0; j<=i; j++) {
System.out.print((j+1)+" ");
}
System.out.println();
System.out.flush();
int tc = scanner.nextInt();
if(tc>c) {
c = tc;
ans[i] = count;
count++;
top[tc-1] = i+1;
}
else {
int a = 0;
int b = c;
while(a!=b) {
int mid = (a+b/2);
boolean num = works(mid, i);
if(num) {
b = mid;
}
else {
a = mid+1;
}
//System.out.println(mid+" "+num+" "+i);
}
//System.out.println(a+" a");
ans[i] = ans[a];
//System.out.println(ans[a]);
}
}
System.out.print(0+" ");
for(int i=0; i<n; i++) {
System.out.print(ans[i]+" ");
}
System.out.flush();
}
public static boolean works(int mid, int num) {
System.out.print(mid+1+" ");
for(int i=0; i<=mid; i++) {
System.out.print((i+1)+" ");
}
System.out.println((num+1) + " ");
System.out.flush();
int c = scanner.nextInt();
return c==(mid+1);
}
}
# | 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... |