import java.util.*;
public class carnival {
static int count = 1;
static int [] array;
static Scanner sc = new Scanner(System.in);
public static void main(String[] args){
int n = sc.nextInt();
System.out.flush();
array = new int[n+1];
for(int i = 1; i < n; i++){
if(array[i]==0){
array[i]=count;
//System.out.println("HELLO: " + i);
//System.out.println(array[i]);
calculate(i+1, n, i);
count++;
}
}
for(int i = 0; i < n+1; i++){
System.out.print(array[i]+" ");
}
System.exit(0);
}
public static void calculate(int left, int right, int start){
if(left>right){
return;
}
print(left, right, start);
int x = sc.nextInt();
print(left, right, -1);
int x2 = sc.nextInt();
if(x==x2+1){
//System.out.println("ONE: " + left + " " + right);
return;
}else if((x==1)&&(x2==1)){
//System.out.println("TWO: " + left + " " + right);
for(int i = left; i <= right; i++){
array[i]=count;
}
}else{
//System.out.println("THREE: " + left + " " + right);
int mid = left + (right-left)/2;
calculate(left, mid, start);
calculate(right, mid+1, start);
}
}
public static void print(int left, int right, int start){
if(start!=-1){
System.out.print((right-left+2) + " ");
System.out.print(start + " ");
}else{
System.out.print((right-left+1) + " ");
}
for(int i = left; i <= right; i++){
System.out.print(i+" ");
}
System.out.flush();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
825 ms |
18940 KB |
Integer 12 violates the range [1, 11] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
814 ms |
18924 KB |
Integer 6 violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
135 ms |
10884 KB |
Output is correct |
2 |
Incorrect |
844 ms |
19112 KB |
Integer 9 violates the range [1, 8] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
825 ms |
18956 KB |
Integer 5 violates the range [1, 4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
797 ms |
18944 KB |
Integer 3 violates the range [1, 2] |
2 |
Halted |
0 ms |
0 KB |
- |