結果

問題 No.479 頂点は要らない
ユーザー uenokuuenoku
提出日時 2017-01-27 23:25:30
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 92 ms / 1,500 ms
コード長 1,696 bytes
コンパイル時間 796 ms
コンパイル使用メモリ 84,240 KB
実行使用メモリ 32,460 KB
最終ジャッジ日時 2023-08-25 10:33:30
合計ジャッジ時間 4,256 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
27,924 KB
testcase_01 AC 11 ms
27,928 KB
testcase_02 AC 12 ms
28,128 KB
testcase_03 AC 11 ms
28,116 KB
testcase_04 AC 12 ms
28,060 KB
testcase_05 AC 11 ms
28,048 KB
testcase_06 AC 11 ms
27,932 KB
testcase_07 AC 11 ms
27,936 KB
testcase_08 AC 11 ms
28,188 KB
testcase_09 AC 12 ms
27,988 KB
testcase_10 AC 12 ms
27,992 KB
testcase_11 AC 11 ms
27,908 KB
testcase_12 AC 11 ms
28,240 KB
testcase_13 AC 11 ms
28,200 KB
testcase_14 AC 12 ms
27,928 KB
testcase_15 AC 11 ms
28,244 KB
testcase_16 AC 12 ms
27,996 KB
testcase_17 AC 11 ms
27,924 KB
testcase_18 AC 11 ms
28,040 KB
testcase_19 AC 12 ms
28,256 KB
testcase_20 AC 12 ms
27,984 KB
testcase_21 AC 12 ms
28,092 KB
testcase_22 AC 12 ms
27,952 KB
testcase_23 AC 12 ms
28,044 KB
testcase_24 AC 12 ms
27,964 KB
testcase_25 AC 11 ms
28,024 KB
testcase_26 AC 92 ms
31,432 KB
testcase_27 AC 92 ms
31,564 KB
testcase_28 AC 79 ms
32,372 KB
testcase_29 AC 80 ms
32,144 KB
testcase_30 AC 80 ms
32,072 KB
testcase_31 AC 81 ms
32,124 KB
testcase_32 AC 80 ms
32,000 KB
testcase_33 AC 83 ms
31,864 KB
testcase_34 AC 87 ms
32,460 KB
testcase_35 AC 81 ms
32,268 KB
testcase_36 AC 48 ms
30,608 KB
testcase_37 AC 85 ms
32,008 KB
testcase_38 AC 73 ms
31,552 KB
testcase_39 AC 55 ms
30,488 KB
testcase_40 AC 63 ms
31,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long int lli;
lli MOD = 1000000007;
struct edge {
    int f, t, num;
};
int edge_flag[10000005] = {};
bool use[10000005] = {};
vector<edge> e[1000005];
int main()
{
    int n, m;
    cin >> n >> m;
    int a, b;
    rep(i, m)
    {
        cin >> a >> b;
        e[b].push_back(edge{b, a, i});
        e[a].push_back(edge{a, b, i});
    }
    rep(i, n)
    {
        bool flag = false;
        for (auto j : e[i]) {
            // if (i == 9) {
            //     cout << edge_flag[j.num] << ' ';
            // }
            if (!edge_flag[j.num]) {
                flag = true;
            }
        }
        if (flag) {
            for (auto j : e[i]) {
                edge_flag[j.num]++;
            }
        }
        use[i] = flag;
    }
    // rep(i, m)
    // {
    //     cout << edge_flag[i] << endl;
    // }
    rrep(i, n)
    {
        if (use[i]) {
            bool flag = false;
            for (auto j : e[i]) {
                if (edge_flag[j.num] == 1) {
                    flag = true;
                }
            }
            if (!flag) {
                for (auto j : e[i]) {
                    edge_flag[j.num]--;
                }
            }
            use[i] = flag;
        }
    }
    int in = 0;
    bool flag = false;
    rrep(i, n)
    {
        if (!flag) {
            flag = use[i];
        }
        if (flag) {
            cout << use[i];
        }
    }
    cout << endl;
}
0