結果
問題 |
No.3196 Unique Nickname
|
ユーザー |
|
提出日時 | 2025-07-11 21:31:33 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 61 ms / 2,000 ms |
コード長 | 2,005 bytes |
コンパイル時間 | 3,317 ms |
コンパイル使用メモリ | 80,276 KB |
実行使用メモリ | 39,660 KB |
最終ジャッジ日時 | 2025-07-11 21:31:38 |
合計ジャッジ時間 | 4,676 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
import java.io.*; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { int n = sc.nextInt(); String[][] s = new String[n][2]; for (int i = 0; i < n; i++) { for (int j = 0; j < 2; j++) { s[i][j] = sc.next(); } } boolean ok = true; for (int i = 0; i < n; i++) { int c = 0; for (int j = 0; j < 2; j++) { o: for (int k = 0; k < n; k++) { if (i == k) continue; for (int l = 0; l < 2; l++) { if (s[i][j].equals(s[k][l])) { c++; break o; } } } } if (c == 2) { ok = false; break; } } out.println(ok ? "Yes" : "No"); out.close(); } static Kattio sc = new Kattio(); static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); static class Kattio { static BufferedReader r; static StringTokenizer st; public Kattio() { r = new BufferedReader(new InputStreamReader(System.in)); } public String next() { try { while (st == null || !st.hasMoreTokens()) { st = new StringTokenizer(r.readLine()); } return st.nextToken(); } catch (Exception e) { return null; } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } } }