이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
import java.io.*;
import java.util.*;
public class carnival {
static int n;
public static void main(String[] args) throws IOException{
BufferedReader file = new BufferedReader(new InputStreamReader(System.in));
n = Integer.parseInt(file.readLine());
int[] ans = new int[n];
int g = 1;
for (int i=0; i<n; i++){
for (int j=i+1; j<n; j++){
if (get(new int[] {i+1, j+1}) == 1){
if (ans[i] != 0){
ans[j] = ans[i];
}else if (ans[j] != 0){
ans[i] = ans[j];
}else{
ans[i] = g;
ans[j] = g;
g++;
}
}
}
}
System.out.print("0");
for (int i : ans){
System.out.print(" " + i);
}
}
public static int get(int[] arr) throws IOException{
BufferedReader file = new BufferedReader(new InputStreamReader(System.in));
System.out.print(arr.length);
for (int i=0; i<arr.length; i++){
System.out.print(" " + arr[i]);
}
System.out.flush();
return Integer.parseInt(file.readLine());
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |