結果
問題 | No.479 頂点は要らない |
ユーザー |
![]() |
提出日時 | 2017-01-27 22:45:12 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 1,003 ms / 1,500 ms |
コード長 | 1,106 bytes |
コンパイル時間 | 4,962 ms |
コンパイル使用メモリ | 79,988 KB |
実行使用メモリ | 65,304 KB |
最終ジャッジ日時 | 2024-12-23 16:31:01 |
合計ジャッジ時間 | 23,100 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
import java.io.BufferedInputStream;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.*;public class _479 {public static void main(String[] args) throws IOException {new _479().solve();}void solve() throws IOException {try (final Scanner in = new Scanner(System.in)) {int n = in.nextInt();int m = in.nextInt();List<Integer>[] g = new List[n];for (int i = 0; i < n; i++) g[i] = new ArrayList<>();int[] cnt = new int[n];for (int i = 0; i < m; i++) {int a = in.nextInt();int b = in.nextInt();cnt[a < b ? a : b]++;if (a < b) g[b].add(a);else g[a].add(b);}char[] cs = new char[n];Arrays.fill(cs, '0');for (int i = n-1; i >= 0; i--) if (cnt[i] != 0) {for (int t : g[i]) cnt[t]--;cs[n-1-i] = '1';}for (int i = 0; i < n; i++) {if (cs[i] != '0' || i == n - 1) {System.out.println(new String(cs, i, cs.length - i));return;}}}}// for debugstatic void dump(Object... o) {System.err.println(Arrays.deepToString(o));}}