Submission #498334

# Submission time Handle Problem Language Result Execution time Memory
498334 2021-12-25T04:25:27 Z sohomdutta Carnival (CEOI14_carnival) Java 11
0 / 100
852 ms 18984 KB
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]-1)+" ");
        }
        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 852 ms 18856 KB Integer -1 violates the range [0, 137]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 844 ms 18952 KB Integer -1 violates the range [0, 145]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 174 ms 10940 KB Integer -1 violates the range [0, 133]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 775 ms 18984 KB Integer -1 violates the range [0, 143]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 792 ms 18944 KB Integer -1 violates the range [0, 149]
2 Halted 0 ms 0 KB -