結果

問題 No.479 頂点は要らない
コンテスト
ユーザー yuppe19 😺
提出日時 2017-01-27 23:42:49
言語 C++11(old_compat)
(gcc 12.4.0 + boost 1.89.0)
コンパイル:
g++-12 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -include bits/stdc++.h -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 46 ms / 1,500 ms
コード長 593 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,470 ms
コンパイル使用メモリ 172,732 KB
実行使用メモリ 9,608 KB
最終ジャッジ日時 2026-03-08 16:08:36
合計ジャッジ時間 3,280 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |   int n, m; scanf("%d%d", &n, &m);
      |             ~~~~~^~~~~~~~~~~~~~~~
main.cpp:10:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |     int a, b; scanf("%d%d", &a, &b);
      |               ~~~~~^~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include <iostream>
#include <algorithm>
using namespace std;
using i64 = long long;

int main(void) {
  int n, m; scanf("%d%d", &n, &m);
  vector<vector<int>> G(n, vector<int>()); // G[n][]
  for(int i=0; i<m; ++i) {
    int a, b; scanf("%d%d", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  string removed(n, '0');
  for(int i=n-1; i>=0; --i) {
    if(removed[i] == '1') { continue; }
    for(int u : G[i]) {
      removed[u] = '1';
    }
  }
  reverse(begin(removed), end(removed));
  removed.erase(0, removed.find_first_not_of('0'));
  cout << removed << endl;
  return 0;
}
0