結果
問題 | No.479 頂点は要らない |
ユーザー |
![]() |
提出日時 | 2017-01-27 23:25:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 107 ms / 1,500 ms |
コード長 | 1,696 bytes |
コンパイル時間 | 809 ms |
コンパイル使用メモリ | 87,036 KB |
実行使用メモリ | 31,452 KB |
最終ジャッジ日時 | 2024-12-23 17:00:41 |
合計ジャッジ時間 | 3,931 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) using namespace std; typedef long long int lli; lli MOD = 1000000007; struct edge { int f, t, num; }; int edge_flag[10000005] = {}; bool use[10000005] = {}; vector<edge> e[1000005]; int main() { int n, m; cin >> n >> m; int a, b; rep(i, m) { cin >> a >> b; e[b].push_back(edge{b, a, i}); e[a].push_back(edge{a, b, i}); } rep(i, n) { bool flag = false; for (auto j : e[i]) { // if (i == 9) { // cout << edge_flag[j.num] << ' '; // } if (!edge_flag[j.num]) { flag = true; } } if (flag) { for (auto j : e[i]) { edge_flag[j.num]++; } } use[i] = flag; } // rep(i, m) // { // cout << edge_flag[i] << endl; // } rrep(i, n) { if (use[i]) { bool flag = false; for (auto j : e[i]) { if (edge_flag[j.num] == 1) { flag = true; } } if (!flag) { for (auto j : e[i]) { edge_flag[j.num]--; } } use[i] = flag; } } int in = 0; bool flag = false; rrep(i, n) { if (!flag) { flag = use[i]; } if (flag) { cout << use[i]; } } cout << endl; }