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 += " " + groupMainPoint[j];
}
query += " " + i;
System.out.println((mid - a + 1) + query);
System.out.flush();
int currGroupCount = Integer.parseInt(reader.readLine());
if(currGroupCount == (mid - a + 1)){
b = mid;
} else {
a = mid + 1;
}
}
groups[i] = a;
}
prev = newGroups;
}
String ans = "0";
for(int i = 1; i <= N; i++){
ans += " " + groups[i];
}
System.out.println(ans);
System.out.flush();
return;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
264 ms |
13724 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
261 ms |
13568 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
250 ms |
12316 KB |
Output is correct |
2 |
Runtime error |
272 ms |
13708 KB |
Execution failed because the return code was nonzero |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
269 ms |
13680 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
278 ms |
13692 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |