結果

問題 No.479 頂点は要らない
ユーザー butter_rollbutter_roll
提出日時 2017-01-27 23:22:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 88 ms / 1,500 ms
コード長 1,025 bytes
コンパイル時間 775 ms
コンパイル使用メモリ 82,592 KB
実行使用メモリ 9,384 KB
最終ジャッジ日時 2023-08-25 10:32:51
合計ジャッジ時間 3,864 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 2 ms
4,384 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 2 ms
4,384 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 88 ms
8,904 KB
testcase_27 AC 87 ms
8,724 KB
testcase_28 AC 71 ms
9,384 KB
testcase_29 AC 69 ms
6,288 KB
testcase_30 AC 68 ms
6,244 KB
testcase_31 AC 69 ms
6,232 KB
testcase_32 AC 68 ms
6,372 KB
testcase_33 AC 74 ms
6,640 KB
testcase_34 AC 80 ms
6,556 KB
testcase_35 AC 67 ms
5,400 KB
testcase_36 AC 35 ms
4,472 KB
testcase_37 AC 77 ms
6,952 KB
testcase_38 AC 64 ms
6,184 KB
testcase_39 AC 47 ms
5,784 KB
testcase_40 AC 57 ms
6,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define pb push_back
#define pii pair<int,int>
using namespace std;


int main(void){
  int n,m;
  int a,b,i,j;
  vector<vector<int> >edge;

  cin>>n>>m;
  int use[n];
  for(i=0;i<n;i++){
    vector<int> x;
    edge.pb(x);
    use[i]=0;
  }
  for(i=0;i<m;i++){
    cin>>a>>b;
    edge[a].pb(b);
    edge[b].pb(a);
  }
  
  for(i=n-1;i>=0;i--){
    if(edge[i].size()!=0 && use[i]==0){
      use[i]=-1;
      for(j=0;j<edge[i].size();j++){
        use[edge[i][j]]=1;
        auto itr=find(edge[edge[i][j]].begin(),edge[edge[i][j]].end(),i);
        if(itr!=edge[edge[i][j]].end()) edge[edge[i][j]].erase(itr);
      }
    }
    
  }
  /*
  cout<<endl;
  for(i=0;i<n;i++){
    cout<<i<<":";
    for(j=0;j<edge[i].size();j++){
      cout<<edge[i][j]<<" ";
    }
    cout<<endl;
  }
  */
  j=0;
  for(i=n;i>=0;i--){
    if(use[i]==1) j=1;
    if(use[i]==1&&j==1) cout<<1;
    if(use[i]!=1&&j==1) cout<<0;
  }
  cout<<endl;


  return 0;
}
0