import java.io.*;
import java.util.HashMap;
import java.util.TreeSet;
import java.util.TreeMap;
public class carnival {
static BufferedReader br;
static TreeMap<Integer, TreeSet<Integer>> costumeToPos;
static int i;
public static void main(String[] args) throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
costumeToPos = new TreeMap<>();
costumeToPos.put(1,new TreeSet<>());
costumeToPos.get(1).add(1);
for (i=2; i <= N; i++) {
System.out.print(i+" ");
for (int j = 1; j <= i; j++) {
System.out.print(j+" ");
}
System.out.println();
System.out.flush();
int feedback = Integer.parseInt(br.readLine());
if (feedback == costumeToPos.size()+1) {
costumeToPos.put(costumeToPos.lastKey()+1,new TreeSet<>());
costumeToPos.get(costumeToPos.lastKey()).add(i);
continue;
}
int a = 1, b = costumeToPos.lastKey()-1;
int ans = 0;
while (a <= b) {
int mid = (a+b+1)/2;
if (works(mid)) {
a = mid+1;
ans = mid;
}
else b = mid-1;
}
costumeToPos.get(ans+1).add(i);
}
int [] ans = new int [N+1];
for (int num : costumeToPos.keySet()) {
for (int n : costumeToPos.get(num)) {
ans[n] = num;
}
}
System.out.print(0+" ");
for (int i = 1; i <= N; i++) {
System.out.print(ans[i]+" ");
}
System.out.println();
System.out.flush();
}
static boolean works (int upTo) throws IOException {
System.out.print((upTo+1)+" ");
for (int num : costumeToPos.keySet()) {
if (num == upTo+1) break;
System.out.print(costumeToPos.get(num).first()+" ");
}
System.out.print(i+" ");
System.out.println();
System.out.flush();
int feedback = Integer.parseInt(br.readLine());
if (feedback == upTo+1) return true;
else return false;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
784 ms |
14264 KB |
Output is correct |
2 |
Correct |
808 ms |
14124 KB |
Output is correct |
3 |
Correct |
774 ms |
13952 KB |
Output is correct |
4 |
Correct |
702 ms |
13860 KB |
Output is correct |
5 |
Correct |
722 ms |
13732 KB |
Output is correct |
6 |
Correct |
696 ms |
13860 KB |
Output is correct |
7 |
Correct |
781 ms |
13860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
732 ms |
13748 KB |
Output is correct |
2 |
Correct |
851 ms |
13796 KB |
Output is correct |
3 |
Correct |
745 ms |
13872 KB |
Output is correct |
4 |
Correct |
697 ms |
13956 KB |
Output is correct |
5 |
Correct |
753 ms |
13808 KB |
Output is correct |
6 |
Correct |
700 ms |
13848 KB |
Output is correct |
7 |
Correct |
744 ms |
14024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
429 ms |
11560 KB |
Output is correct |
2 |
Correct |
706 ms |
13760 KB |
Output is correct |
3 |
Correct |
894 ms |
18108 KB |
Output is correct |
4 |
Correct |
781 ms |
13792 KB |
Output is correct |
5 |
Correct |
706 ms |
14012 KB |
Output is correct |
6 |
Correct |
738 ms |
13780 KB |
Output is correct |
7 |
Correct |
794 ms |
13776 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
745 ms |
13992 KB |
Output is correct |
2 |
Correct |
698 ms |
13772 KB |
Output is correct |
3 |
Correct |
767 ms |
13932 KB |
Output is correct |
4 |
Correct |
691 ms |
13932 KB |
Output is correct |
5 |
Correct |
765 ms |
13860 KB |
Output is correct |
6 |
Correct |
724 ms |
13812 KB |
Output is correct |
7 |
Correct |
797 ms |
13944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
745 ms |
13896 KB |
Output is correct |
2 |
Correct |
725 ms |
13720 KB |
Output is correct |
3 |
Correct |
935 ms |
17992 KB |
Output is correct |
4 |
Correct |
879 ms |
18060 KB |
Output is correct |
5 |
Correct |
735 ms |
13988 KB |
Output is correct |
6 |
Correct |
751 ms |
13884 KB |
Output is correct |
7 |
Correct |
753 ms |
13764 KB |
Output is correct |