結果

問題 No.479 頂点は要らない
ユーザー face4face4
提出日時 2019-01-29 12:39:45
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 83 ms / 1,500 ms
コード長 707 bytes
コンパイル時間 796 ms
コンパイル使用メモリ 74,680 KB
実行使用メモリ 9,472 KB
最終ジャッジ日時 2024-04-17 19:41:51
合計ジャッジ時間 3,418 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 3 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 3 ms
6,940 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 82 ms
9,472 KB
testcase_27 AC 83 ms
9,124 KB
testcase_28 AC 70 ms
9,460 KB
testcase_29 AC 71 ms
6,944 KB
testcase_30 AC 70 ms
6,944 KB
testcase_31 AC 70 ms
6,940 KB
testcase_32 AC 71 ms
6,944 KB
testcase_33 AC 66 ms
6,944 KB
testcase_34 AC 72 ms
7,040 KB
testcase_35 AC 69 ms
6,940 KB
testcase_36 AC 38 ms
6,944 KB
testcase_37 AC 70 ms
7,552 KB
testcase_38 AC 58 ms
6,940 KB
testcase_39 AC 43 ms
6,940 KB
testcase_40 AC 51 ms
7,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;

    vector<int> v[n];
    int a, b;
    for(int i = 0; i < m; i++){
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    vector<bool> bought(n, 0);
    string res = "";
    for(int i = n-1; i >= 0; i--){
        bool buy = false;
        for(int to : v[i]){
            if(to > i && !bought[to])   buy = true;
        }
        if(buy){
            res += "1";
            bought[i] = true;
        }else{
            res += "0";
        }
    }

    int cur = 0;
    while(res[cur] == '0')  cur++;
    res = res.substr(cur);

    cout << res << endl;

    return 0;
}
0