結果
問題 |
No.1254 補強への架け橋
|
ユーザー |
|
提出日時 | 2022-08-28 02:45:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,280 bytes |
コンパイル時間 | 2,193 ms |
コンパイル使用メモリ | 203,984 KB |
最終ジャッジ日時 | 2025-01-31 06:36:01 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 3 WA * 120 |
ソースコード
// #pragma GCC optimize("O3") // #ifndef ONLINE_JUDGE // #define _GLIBCXX_DEBUG // #endif #include <bits/stdc++.h> using namespace std; void solve() { int N; cin >> N; vector<vector<int>> adj(N); for (auto i = 0; i < N; ++i) { int u, v; cin >> u >> v; --u, --v; adj[u].push_back(v); adj[v].push_back(u); } vector<char> visited(N); vector<int> tin(N, -1), low(N, -1); int timer = 0; vector<char> color(N); auto dfs = [&](auto self, int u, int par) -> void { visited[u] = true; tin[u] = low[u] = timer++; for (auto v : adj[u]) if (v != par){ if (visited[v]) { low[u] = min(low[u], tin[v]); } else { self(self, v, u); low[u] = min(low[u], low[v]); if (low[v] > tin[u]) { color[v] = 1; } } } }; dfs(dfs, 0, 0); cout << count_if(begin(color), end(color), [](auto x) {return !x;}) << '\n'; for (auto i = 0; i < N; ++i) { if (!color[i]) { cout << i + 1 << ' '; } } } auto main() -> signed { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); solve(); return 0; }