mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 15:36:27 +00:00
D - Black and White Tree
https://atcoder.jp/contests/agc014/submissions/26377341
This commit is contained in:
parent
02ed7be7c2
commit
4919169d97
33
AtCoder/AGC014/D/D.cpp
Normal file
33
AtCoder/AGC014/D/D.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int n, u, v;
|
||||
vector<int> g[100005];
|
||||
bool flag, vis[100005];
|
||||
|
||||
void dfs(int u, int f) {
|
||||
if (flag) return;
|
||||
for (int i : g[u]) {
|
||||
if (i != f) dfs(i, u);
|
||||
}
|
||||
if (!vis[u]) {
|
||||
if (f == -1 || vis[f]) {
|
||||
flag = true;
|
||||
} else {
|
||||
vis[f] = vis[u] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
cin >> n;
|
||||
for (int i = 1; i < n; i++) {
|
||||
cin >> u >> v;
|
||||
g[u].push_back(v);
|
||||
g[v].push_back(u);
|
||||
}
|
||||
dfs(1, -1);
|
||||
cout << (flag ? "First" : "Second") << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user