• 문제 링크
3982번: Soccer Bets
The first line of the input is the number of test cases c (1 ≤ c ≤ 100). Each test case consists of 16 lines describing the matches in random order. A match description looks as follows: t1 t2 g1 g2. t1 and t2 are the names of teams (abbreviated as exa
www.acmicpc.net
• 풀이 코드
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
public class Main {
static Map<String, Boolean> map = new HashMap<>();
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();
int t = Integer.parseInt(br.readLine());
while (t-- > 0) {
for (int i = 0; i < 16; i++) {
StringTokenizer st = new StringTokenizer(br.readLine());
String a = st.nextToken(), b = st.nextToken();
if (Integer.parseInt(st.nextToken()) > Integer.parseInt(st.nextToken())) log(a, b);
else log(b, a);
}
for (String key : map.keySet()) {
if (map.get(key)) {
sb.append(key).append("\n");
break;
}
}
map.clear();
}
bw.write(sb.toString());
bw.flush();
}
private static void log(String w, String l) {
if (!map.containsKey(w)) map.put(w, true);
map.put(l, false);
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 26043 식당 메뉴 - Data Structure / Java (0) | 2023.11.07 |
---|---|
[백준] 14402 야근 - Data Structure / Java (0) | 2023.11.06 |
[백준] 18294 Biodiversity - Data Structure / Java (0) | 2023.11.04 |
[백준] 4881 자리수의 제곱 - Data Structure / Java (0) | 2023.11.03 |
[백준] 10105 Assigning Partners - Data Structure / Java (0) | 2023.11.02 |
댓글