結果
問題 | No.768 Tapris and Noel play the game on Treeone |
ユーザー |
|
提出日時 | 2018-12-15 15:14:08 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 754 bytes |
コンパイル時間 | 1,889 ms |
コンパイル使用メモリ | 185,488 KB |
実行使用メモリ | 32,460 KB |
最終ジャッジ日時 | 2024-09-25 06:16:25 |
合計ジャッジ時間 | 9,727 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
12,320 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 4 ms
5,376 KB |
testcase_04 | AC | 4 ms
5,376 KB |
testcase_05 | AC | 4 ms
5,376 KB |
testcase_06 | AC | 3 ms
5,376 KB |
testcase_07 | AC | 268 ms
20,992 KB |
testcase_08 | AC | 116 ms
12,544 KB |
testcase_09 | AC | 139 ms
14,336 KB |
testcase_10 | AC | 101 ms
11,648 KB |
testcase_11 | AC | 469 ms
30,720 KB |
testcase_12 | AC | 507 ms
30,976 KB |
testcase_13 | AC | 486 ms
30,208 KB |
testcase_14 | AC | 459 ms
30,208 KB |
testcase_15 | AC | 552 ms
31,872 KB |
testcase_16 | AC | 497 ms
31,872 KB |
testcase_17 | AC | 560 ms
32,460 KB |
testcase_18 | TLE | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
20evil_special_uni1.txt | -- | - |
20evil_special_uni2.txt | -- | - |
ソースコード
#include <bits/stdc++.h> using i64 = long long; using std::cout; using std::endl; using std::cin; int n; std::vector<std::vector<int>> g; std::map<int, std::map<int, int>> dp; void dfs(int v, int par = -1) { if(dp.count(v) and dp[v].count(par)) return; bool ret = true; for(auto e : g[v]) { if(e == par) continue; dfs(e, v); ret &= !dp[e][v]; } dp[v][par] = ret; return; } int main() { scanf("%d", &n); g.resize(n); for(int i = 0; i < n - 1; i++) { int a, b; scanf("%d%d", &a, &b); g[a - 1].push_back(b - 1); g[b - 1].push_back(a - 1); } std::vector<int> ans; for(int i = 0; i < n; i++) { dfs(i); if(dp[i][-1]) ans.push_back(i + 1); } printf("%d\n", ans.size()); for(auto v : ans) printf("%d\n", v); return 0; }