# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
346781 |
2021-01-11T02:29:05 Z |
vijay |
Carnival (CEOI14_carnival) |
Java 11 |
|
1000 ms |
15184 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)){
b = mid;
} else {
a = mid + 1;
}
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 |
Runtime error |
335 ms |
13776 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
296 ms |
13564 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
215 ms |
11984 KB |
Output is correct |
2 |
Execution timed out |
1183 ms |
15184 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1216 ms |
15096 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1173 ms |
14940 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |