답안 #1021487

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1021487 2024-07-12T18:49:52 Z QuantumPi 사육제 (CEOI14_carnival) Java 11
0 / 100
149 ms 12324 KB
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;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 149 ms 12192 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 122 ms 12324 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 124 ms 12092 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 125 ms 12088 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 129 ms 11916 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -