結果

問題 No.479 頂点は要らない
ユーザー tentententen
提出日時 2020-09-11 09:40:33
言語 Java19
(openjdk 21)
結果
RE  
実行時間 -
コード長 888 bytes
コンパイル時間 3,953 ms
コンパイル使用メモリ 75,768 KB
実行使用メモリ 92,300 KB
最終ジャッジ日時 2023-08-26 09:46:57
合計ジャッジ時間 21,993 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
55,960 KB
testcase_01 AC 115 ms
58,372 KB
testcase_02 AC 113 ms
56,284 KB
testcase_03 AC 111 ms
55,716 KB
testcase_04 RE -
testcase_05 AC 116 ms
56,476 KB
testcase_06 AC 112 ms
56,276 KB
testcase_07 AC 115 ms
56,276 KB
testcase_08 AC 110 ms
56,304 KB
testcase_09 AC 113 ms
56,288 KB
testcase_10 AC 110 ms
56,184 KB
testcase_11 AC 111 ms
55,864 KB
testcase_12 RE -
testcase_13 AC 120 ms
55,916 KB
testcase_14 AC 116 ms
56,064 KB
testcase_15 AC 118 ms
56,012 KB
testcase_16 AC 109 ms
55,760 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 192 ms
59,336 KB
testcase_22 AC 191 ms
59,668 KB
testcase_23 AC 191 ms
59,560 KB
testcase_24 AC 199 ms
59,416 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 993 ms
90,964 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
権限があれば一括ダウンロードができます

ソースコード

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).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