# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
346783 |
2021-01-11T02:39:35 Z |
vijay |
Carnival (CEOI14_carnival) |
Java 11 |
|
477 ms |
13944 KB |
import java.io.*;
import java.util.*;
public class carnival {
public static void main(String[] args) throws IOException, FileNotFoundException {
// BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(new File("carnival.in"))));
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(reader.readLine());
int[] groups = new int[N + 1];
groups[1] = 1;
int groupCount = 1;
int[] groupMainPoint = new int[N + 1];
groupMainPoint[groupCount] = 1;
String startQuery = "1";
int prev = 1;
for(int i = 2; i <= N; i++){
startQuery += " " + String.valueOf(i);
System.out.println(i + " " + startQuery);
System.out.flush();
int newGroups = Integer.parseInt(reader.readLine());
if(newGroups != prev){
groupCount++;
groups[i] = groupCount;
groupMainPoint[groupCount] = i;
} else {
int a = 1;
int b = groupCount;
while(a != b){
int mid = (a + b) / 2;
String query = "";
for (int j = a; j <= mid; j++){
query += " " + String.valueOf(groupMainPoint[j]);
}
query += " " + i;
System.out.println(String.valueOf(mid - a + 2) + query);
System.out.flush();
int currGroupCount = Integer.parseInt(reader.readLine());
if(currGroupCount == (mid - a + 2)){
a = mid + 1;
} else {
b = mid;
}
// b = 1;
}
groups[i] = a;
}
prev = newGroups;
}
String ans = "0";
for(int i = 1; i <= N; i++){
ans += " " + String.valueOf(groups[i]);
}
System.out.println(ans);
System.out.flush();
return;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
421 ms |
13692 KB |
Output is correct |
2 |
Correct |
446 ms |
13864 KB |
Output is correct |
3 |
Correct |
396 ms |
13780 KB |
Output is correct |
4 |
Correct |
381 ms |
13668 KB |
Output is correct |
5 |
Correct |
365 ms |
13800 KB |
Output is correct |
6 |
Correct |
348 ms |
13820 KB |
Output is correct |
7 |
Correct |
419 ms |
13868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
372 ms |
13732 KB |
Output is correct |
2 |
Correct |
423 ms |
13736 KB |
Output is correct |
3 |
Correct |
364 ms |
13848 KB |
Output is correct |
4 |
Correct |
349 ms |
13812 KB |
Output is correct |
5 |
Correct |
378 ms |
13828 KB |
Output is correct |
6 |
Correct |
388 ms |
13740 KB |
Output is correct |
7 |
Correct |
439 ms |
13664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
261 ms |
11888 KB |
Output is correct |
2 |
Correct |
424 ms |
13632 KB |
Output is correct |
3 |
Correct |
477 ms |
13944 KB |
Output is correct |
4 |
Correct |
352 ms |
13660 KB |
Output is correct |
5 |
Correct |
390 ms |
13632 KB |
Output is correct |
6 |
Correct |
391 ms |
13648 KB |
Output is correct |
7 |
Correct |
406 ms |
13804 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
398 ms |
13804 KB |
Output is correct |
2 |
Correct |
372 ms |
13804 KB |
Output is correct |
3 |
Correct |
405 ms |
13764 KB |
Output is correct |
4 |
Correct |
358 ms |
13788 KB |
Output is correct |
5 |
Correct |
422 ms |
13824 KB |
Output is correct |
6 |
Correct |
389 ms |
13668 KB |
Output is correct |
7 |
Correct |
453 ms |
13608 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
345 ms |
13648 KB |
Output is correct |
2 |
Correct |
410 ms |
13696 KB |
Output is correct |
3 |
Correct |
410 ms |
13580 KB |
Output is correct |
4 |
Correct |
435 ms |
13652 KB |
Output is correct |
5 |
Correct |
401 ms |
13688 KB |
Output is correct |
6 |
Correct |
384 ms |
13912 KB |
Output is correct |
7 |
Correct |
345 ms |
13852 KB |
Output is correct |