結果

問題 No.479 頂点は要らない
ユーザー walkrewalkre
提出日時 2017-01-28 01:33:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 47 ms / 1,500 ms
コード長 1,703 bytes
コンパイル時間 1,415 ms
コンパイル使用メモリ 174,568 KB
実行使用メモリ 9,952 KB
最終ジャッジ日時 2023-08-25 12:32:25
合計ジャッジ時間 3,634 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 0 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 47 ms
9,524 KB
testcase_27 AC 46 ms
9,520 KB
testcase_28 AC 32 ms
9,952 KB
testcase_29 AC 34 ms
6,776 KB
testcase_30 AC 33 ms
6,664 KB
testcase_31 AC 33 ms
6,756 KB
testcase_32 AC 31 ms
6,728 KB
testcase_33 AC 32 ms
6,956 KB
testcase_34 AC 35 ms
7,084 KB
testcase_35 AC 27 ms
5,460 KB
testcase_36 AC 14 ms
4,460 KB
testcase_37 AC 37 ms
7,368 KB
testcase_38 AC 30 ms
6,484 KB
testcase_39 AC 23 ms
6,032 KB
testcase_40 AC 29 ms
7,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> graph(n);
    rep(i,0,m){
        int a,b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    vector<bool> used(n);
    priority_queue<int,vector<int>> que;
    int count=0;
    rep(i,0,n) que.push(i);
    while(count<m){
        auto u=que.top();
        que.pop();
        if(used[u]) continue;
        
        vector<int> vs;
        for(auto v:graph[u]){
            if(used[v]) continue;
            vs.push_back(v);
        }
        
        for(int v:vs){
            used[v]=true;
            for(auto w:graph[v]){
                if(used[w]) continue;
               ++count; 
            }
        }
    }

    vector<int> ans(n);
    rep(i,0,n){
        if(used[i]) ans[i]=1;
        else ans[i]=0;
    }
    for(int i=n-1; i>=0; --i){
        if(ans[i]){
            for(int j=i; j>=0; --j) cout << ans[j];
            cout << endl;
            return;
        }
    }
    cout << 0 << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}
0