# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1021477 | 2024-07-12T18:42:02 Z | QuantumPi | Carnival (CEOI14_carnival) | Java 11 | 0 ms | 0 KB |
import java.io.*; import java.util.*; public class Main { 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(); } 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; } }