• 문제 링크
https://www.acmicpc.net/problem/11645
• 풀이 코드
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.HashSet;
import java.util.Set;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringBuilder sb = new StringBuilder();
Set<String> set = new HashSet<>();
int t = Integer.parseInt(br.readLine());
while (t-- > 0) {
int n = Integer.parseInt(br.readLine());
while (n-- > 0) set.add(br.readLine());
sb.append(set.size()).append("\n");
set.clear();
}
bw.write(sb.toString());
bw.flush();
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 1057 토너먼트 - Brute Force / Java (0) | 2025.02.10 |
---|---|
[백준] 33241 Ducks and Sharks - Data Structure / Java (0) | 2025.02.09 |
[백준] 29813 최애의 팀원 - Data Structure / Java (0) | 2025.02.07 |
[백준] 17503 맥주 축제 - Data Structure / Java (0) | 2025.02.06 |
[백준] 30614 Port Robot - Data Structure / Java (0) | 2025.02.05 |
댓글