Submission #3246715
Source Code Expand
#include<iostream> #include<vector> #include<stack> using namespace std; int main(){ int n; cin >> n; vector<vector<int>> v(n); int a, b; for(int i = 0; i < n-1; i++){ cin >> a >> b; a--, b--; v[a].push_back(b); v[b].push_back(a); } int disto[n], distn[n]; stack<pair<pair<int,int>, int>> s; s.push({{-1, 0}, 0}); while(!s.empty()){ pair<pair<int,int>,int> x = s.top(); s.pop(); int parent = x.first.first; int now = x.first.second; int depth = x.second; disto[now] = depth; for(int next : v[now]){ if(next != parent) s.push({{now, next}, depth+1}); } } s.push({{-1, n-1}, 0}); while(!s.empty()){ pair<pair<int,int>,int> x = s.top(); s.pop(); int parent = x.first.first; int now = x.first.second; int depth = x.second; distn[now] = depth; for(int next : v[now]){ if(next != parent) s.push({{now, next}, depth+1}); } } int fen = 0, snu = 0; for(int i = 0; i < n; i++){ if(distn[i] >= disto[i]) fen++; else snu++; } if(fen <= snu) cout << "Snuke" << endl; else cout << "Fennec" << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Fennec VS. Snuke |
User | face4 |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1381 Byte |
Status | AC |
Exec Time | 82 ms |
Memory | 6528 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 | 1 ms | 256 KB |
00_example_02.txt | AC | 1 ms | 256 KB |
01.txt | AC | 1 ms | 256 KB |
02.txt | AC | 1 ms | 256 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 67 ms | 5504 KB |
06.txt | AC | 72 ms | 5888 KB |
07.txt | AC | 68 ms | 5504 KB |
08.txt | AC | 72 ms | 5888 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | AC | 66 ms | 5632 KB |
11.txt | AC | 73 ms | 5888 KB |
12.txt | AC | 72 ms | 6144 KB |
13.txt | AC | 76 ms | 6400 KB |
14.txt | AC | 76 ms | 6400 KB |
15.txt | AC | 77 ms | 6400 KB |
16.txt | AC | 79 ms | 6528 KB |
17.txt | AC | 78 ms | 6528 KB |
18.txt | AC | 78 ms | 6528 KB |
19.txt | AC | 82 ms | 6528 KB |