結果

問題 No.479 頂点は要らない
ユーザー tentententen
提出日時 2020-09-11 09:47:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,316 ms / 1,500 ms
コード長 915 bytes
コンパイル時間 2,664 ms
コンパイル使用メモリ 76,156 KB
実行使用メモリ 92,724 KB
最終ジャッジ日時 2023-08-26 12:59:33
合計ジャッジ時間 25,456 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
53,572 KB
testcase_01 AC 126 ms
55,992 KB
testcase_02 AC 129 ms
55,880 KB
testcase_03 AC 129 ms
56,056 KB
testcase_04 AC 129 ms
56,168 KB
testcase_05 AC 128 ms
54,388 KB
testcase_06 AC 124 ms
56,048 KB
testcase_07 AC 125 ms
55,608 KB
testcase_08 AC 127 ms
55,724 KB
testcase_09 AC 127 ms
55,904 KB
testcase_10 AC 126 ms
55,900 KB
testcase_11 AC 127 ms
56,224 KB
testcase_12 AC 126 ms
56,024 KB
testcase_13 AC 129 ms
55,848 KB
testcase_14 AC 129 ms
55,836 KB
testcase_15 AC 131 ms
55,892 KB
testcase_16 AC 126 ms
55,752 KB
testcase_17 AC 131 ms
55,896 KB
testcase_18 AC 128 ms
56,032 KB
testcase_19 AC 213 ms
59,408 KB
testcase_20 AC 218 ms
59,792 KB
testcase_21 AC 212 ms
59,308 KB
testcase_22 AC 212 ms
59,676 KB
testcase_23 AC 215 ms
59,436 KB
testcase_24 AC 216 ms
59,648 KB
testcase_25 AC 210 ms
59,276 KB
testcase_26 AC 1,231 ms
90,432 KB
testcase_27 AC 1,208 ms
91,268 KB
testcase_28 AC 1,103 ms
92,724 KB
testcase_29 AC 915 ms
81,700 KB
testcase_30 AC 971 ms
81,904 KB
testcase_31 AC 955 ms
81,864 KB
testcase_32 AC 925 ms
81,568 KB
testcase_33 AC 1,184 ms
81,452 KB
testcase_34 AC 1,292 ms
82,480 KB
testcase_35 AC 1,316 ms
79,376 KB
testcase_36 AC 1,017 ms
71,356 KB
testcase_37 AC 1,207 ms
81,532 KB
testcase_38 AC 1,135 ms
79,048 KB
testcase_39 AC 885 ms
73,372 KB
testcase_40 AC 927 ms
79,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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).size() > 0 && 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);
	}
}
0