結果

問題 No.479 頂点は要らない
ユーザー rapurasurapurasu
提出日時 2017-03-10 15:47:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 107 ms / 1,500 ms
コード長 1,419 bytes
コンパイル時間 1,484 ms
コンパイル使用メモリ 147,188 KB
実行使用メモリ 14,848 KB
最終ジャッジ日時 2023-09-06 13:16:36
合計ジャッジ時間 4,503 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,332 KB
testcase_01 AC 5 ms
8,304 KB
testcase_02 AC 4 ms
8,212 KB
testcase_03 AC 5 ms
8,320 KB
testcase_04 AC 5 ms
8,256 KB
testcase_05 AC 5 ms
8,280 KB
testcase_06 AC 5 ms
8,276 KB
testcase_07 AC 5 ms
8,256 KB
testcase_08 AC 5 ms
8,256 KB
testcase_09 AC 5 ms
8,208 KB
testcase_10 AC 4 ms
8,236 KB
testcase_11 AC 5 ms
8,308 KB
testcase_12 AC 4 ms
8,212 KB
testcase_13 AC 5 ms
8,208 KB
testcase_14 AC 5 ms
8,276 KB
testcase_15 AC 5 ms
8,244 KB
testcase_16 AC 4 ms
8,348 KB
testcase_17 AC 5 ms
8,248 KB
testcase_18 AC 4 ms
8,368 KB
testcase_19 AC 5 ms
8,272 KB
testcase_20 AC 6 ms
8,352 KB
testcase_21 AC 5 ms
8,468 KB
testcase_22 AC 6 ms
8,492 KB
testcase_23 AC 5 ms
8,304 KB
testcase_24 AC 6 ms
8,272 KB
testcase_25 AC 6 ms
8,312 KB
testcase_26 AC 107 ms
14,444 KB
testcase_27 AC 104 ms
14,500 KB
testcase_28 AC 79 ms
14,848 KB
testcase_29 AC 76 ms
11,936 KB
testcase_30 AC 77 ms
11,896 KB
testcase_31 AC 75 ms
12,152 KB
testcase_32 AC 80 ms
12,088 KB
testcase_33 AC 74 ms
12,376 KB
testcase_34 AC 83 ms
12,604 KB
testcase_35 AC 66 ms
11,336 KB
testcase_36 AC 38 ms
10,048 KB
testcase_37 AC 81 ms
12,672 KB
testcase_38 AC 68 ms
12,040 KB
testcase_39 AC 48 ms
11,180 KB
testcase_40 AC 59 ms
12,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

 #include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int N;
int M;
vector<int>G[100001];//辺の相手
vector<int>num[100001];//辺番号
bool used[100001];
bool in[100001];
int main(){
    cin>>N>>M;
    REP(i,M){
        int a,b;
        cin>>a>>b;
        G[a].push_back(b);
        num[a].push_back(i);
        G[b].push_back(a);
        num[b].push_back(i);
    }
    REP(i,100001){
        used[i]=false;
        in[i]=false;
    }
    REP(i,N){
        bool check=false;
        REP(j,G[i].size()){
            if(used[num[i][j]]==false){
               used[num[i][j]]=true;
               check=true;
            }
        }
        if(check){
            in[i]=true;
        }
    }
    for(int i=N-1;i>=0;i--){
        bool check=false;
        REP(j,G[i].size()){
            if(used[num[i][j]]==false){
               check=true;
            }
            if(in[G[i][j]]==false){
               check=true;
            }
        }
        if(check==false){
            in[i]=false;
            REP(j,G[i].size()){
                used[num[i][j]]=false;
            }
        }
    }
    bool check=false;
    for(int i=N-1;i>=0;i--){
        if(in[i]){
           check=true;
           cout<<1;
        }else{
           if(check){
              cout<<0;
           }
        }
    }
    cout<<endl;
    return 0;
}
0