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();
System.exit(0);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
109 ms |
11384 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
104 ms |
11260 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 |
11276 KB |
Output is correct |
2 |
Runtime error |
108 ms |
11560 KB |
Execution failed because the return code was nonzero |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
121 ms |
11380 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
136 ms |
12628 KB |
Output is correct |
2 |
Runtime error |
121 ms |
11356 KB |
Execution failed because the return code was nonzero |
3 |
Halted |
0 ms |
0 KB |
- |