結果
問題 | No.768 Tapris and Noel play the game on Treeone |
ユーザー | lumc_ |
提出日時 | 2018-03-12 01:14:25 |
言語 | C++11 (gcc 11.4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 633 bytes |
コンパイル時間 | 1,532 ms |
コンパイル使用メモリ | 169,476 KB |
実行使用メモリ | 26,068 KB |
最終ジャッジ日時 | 2023-10-25 21:48:05 |
合計ジャッジ時間 | 5,539 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
11,224 KB |
testcase_01 | AC | 5 ms
11,224 KB |
testcase_02 | AC | 4 ms
11,224 KB |
testcase_03 | AC | 19 ms
11,392 KB |
testcase_04 | AC | 30 ms
11,448 KB |
testcase_05 | AC | 23 ms
11,412 KB |
testcase_06 | AC | 13 ms
11,352 KB |
testcase_07 | TLE | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
20evil_special_uni1.txt | -- | - |
20evil_special_uni2.txt | -- | - |
ソースコード
#include<bits/stdc++.h> using namespace std; vector<int> g[100000]; int N; unordered_map<int, bool> dp[100000]; // 想定TLE ? bool dfs(int v, int p) { // if(dp[v].count(p)) return dp[v][p]; bool flag = 0; for(int u : g[v]) if(u != p) flag |= dfs(u, v); return dp[v][p] = !flag; } int main() { cin >> N; for(int i = 0; i < N - 1; i++) { int a, b; cin >> a >> b; a--; b--; g[a].emplace_back(b); g[b].emplace_back(a); } vector<int> ans; ans.reserve(N); for(int i = 0; i < N; i++) if(dfs(i, -1)) ans.emplace_back(i); cout << ans.size() << endl; for(int el : ans) cout << el + 1 << endl; }