結果

問題 No.479 頂点は要らない
ユーザー yuppe19 😺yuppe19 😺
提出日時 2017-01-27 23:42:49
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 593 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 52,896 KB
最終ジャッジ日時 2023-08-25 11:06:54
合計ジャッジ時間 1,010 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:3: error: ‘vector’ was not declared in this scope
   vector<vector<int>> G(n, vector<int>()); // G[n][]
   ^~~~~~
main.cpp:8:3: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
main.cpp:3:1:
+#include <vector>
 using namespace std;
main.cpp:8:3:
   vector<vector<int>> G(n, vector<int>()); // G[n][]
   ^~~~~~
main.cpp:8:17: error: expected primary-expression before ‘int’
   vector<vector<int>> G(n, vector<int>()); // G[n][]
                 ^~~
main.cpp:11:5: error: ‘G’ was not declared in this scope
     G[a].push_back(b);
     ^
main.cpp:17:17: error: ‘G’ was not declared in this scope
     for(int u : G[i]) {
                 ^

ソースコード

diff #

#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