백준

백준 26069 - Java

으엉어엉 2024. 9. 12. 14:21
728x90

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class ChongChong {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());

        Set<String> s = new HashSet<>();
        s.add("ChongChong");

        for (int i = 0; i < N; i++) {
            String[] meeting = br.readLine().split(" ");
            String A = meeting[0];
            String B = meeting[1];

            if (s.contains(A) || s.contains(B)) {
                s.add(A);
                s.add(B);
            }
        }

        System.out.println(s.size());
    }
}
728x90

'백준' 카테고리의 다른 글

백준 20920 - Java  (0) 2024.09.12
백준 2108 - Java  (0) 2024.09.12
백준 25192 - Java  (0) 2024.09.11
백준 1037 - Java  (0) 2024.09.11
백준 11050 - Java  (0) 2024.09.09