結果
問題 |
No.479 頂点は要らない
|
ユーザー |
![]() |
提出日時 | 2020-09-11 09:40:33 |
言語 | Java (openjdk 23) |
結果 |
RE
|
実行時間 | - |
コード長 | 888 bytes |
コンパイル時間 | 4,319 ms |
コンパイル使用メモリ | 86,332 KB |
実行使用メモリ | 84,788 KB |
最終ジャッジ日時 | 2024-12-25 04:22:03 |
合計ジャッジ時間 | 25,261 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 RE * 21 |
ソースコード
import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); ArrayList<TreeSet<Integer>> graph = new ArrayList<>(); for (int i = 0; i < n; i++) { graph.add(new TreeSet<>()); } for (int i = 0; i < m; i++) { int a = sc.nextInt(); int b = sc.nextInt(); graph.get(a).add(b); graph.get(b).add(a); } StringBuilder sb = new StringBuilder(); for (int i = n - 1; i >= 0; i--) { if (graph.get(i).last() > i) { sb.append("1"); for (int x : graph.get(i)) { graph.get(x).remove(i); } } else { if (sb.length() > 0) { sb.append("0"); } } } System.out.println(sb); } }