結果

問題 No.479 頂点は要らない
ユーザー hiyokko2hiyokko2
提出日時 2017-08-06 16:46:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 71 ms / 1,500 ms
コード長 1,351 bytes
コンパイル時間 1,391 ms
コンパイル使用メモリ 165,792 KB
実行使用メモリ 9,344 KB
最終ジャッジ日時 2024-04-20 03:51:23
合計ジャッジ時間 3,887 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 1 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 1 ms
6,948 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 1 ms
6,944 KB
testcase_25 AC 1 ms
6,940 KB
testcase_26 AC 71 ms
8,832 KB
testcase_27 AC 71 ms
8,576 KB
testcase_28 AC 63 ms
9,344 KB
testcase_29 AC 63 ms
7,040 KB
testcase_30 AC 66 ms
7,168 KB
testcase_31 AC 62 ms
7,040 KB
testcase_32 AC 62 ms
7,168 KB
testcase_33 AC 57 ms
7,296 KB
testcase_34 AC 68 ms
7,552 KB
testcase_35 AC 60 ms
6,944 KB
testcase_36 AC 32 ms
6,944 KB
testcase_37 AC 60 ms
7,680 KB
testcase_38 AC 53 ms
6,944 KB
testcase_39 AC 36 ms
6,944 KB
testcase_40 AC 45 ms
7,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
const int INF = 1e9;

class UndirectedGraph
{
public:
    size_t n;
    vector<vector<int>> vertex_to;

    UndirectedGraph(size_t n) : n(n), vertex_to(n) {}

    void connect(int from, int to)
    {
        vertex_to[from].emplace_back(to);
        vertex_to[to].emplace_back(from);
    }

    vector<int>& operator[](int v)
    {
        return vertex_to[v];
    }

    void resize(size_t _n)
    {
        n = _n;
        vertex_to.resize(_n);
    }

    size_t degree(int v)
    {
        return vertex_to[v].size();
    }
};

signed main()
{
    int n, m;
    int a, b;

    cin >> n >> m;

    UndirectedGraph graph(n);
    vector<bool> deleted(n, false);

    REP(i,m) {
        cin >> a >> b;
        graph.connect(a, b);
    }

    for (int i=n-1; 0<=i; i--) {
        for (int to : graph.vertex_to[i]) {
            if (i < to && !deleted[to]) {
                deleted[i] = true;
                break;
            }
        }
    }

    bool zero = false;
    for (int i=n-1; 0<=i; i--) {
        if (!zero && deleted[i]) zero = true;
        if (zero || deleted[i]) cout << (deleted[i] & 1);
    }
    cout << endl;
}
0