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++;
}
}
System.out.print("0 ");
for(int i = 1; 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();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
787 ms |
18892 KB |
Integer 12 violates the range [1, 11] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
775 ms |
18828 KB |
Integer 6 violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
170 ms |
10964 KB |
Output is correct |
2 |
Incorrect |
794 ms |
18968 KB |
Integer 9 violates the range [1, 8] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
748 ms |
19036 KB |
Integer 5 violates the range [1, 4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
777 ms |
18948 KB |
Integer 3 violates the range [1, 2] |
2 |
Halted |
0 ms |
0 KB |
- |