이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
import java.util.*;
import java.io.*;
public class carnival {
private static ArrayList<Integer> components;
private static HashMap<Integer, ArrayList<Integer>> sets;
public static void main(String[] args) throws IOException {
new carnival();
}
public carnival() throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
sets = new HashMap<>();
components = new ArrayList<>();
components.add(1);
sets.put(1, new ArrayList<>());
sets.get(1).add(1);
for(int i = 2; i <= n; i++){
boolean added = false;
for(Integer val: components){
System.out.println("2 " + i + " " + val);
st = new StringTokenizer(br.readLine());
if ((Integer.parseInt(st.nextToken()) == 1)){
sets.get(val).add(i);
added=true;
break;
}
}
if (!added){
sets.put(i, new ArrayList<>());
sets.get(i).add(i);
components.add(i);
}
}
int[] result = new int[n+1];
int m = 1;
for(Integer i: components){
for(Integer j: sets.get(i)){
result[j] = m;
} m++;
}
for(int i: result){
System.out.print(i + " ");
}
System.out.println();
}
}
# | 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... |