import java.util.*;
public class carnival {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] confirmed = new int[n];
ArrayList<Integer> same = new ArrayList<>();
confirmed[0] = 1;
int curNum = 1;
for(int i = 1; i < n; i++) {
StringBuilder s = new StringBuilder();
s.append(i + 1);
for(int j = 0; j <= i; j++) s.append(" ").append(j + 1);
System.out.println(s); System.out.flush();
confirmed[i] = sc.nextInt();
if(confirmed[i] == confirmed[i - 1]) {
same.add(i);
}
}
for(int check : same) {
int min = 0;
int max = check - 1;
while(min != max) {
int mid = (min + max)/2;
StringBuilder s = new StringBuilder();
StringBuilder s2 = new StringBuilder();
s.append((mid - min) + 1); s2.append((mid - min) + 2);
for(int j = min; j <= mid; j++) {
s.append(" ").append(j + 1);
s2.append(" ").append(j + 1);
}
System.out.println(s); System.out.flush();
int notIncluded = sc.nextInt();
s2.append(" ").append(check + 1);
System.out.println(s2); System.out.flush();
int included = sc.nextInt();
if(included == notIncluded) {
max = mid;
} else {
min = mid + 1;
}
}
confirmed[check] = confirmed[min];
}
StringBuilder s = new StringBuilder();
s.append(0);
for(int i : confirmed) {
s.append(" ").append(i);
}
System.out.println(s);
System.out.flush();
sc.close();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
326 ms |
17324 KB |
Output is correct |
2 |
Correct |
273 ms |
17296 KB |
Output is correct |
3 |
Correct |
201 ms |
16704 KB |
Output is correct |
4 |
Correct |
164 ms |
16420 KB |
Output is correct |
5 |
Correct |
340 ms |
17000 KB |
Output is correct |
6 |
Correct |
324 ms |
17068 KB |
Output is correct |
7 |
Correct |
266 ms |
16976 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
321 ms |
17032 KB |
Output is correct |
2 |
Correct |
318 ms |
16940 KB |
Output is correct |
3 |
Correct |
191 ms |
17144 KB |
Output is correct |
4 |
Correct |
175 ms |
15840 KB |
Output is correct |
5 |
Correct |
317 ms |
17460 KB |
Output is correct |
6 |
Correct |
313 ms |
17400 KB |
Output is correct |
7 |
Correct |
320 ms |
17272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
312 ms |
17408 KB |
Output is correct |
2 |
Correct |
338 ms |
16988 KB |
Output is correct |
3 |
Correct |
262 ms |
16928 KB |
Output is correct |
4 |
Correct |
167 ms |
15908 KB |
Output is correct |
5 |
Correct |
284 ms |
17136 KB |
Output is correct |
6 |
Correct |
280 ms |
17244 KB |
Output is correct |
7 |
Correct |
283 ms |
16960 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
317 ms |
17356 KB |
Output is correct |
2 |
Correct |
332 ms |
17240 KB |
Output is correct |
3 |
Correct |
198 ms |
16976 KB |
Output is correct |
4 |
Correct |
162 ms |
16048 KB |
Output is correct |
5 |
Correct |
307 ms |
16964 KB |
Output is correct |
6 |
Correct |
238 ms |
16712 KB |
Output is correct |
7 |
Correct |
273 ms |
17072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
365 ms |
18952 KB |
Output is correct |
2 |
Correct |
321 ms |
17268 KB |
Output is correct |
3 |
Correct |
247 ms |
16864 KB |
Output is correct |
4 |
Correct |
223 ms |
17100 KB |
Output is correct |
5 |
Correct |
228 ms |
17208 KB |
Output is correct |
6 |
Correct |
201 ms |
16912 KB |
Output is correct |
7 |
Correct |
172 ms |
16156 KB |
Output is correct |