Submission #298297

# Submission time Handle Problem Language Result Execution time Memory
298297 2020-09-12T17:01:58 Z FlashGamezzz Carnival (CEOI14_carnival) Java 11
0 / 100
126 ms 12652 KB
import java.io.*;
import java.util.*;

public class carnival {
	static Random rng = new java.util.Random(28);
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] prefs = new int[n];
		prefs[0] = 1;
		String s = "1";
		for (int i = 1; i < n; i++) {
			s += " " + Integer.toString(i+1);
			System.out.println((i+1) + " " + s);
			System.out.flush();
			prefs[i] = Integer.parseInt(br.readLine());
		}
		int[] vals = new int[n];
		vals[0] = 1;
		int count = 2;
		for (int i = 1; i < n; i++) {
			if (prefs[i] == prefs[i-1]+1) {
				vals[i] = count;
				count++;
			}
		}
		ArrayList<Integer> nums = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			if (vals[i] == 0) {
				ArrayList<Integer> temp = new ArrayList<Integer>();
				temp.addAll(nums);
				while (temp.size() > 1) {
					int ind = rng.nextInt(nums.size()), v = temp.get(ind);
					System.out.println("2 " + Integer.toString(v) + " " + (i+1));
					System.out.flush();
					int in = Integer.parseInt(br.readLine());
					if (in == 1) {
						vals[i] = v;
						break;
					}
					temp.remove(ind);
				}
				if (vals[i] == 0) {
					vals[i] = temp.get(0);
				}
			} else {
				nums.add(vals[i]);
			}
		}
		System.out.print("0");
		for (int i = 0; i < n; i++) {
			System.out.print(" " + vals[i]);
		}
		System.out.println();
	}
}
# Verdict Execution time Memory Grader output
1 Runtime error 101 ms 11884 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 112 ms 11524 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 108 ms 11520 KB Output is correct
2 Runtime error 102 ms 11288 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 107 ms 11456 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 126 ms 12652 KB Output is correct
2 Runtime error 109 ms 11776 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -