結果

問題 No.479 頂点は要らない
ユーザー koyoprokoyopro
提出日時 2020-01-12 01:32:46
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 85 ms / 1,500 ms
コード長 1,835 bytes
コンパイル時間 1,981 ms
コンパイル使用メモリ 153,976 KB
実行使用メモリ 20,124 KB
最終ジャッジ日時 2023-08-18 02:04:34
合計ジャッジ時間 5,218 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,676 KB
testcase_01 AC 3 ms
5,444 KB
testcase_02 AC 3 ms
5,480 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 3 ms
5,428 KB
testcase_05 AC 3 ms
5,636 KB
testcase_06 AC 3 ms
5,480 KB
testcase_07 AC 3 ms
5,692 KB
testcase_08 AC 3 ms
5,636 KB
testcase_09 AC 4 ms
5,684 KB
testcase_10 AC 4 ms
5,620 KB
testcase_11 AC 2 ms
5,496 KB
testcase_12 AC 3 ms
5,320 KB
testcase_13 AC 4 ms
5,560 KB
testcase_14 AC 3 ms
5,624 KB
testcase_15 AC 4 ms
5,380 KB
testcase_16 AC 3 ms
5,316 KB
testcase_17 AC 3 ms
5,532 KB
testcase_18 AC 3 ms
5,632 KB
testcase_19 AC 3 ms
5,860 KB
testcase_20 AC 3 ms
5,860 KB
testcase_21 AC 4 ms
5,476 KB
testcase_22 AC 3 ms
5,944 KB
testcase_23 AC 3 ms
6,056 KB
testcase_24 AC 4 ms
5,928 KB
testcase_25 AC 4 ms
5,712 KB
testcase_26 AC 83 ms
20,124 KB
testcase_27 AC 85 ms
19,964 KB
testcase_28 AC 53 ms
20,064 KB
testcase_29 AC 53 ms
19,504 KB
testcase_30 AC 54 ms
19,552 KB
testcase_31 AC 52 ms
19,716 KB
testcase_32 AC 53 ms
19,768 KB
testcase_33 AC 63 ms
17,604 KB
testcase_34 AC 71 ms
18,700 KB
testcase_35 AC 58 ms
18,816 KB
testcase_36 AC 31 ms
14,312 KB
testcase_37 AC 69 ms
17,896 KB
testcase_38 AC 56 ms
16,280 KB
testcase_39 AC 39 ms
13,300 KB
testcase_40 AC 49 ms
14,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define array2(type, x, y) array<array<type, y>, x>
#define vector2(type) vector<vector<type> >
#define out(...) printf(__VA_ARGS__)

int dxy[] = {0, 1, 0, -1, 0};

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/

int N,M,Q;

struct Edge {
    int src, to, w;
    Edge(int u, int v, int w): src(u), to(v), w(w) {};
};

vector< vector<Edge> > E(111111);

void add_edge(int u, int v, int w) {
    E[u].push_back(*new Edge(u,v,w));
    E[v].push_back(*new Edge(v,u,w));
}
/**********************************************************/

int ans[100001];

void solve() {
    cin>>N>>M;
    
    int a,b;
    REP(i,M) {
        cin>>a>>b;
        add_edge(a, b, 0);
    }
    
    priority_queue<int> que;
    REP(i,N) que.push(i);
    while(!que.empty()) {
        int p = que.top();
        que.pop();
        if (ans[p]) continue;
        for (auto e:E[p]) {
            ans[e.to]=1;
            for (auto it = E[e.to].begin(); it != E[e.to].end(); it++) {
                if (it->to == p) {
                    E[e.to].erase(it);
                    break;
                }
            }
        }
    }
    
    string s;
    RREP(i,N) {
        if (ans[i]) s += '1';
        else if (s.size()) s += '0';
    }
    
    cout << s << endl;
}
0