結果

問題 No.479 頂点は要らない
コンテスト
ユーザー izuru_matsuura
提出日時 2017-04-11 18:07:20
言語 D
(dmd 2.112.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
AC  
実行時間 138 ms / 1,500 ms
コード長 1,432 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,235 ms
コンパイル使用メモリ 124,564 KB
実行使用メモリ 8,012 KB
最終ジャッジ日時 2026-03-05 14:18:33
合計ジャッジ時間 4,459 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void log(A...)(A arg) { stderr.writeln(arg); }
int size(T)(in T s) { return cast(int)s.length; }

void main() {
    int N, M; readf("%d %d\n", &N, &M);
    auto G = new int[][N];
    int R = M; // remainings;
    foreach (int i; 0 .. M) {
        int a, b; readf("%d %d\n", &a, &b);
        G[a] ~= i;
        G[b] ~= i;
    }
    auto count = new int[M];
    auto ans = new bool[N]; ans[] = true;
    foreach (int i; 0 .. N) {
        foreach (edgeid; G[i]) {
            count[edgeid]++;
        }
    }
    foreach_reverse (int i; 0 .. N) {
        foreach (edgeid; G[i]) {
            count[edgeid]--;
        }
        bool C() {
            foreach (edgeid; G[i]) {
                if (count[edgeid] <= 0) {
                    return false;
                }
            }
            return true;
        }
        if (C()) {
            ans[i] = false;
        } else {
            foreach (edgeid; G[i]) {
                count[edgeid]++;
            }
        }
    }
    ans.reverse;
    bool first = true;
    foreach (x; ans) {
        if (x == false) {
            if (first) continue;
            write(0);
        } else {
            first = false;
            write(1);
        }
    }
    writeln();
}
0