Submission #727501

# Submission time Handle Problem Language Result Execution time Memory
727501 2023-04-20T21:27:38 Z jnjwnwnw Carnival (CEOI14_carnival) Java 11
20 / 100
892 ms 14512 KB
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
1 Correct 205 ms 10956 KB Output is correct
2 Correct 330 ms 12304 KB Output is correct
3 Partially correct 682 ms 13832 KB Partially correct
4 Partially correct 726 ms 14244 KB Partially correct
5 Correct 154 ms 10848 KB Output is correct
6 Correct 142 ms 10528 KB Output is correct
7 Correct 283 ms 12272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 170 ms 10900 KB Output is correct
2 Correct 313 ms 12304 KB Output is correct
3 Partially correct 464 ms 12648 KB Partially correct
4 Partially correct 713 ms 14208 KB Partially correct
5 Correct 159 ms 10884 KB Output is correct
6 Correct 154 ms 10976 KB Output is correct
7 Correct 201 ms 10964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 141 ms 10852 KB Output is correct
2 Correct 184 ms 10692 KB Output is correct
3 Partially correct 476 ms 12736 KB Partially correct
4 Partially correct 890 ms 14512 KB Partially correct
5 Correct 187 ms 10680 KB Output is correct
6 Correct 204 ms 11036 KB Output is correct
7 Correct 348 ms 12472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 161 ms 11000 KB Output is correct
2 Correct 183 ms 10760 KB Output is correct
3 Partially correct 745 ms 14340 KB Partially correct
4 Partially correct 882 ms 14372 KB Partially correct
5 Correct 249 ms 11416 KB Output is correct
6 Correct 389 ms 12440 KB Output is correct
7 Correct 339 ms 12308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 159 ms 10920 KB Output is correct
2 Correct 258 ms 11328 KB Output is correct
3 Partially correct 647 ms 13924 KB Partially correct
4 Partially correct 722 ms 13772 KB Partially correct
5 Correct 410 ms 12492 KB Output is correct
6 Partially correct 670 ms 13924 KB Partially correct
7 Partially correct 892 ms 14460 KB Partially correct