結果

問題 No.479 頂点は要らない
ユーザー ShibuyapShibuyap
提出日時 2020-08-03 03:16:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 107 ms / 1,500 ms
コード長 1,244 bytes
コンパイル時間 2,172 ms
コンパイル使用メモリ 207,268 KB
実行使用メモリ 12,980 KB
最終ジャッジ日時 2023-09-28 21:06:43
合計ジャッジ時間 6,550 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,056 KB
testcase_01 AC 4 ms
7,980 KB
testcase_02 AC 3 ms
8,220 KB
testcase_03 AC 4 ms
8,092 KB
testcase_04 AC 3 ms
8,152 KB
testcase_05 AC 4 ms
8,064 KB
testcase_06 AC 3 ms
7,980 KB
testcase_07 AC 4 ms
7,988 KB
testcase_08 AC 4 ms
8,092 KB
testcase_09 AC 3 ms
8,108 KB
testcase_10 AC 4 ms
7,988 KB
testcase_11 AC 3 ms
8,048 KB
testcase_12 AC 4 ms
8,064 KB
testcase_13 AC 3 ms
8,148 KB
testcase_14 AC 4 ms
8,328 KB
testcase_15 AC 4 ms
8,056 KB
testcase_16 AC 4 ms
8,036 KB
testcase_17 AC 4 ms
7,984 KB
testcase_18 AC 4 ms
7,984 KB
testcase_19 AC 4 ms
8,072 KB
testcase_20 AC 5 ms
8,388 KB
testcase_21 AC 4 ms
8,196 KB
testcase_22 AC 5 ms
8,132 KB
testcase_23 AC 5 ms
8,096 KB
testcase_24 AC 4 ms
8,368 KB
testcase_25 AC 5 ms
8,072 KB
testcase_26 AC 107 ms
11,952 KB
testcase_27 AC 107 ms
11,956 KB
testcase_28 AC 76 ms
12,980 KB
testcase_29 AC 73 ms
11,348 KB
testcase_30 AC 74 ms
11,408 KB
testcase_31 AC 73 ms
11,348 KB
testcase_32 AC 73 ms
11,352 KB
testcase_33 AC 84 ms
11,596 KB
testcase_34 AC 96 ms
11,936 KB
testcase_35 AC 76 ms
11,276 KB
testcase_36 AC 40 ms
10,208 KB
testcase_37 AC 91 ms
11,768 KB
testcase_38 AC 75 ms
11,168 KB
testcase_39 AC 54 ms
10,448 KB
testcase_40 AC 68 ms
11,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

vector<P> G[MAX_N];

int ans[MAX_N];
int use[MAX_N];

int main() {
    int n, m;
    cin >> n >> m;
    rep(i,m){
        int a, b;
        cin >> a >> b;
        G[a].push_back(P(b,i));
        G[b].push_back(P(a,i));
    }
    drep(i,n){
        queue<int> que;
        rep(j,G[i].size()){
            if(use[G[i][j].second] == 0){
                use[G[i][j].second] = 1;
                if(ans[G[i][j].first] == 1) continue;
                que.push(G[i][j].first);
                ans[G[i][j].first] = 1;
            }
        }
        while(que.size() > 0){
            int x = que.front();
            que.pop();
            rep(j,G[x].size()){
                use[G[x][j].second] = 1;
            }
        }
    }
    int flag = 0;
    drep(i,n){
        if(ans[i] == 1){
            flag = 1;
            cout << ans[i];
        }else if(flag){
            cout << ans[i];
        }
    }
    cout << endl;
    return 0;
}
 
 
0