結果

問題 No.479 頂点は要らない
ユーザー ei1333333
提出日時 2017-01-27 23:58:32
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 83 ms / 1,500 ms
コード長 535 bytes
コンパイル時間 1,650 ms
コンパイル使用メモリ 162,036 KB
実行使用メモリ 9,300 KB
最終ジャッジ日時 2024-12-23 17:55:28
合計ジャッジ時間 4,123 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main()
{
  int N, M;
  vector< int > g[100000];
  cin >> N >> M;
  while(M--) {
    int A, B;
    cin >> A >> B;
    g[A].push_back(B);
    g[B].push_back(A);
  }

  string S = string(N, '1');
  bool st[100000];
  memset(st, true, sizeof(st));
  for(int i = N - 1; i >= 0; i--) {
    st[i] = true;
    for(auto &to : g[i]) st[i] &= st[to];
    st[i] ^= 1;
    if(st[i] == 0) S[i] = '0';
  }
  while(S.back() == '0') S.pop_back();
  reverse(begin(S), end(S));
  cout << S << endl;

}
0