Submission #1423022
Source Code Expand
#include<iostream> #include<algorithm> #include<vector> #include<string> #include<functional> #include<queue> #include<cmath> using namespace std; int dist1[200009], dist2[200009], n, a, b; vector<int>x[200009]; void dfs1(int pos, int depth) { if (dist1[pos] != -1)return; dist1[pos] = depth; for (int i = 0; i < x[pos].size(); i++) { dfs1(x[pos][i], depth + 1); } } void dfs2(int pos, int depth) { if (dist2[pos] != -1)return; dist2[pos] = depth; for (int i = 0; i < x[pos].size(); i++) { dfs2(x[pos][i], depth + 1); } } int main() { cin >> n; for (int i = 0; i < n - 1; i++) { cin >> a >> b; x[a].push_back(b); x[b].push_back(a); } for (int i = 0; i < 200009; i++) { dist1[i] = -1; dist2[i] = -1; } dfs1(1, 0); dfs2(n, 0); int cnt1 = 0, cnt2 = 0; for (int i = 1; i <= n; i++) { if (dist1[i] <= dist2[i])cnt1++; else cnt2++; } if (cnt1 > cnt2)cout << "Fennec" << endl; else cout << "Snuke" << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Fennec VS. Snuke |
User | E869120 |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 970 Byte |
Status | AC |
Exec Time | 96 ms |
Memory | 14336 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt |
All | 00_example_01.txt, 00_example_02.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 3 ms | 6528 KB |
00_example_02.txt | AC | 3 ms | 6528 KB |
01.txt | AC | 3 ms | 6528 KB |
02.txt | AC | 3 ms | 6528 KB |
03.txt | AC | 3 ms | 6528 KB |
04.txt | AC | 3 ms | 6528 KB |
05.txt | AC | 81 ms | 10368 KB |
06.txt | AC | 85 ms | 10624 KB |
07.txt | AC | 80 ms | 10368 KB |
08.txt | AC | 85 ms | 10496 KB |
09.txt | AC | 3 ms | 6528 KB |
10.txt | AC | 77 ms | 9216 KB |
11.txt | AC | 89 ms | 9344 KB |
12.txt | AC | 83 ms | 9472 KB |
13.txt | AC | 88 ms | 9728 KB |
14.txt | AC | 86 ms | 9600 KB |
15.txt | AC | 88 ms | 9728 KB |
16.txt | AC | 94 ms | 14336 KB |
17.txt | AC | 94 ms | 14336 KB |
18.txt | AC | 96 ms | 14336 KB |
19.txt | AC | 95 ms | 14336 KB |