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 Scanner fin = new Scanner(System.in);
public static void main(String[] args) {
int n = fin.nextInt();
int previousTotal = 0;
int previousNum = 0;
int[] nums = new int[n];
for (int i=0; i<n; i++) {
String s = (i+1)+"";
for (int j=0; j<=i; j++) {
s += " "+(j+1);
}
System.out.println(s);
int numCostumes = fin.nextInt();
if (numCostumes == previousTotal) {
int low = 0;
int high = i-1;
while (low < high) {
int mid = (low+high)/2;
if (works(low+1, mid+1, i+1)) {
high = mid;
}
else {
low = mid+1;
}
}
nums[i] = nums[low];
}
else {
nums[i] = ++previousNum;
}
previousTotal = numCostumes;
}
String s = "0";
for (int i=0; i<n; i++) {
s += " "+nums[i];
}
System.out.println(s);
fin.close();
System.exit(0);
}
public static boolean works(int low, int mid, int num) {
String s = (mid-low+1)+"";
for (int j=low; j<=mid; j++) {
s += " "+j;
}
System.out.println(s);
int a = fin.nextInt();
s += " "+num;
System.out.println(s);
int b = fin.nextInt();
if (a == b) {
return true;
}
return false;
}
}
# | 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... |