結果
問題 | No.479 頂点は要らない |
ユーザー |
![]() |
提出日時 | 2017-01-27 23:46:14 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 93 ms / 1,500 ms |
コード長 | 1,624 bytes |
コンパイル時間 | 1,094 ms |
コンパイル使用メモリ | 71,024 KB |
実行使用メモリ | 9,468 KB |
最終ジャッジ日時 | 2024-12-23 17:48:59 |
合計ジャッジ時間 | 3,338 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <iostream> #include <utility> #include <cstdio> #include <queue> #include <stack> #include <algorithm> #include <numeric> #include <vector> #include <set> #include <map> #include <string> #include <cstring> using namespace std; #define ALL(a) (a).begin(), (a).end() using ll = long long; using P = pair<int, int>; struct State { int v, cost; State(int v, int cost): v(v), cost(cost) {} // 昇順 bool operator<(const State& s) const { return cost < s.cost; } // 降順 bool operator>(const State& s) const { return cost > s.cost; } }; void dump_vector(vector<int> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << (i < vec.size() - 1 ? " " : "\n"); } } const int MAX_N = 100010; const int MAX_M = 100010; struct Edge { int to, id; }; vector<Edge> edges[MAX_N]; bool v_used[MAX_M]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; edges[a].push_back((Edge){b, i}); edges[b].push_back((Edge){a, i}); } for (int v = n - 1; v >= 0; v--) { for (Edge e : edges[v]) { if (v_used[v] || v_used[e.to]) continue; // どっちも使われていないなら v_used[min(v, e.to)] = true; // cout << "#: " << e.to << endl; } } bool first = true; for (int i = n - 1; i >= 0; i--) { if (v_used[i]) { first = false; cout << 1; } else if (!first) { cout << 0; } } cout << endl; return 0; }