結果

問題 No.479 頂点は要らない
ユーザー bachoppi
提出日時 2020-07-20 18:21:56
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 158 ms / 1,500 ms
コード長 1,160 bytes
コンパイル時間 1,065 ms
コンパイル使用メモリ 105,508 KB
実行使用メモリ 14,068 KB
最終ジャッジ日時 2024-12-24 05:49:35
合計ジャッジ時間 4,948 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793


int main(){
  int n, m; cin >> n >> m; vector<int> to[n];
  rep(i, m){
    int a, b; cin >> a >> b; 
    to[a].push_back(b); to[b].push_back(a);
  }
  set<int> ans; set<int> ok;
  for(int i=n-1; i>=0; i--){
    bool can = false;
    for(int k: to[i]){
      if(ok.count(k)){
        can = true; ans.insert(i);
      }
    }
    if(!can){
      ok.insert(i); //cout << i << endl;
    }
  }
  int tmp[n] = {};
  for(auto k: ans){
    tmp[k] = 1; //cout << k << endl;
  }
  reverse(tmp, tmp+n); bool zero = true;
  rep(i, n){
    if(zero && tmp[i]==0) continue;
    if(tmp[i]==1) zero = false;
    cout << tmp[i];
  }
  cout << endl;
}
0