Submission #298304

# Submission time Handle Problem Language Result Execution time Memory
298304 2020-09-12T17:04:37 Z FlashGamezzz Carnival (CEOI14_carnival) Java 11
0 / 100
124 ms 12708 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();
      	return;
	}
}
# Verdict Execution time Memory Grader output
1 Runtime error 102 ms 11412 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 101 ms 11356 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 107 ms 11384 KB Output is correct
2 Runtime error 101 ms 11532 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 105 ms 11496 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 124 ms 12708 KB Output is correct
2 Runtime error 112 ms 11328 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -