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{
ASTDIO io = new ASTDIO();
int n = io.nextInt();
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);
if ((io.nextInt() == 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];
for(Integer i: components){
for(Integer j: sets.get(i)){
result[j] = i;
}
}
for(int i: result){
io.print(i + " ");
}
io.println();
io.close();
}
}
/**
* Modified fork of KATTIO
*/
class ASTDIO extends PrintWriter{
private BufferedReader br;
private StringTokenizer st = new StringTokenizer("");
private String line;
public ASTDIO(){
super(new BufferedOutputStream(System.out));
br = new BufferedReader(new InputStreamReader(System.in));
}
public ASTDIO(String problemName)throws IOException{
super(new File(problemName + ".out"));
br = new BufferedReader(new FileReader(problemName + ".in"));
}
// use these 2 if blank lines can occur in the input, and replace all uses of next() with nextToken()
// private String token;
// private String peekToken() {
// if (token == null)
// try {
// while (st == null || !st.hasMoreTokens()) {
// line = br.readLine();
// if (line == null) return null;
// st = new StringTokenizer(line);
// }
// token = st.nextToken();
// } catch (IOException e) { }
// return token;
// }
// private String nextToken() {
// String ans = peekToken();
// token = null;
// return ans;
// }
/**
* PRECONDITION: all input lines are consecutive, so the nextLine should always have some data
*/
public String next() {
if (!st.hasMoreTokens()){
try {
line = br.readLine();
} catch (IOException e) {;}
if(line==null){return null;}
}
st = new StringTokenizer(line);
return st.nextToken();
}
public int nextInt(){ return Integer.parseInt(next()); }
public double nextDouble(){ return Double.parseDouble(next()); }
public long nextLong(){return Long.parseLong(next());}
public void close(){
super.close();
try{
br.close();
} catch(Exception e){ ; }
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
215 ms |
11536 KB |
Integer 19 violates the range [1, 11] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
188 ms |
10860 KB |
Integer 6 violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
149 ms |
10652 KB |
Output is correct |
2 |
Incorrect |
188 ms |
10800 KB |
Integer 11 violates the range [1, 8] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
167 ms |
10888 KB |
Integer 5 violates the range [1, 4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
150 ms |
10856 KB |
Output is correct |
2 |
Incorrect |
268 ms |
11456 KB |
Integer 20 violates the range [1, 17] |
3 |
Halted |
0 ms |
0 KB |
- |