結果
問題 | No.768 Tapris and Noel play the game on Treeone |
ユーザー |
![]() |
提出日時 | 2018-12-16 18:31:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 238 ms / 2,000 ms |
コード長 | 545 bytes |
コンパイル時間 | 2,482 ms |
コンパイル使用メモリ | 196,756 KB |
最終ジャッジ日時 | 2025-01-06 19:36:52 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 TLE * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; int N; vector< int > g[100000]; bool dfs(int idx, int par) { for(auto &to : g[idx]) { if(to == par) continue; if(!dfs(to, idx)) return true; } return false; } int main() { cin >> N; for(int i = 1; i < N; i++) { int x, y; cin >> x >> y; --x, --y; g[x].push_back(y); g[y].push_back(x); } vector< int > ans; for(int i = 0; i < N; i++) { if(!dfs(i, -1)) ans.push_back(i); } cout << ans.size() << endl; for(auto &p : ans) cout << p + 1 << endl; }