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.*;
public class carnival {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] confirmed = new int[n];
ArrayList<Integer> same = new ArrayList<>();
confirmed[0] = 1;
int curNum = 1;
for(int i = 1; i < n; i++) {
StringBuilder s = new StringBuilder();
s.append(i + 1);
for(int j = 0; j <= i; j++) s.append(" ").append(j + 1);
System.out.println(s); System.out.flush();
confirmed[i] = sc.nextInt();
if(confirmed[i] == confirmed[i - 1]) {
same.add(i);
}
}
for(int check : same) {
int min = 0;
int max = check - 1;
while(min != max) {
int mid = (min + max)/2;
StringBuilder s = new StringBuilder();
s.append((mid - min) + 1);
for(int j = min; j <= mid; j++) s.append(" ").append(j + 1);
System.out.println(s); System.out.flush();
int notIncluded = sc.nextInt();
s.append(" ").append(check + 1);
System.out.println(s); System.out.flush();
int included = sc.nextInt();
if(included == notIncluded) {
max = mid;
} else {
min = mid + 1;
}
}
confirmed[check] = confirmed[min];
}
StringBuilder s = new StringBuilder();
s.append(0);
for(int i : confirmed) {
s.append(" ").append(i);
}
System.out.println(s);
System.out.flush();
sc.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... |