結果

問題 No.479 頂点は要らない
ユーザー tentententen
提出日時 2021-11-11 18:50:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 837 ms / 1,500 ms
コード長 2,080 bytes
コンパイル時間 2,697 ms
コンパイル使用メモリ 75,236 KB
実行使用メモリ 99,792 KB
最終ジャッジ日時 2023-08-15 02:32:18
合計ジャッジ時間 15,155 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,780 KB
testcase_01 AC 44 ms
49,440 KB
testcase_02 AC 43 ms
49,284 KB
testcase_03 AC 44 ms
49,152 KB
testcase_04 AC 43 ms
49,320 KB
testcase_05 AC 43 ms
49,276 KB
testcase_06 AC 44 ms
49,576 KB
testcase_07 AC 44 ms
49,248 KB
testcase_08 AC 44 ms
49,308 KB
testcase_09 AC 44 ms
49,700 KB
testcase_10 AC 44 ms
49,308 KB
testcase_11 AC 44 ms
49,464 KB
testcase_12 AC 45 ms
49,164 KB
testcase_13 AC 45 ms
49,784 KB
testcase_14 AC 45 ms
49,800 KB
testcase_15 AC 44 ms
49,460 KB
testcase_16 AC 45 ms
49,304 KB
testcase_17 AC 44 ms
49,772 KB
testcase_18 AC 45 ms
49,840 KB
testcase_19 AC 78 ms
50,576 KB
testcase_20 AC 82 ms
51,584 KB
testcase_21 AC 83 ms
50,556 KB
testcase_22 AC 91 ms
51,248 KB
testcase_23 AC 88 ms
51,572 KB
testcase_24 AC 88 ms
50,304 KB
testcase_25 AC 85 ms
51,536 KB
testcase_26 AC 835 ms
94,252 KB
testcase_27 AC 837 ms
93,920 KB
testcase_28 AC 603 ms
99,792 KB
testcase_29 AC 430 ms
77,316 KB
testcase_30 AC 424 ms
77,352 KB
testcase_31 AC 425 ms
79,352 KB
testcase_32 AC 430 ms
77,660 KB
testcase_33 AC 605 ms
78,792 KB
testcase_34 AC 650 ms
78,496 KB
testcase_35 AC 612 ms
75,160 KB
testcase_36 AC 419 ms
65,892 KB
testcase_37 AC 625 ms
78,424 KB
testcase_38 AC 572 ms
76,556 KB
testcase_39 AC 434 ms
72,228 KB
testcase_40 AC 532 ms
77,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int m = sc.nextInt();
        ArrayList<HashSet<Integer>> graph = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            graph.add(new HashSet<>());
        }
        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);
        }
        boolean[] delete = new boolean[n];
        for (int i = n - 1; i >= 0; i--) {
            if (delete[i]) {
                for (int x : graph.get(i)) {
                    graph.get(x).remove(i);
                }
            } else {
                for (int x : graph.get(i)) {
                    delete[x] = true;
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        boolean isFirst = true;
        for (int i = n - 1; i >= 0; i--) {
            if (delete[i]) {
                sb.append("1");
                isFirst = false;
            } else {
                if (!isFirst) {
                    sb.append("0");
                }
            }
        }
        System.out.println(sb);
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String nextLine() throws Exception {
        return br.readLine();
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0