結果

問題 No.479 頂点は要らない
ユーザー 37zigen37zigen
提出日時 2017-01-28 01:13:01
言語 Java19
(openjdk 21)
結果
AC  
実行時間 1,256 ms / 1,500 ms
コード長 1,010 bytes
コンパイル時間 3,670 ms
コンパイル使用メモリ 76,972 KB
実行使用メモリ 84,620 KB
最終ジャッジ日時 2023-08-25 11:47:24
合計ジャッジ時間 23,902 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,796 KB
testcase_01 AC 119 ms
56,004 KB
testcase_02 AC 122 ms
55,752 KB
testcase_03 AC 119 ms
55,932 KB
testcase_04 AC 117 ms
56,088 KB
testcase_05 AC 120 ms
55,516 KB
testcase_06 AC 117 ms
55,632 KB
testcase_07 AC 120 ms
56,264 KB
testcase_08 AC 122 ms
55,692 KB
testcase_09 AC 120 ms
56,244 KB
testcase_10 AC 119 ms
55,712 KB
testcase_11 AC 119 ms
55,968 KB
testcase_12 AC 119 ms
56,324 KB
testcase_13 AC 119 ms
56,444 KB
testcase_14 AC 121 ms
55,744 KB
testcase_15 AC 123 ms
55,756 KB
testcase_16 AC 120 ms
55,692 KB
testcase_17 AC 122 ms
56,088 KB
testcase_18 AC 124 ms
56,208 KB
testcase_19 AC 223 ms
59,484 KB
testcase_20 AC 226 ms
59,092 KB
testcase_21 AC 188 ms
58,880 KB
testcase_22 AC 221 ms
59,320 KB
testcase_23 AC 211 ms
58,768 KB
testcase_24 AC 201 ms
58,936 KB
testcase_25 AC 212 ms
58,988 KB
testcase_26 AC 1,256 ms
83,960 KB
testcase_27 AC 1,255 ms
82,332 KB
testcase_28 AC 1,197 ms
84,620 KB
testcase_29 AC 983 ms
73,588 KB
testcase_30 AC 977 ms
72,212 KB
testcase_31 AC 957 ms
72,056 KB
testcase_32 AC 1,056 ms
71,824 KB
testcase_33 AC 1,078 ms
75,224 KB
testcase_34 AC 1,098 ms
73,268 KB
testcase_35 AC 934 ms
70,848 KB
testcase_36 AC 709 ms
67,340 KB
testcase_37 AC 1,161 ms
75,836 KB
testcase_38 AC 996 ms
73,508 KB
testcase_39 AC 878 ms
67,240 KB
testcase_40 AC 986 ms
73,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.util.concurrent.SynchronousQueue;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		ArrayList<Integer>[] g = new ArrayList[n];
		for (int i = 0; i < n; ++i)
			g[i] = new ArrayList<>();
		int[] a = new int[m];
		int[] b = new int[m];
		boolean[] used = new boolean[n];
		for (int i = 0; i < m; ++i) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			g[a[i]].add(b[i]);
			g[b[i]].add(a[i]);
		}
		for (int i = n - 1; i >= 0; --i) {
			boolean f = true;
			for (int dst : g[i]) {
				if (dst > i && !used[dst]) {
					f = false;
					break;
				}
			}
			if (!f) {
				used[i] = true;
			}
		}
		boolean f = false;
		for (int i = n - 1; i >= 0; --i) {
			if (!f && !used[i])
				continue;
			else
				f = true;
			System.out.print(used[i] ? 1 : 0);
		}
		System.out.println();
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}
0