結果
問題 |
No.938 賢人を探せ
|
ユーザー |
![]() |
提出日時 | 2019-12-09 11:43:38 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 406 ms / 2,000 ms |
コード長 | 767 bytes |
コンパイル時間 | 2,759 ms |
コンパイル使用メモリ | 76,044 KB |
実行使用メモリ | 50,660 KB |
最終ジャッジ日時 | 2024-12-14 11:50:50 |
合計ジャッジ時間 | 9,837 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ArrayList<String> allList = new ArrayList<>(); HashSet<String> outSet = new HashSet<>(); for (int i = 0; i < n; i++) { String a = sc.next(); String b = sc.next(); allList.add(b); outSet.add(a); } StringBuilder sb = new StringBuilder(); HashSet<String> putSet = new HashSet<>(); for (String s : allList) { if (!outSet.contains(s) && !putSet.contains(s)) { sb.append(s).append("\n"); putSet.add(s); } } System.out.print(sb); } }