結果
問題 |
No.479 頂点は要らない
|
ユーザー |
![]() |
提出日時 | 2017-01-27 23:10:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 33 ms / 1,500 ms |
コード長 | 776 bytes |
コンパイル時間 | 1,584 ms |
コンパイル使用メモリ | 170,956 KB |
実行使用メモリ | 10,132 KB |
最終ジャッジ日時 | 2024-12-23 16:53:29 |
合計ジャッジ時間 | 3,262 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; struct Edge { int id, to; }; int check[100000]; int del[100000]; vector<Edge> G[100000]; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; for(int i = 0; i < m; i++) { int a, b; cin >> a >> b; G[a].push_back({ i, b }); G[b].push_back({ i, a }); } for(int i = n - 1; i >= 0; i--) { bool ok = true; for(auto e : G[i]) { if(check[e.id]) { ok = false; break; } } if(ok) { for(auto e : G[i]) { check[e.id] = 1; } del[i] = 1; } } string s; for(int i = 0; i < n; i++) { if(del[i]) s += '0'; else s += '1'; } while(s.back() == '0') s.pop_back(); reverse(s.begin(), s.end()); if(s == "") s = "0"; cout << s << endl; }