Submission #2835942
Source Code Expand
#include <iostream> #include <vector> #define MAX_V 100010 using namespace std; struct edge{int to,cost; }; vector<edge> G[MAX_V]; bool used[MAX_V]; int d[MAX_V],f[MAX_V]; int V,E; void dfs(int s){ used[s] = true; int i = 0; while(true){ edge e = G[s][i]; if(e.to==-1){ break; } i++; if(!used[e.to]){ d[e.to] = d[s]+e.cost; dfs(e.to); } } } int main(){ int i,c=0; cin >> V; E = V-1; for(i=0;i<E;i++){ int s,t; cin >> s >> t; s--; t--; edge e; e.to = t; e.cost = 1; G[s].push_back(e); e.to = s; e.cost = 1; G[t].push_back(e); } for(i=0;i<V;i++){ edge e; e.to = -1; e.cost = 0; G[i].push_back(e); used[i] = false; } d[0] = 0; dfs(0); for(i=0;i<V;i++){ f[i] = d[i]; used[i] = false; } d[V-1] = 0; dfs(V-1); for(i=0;i<V;i++){ if(f[i]<=d[i]){ c++; } } cout << c << endl; if(c>V/2){ cout << "Fennec" << endl; }else{ cout << "Snuke" << endl; } }
Submission Info
Submission Time | |
---|---|
Task | D - Fennec VS. Snuke |
User | Alt3 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1001 Byte |
Status | WA |
Exec Time | 112 ms |
Memory | 12160 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | WA | 2 ms | 2560 KB |
00_example_02.txt | WA | 2 ms | 2560 KB |
01.txt | WA | 2 ms | 2560 KB |
02.txt | WA | 2 ms | 2560 KB |
03.txt | WA | 2 ms | 2560 KB |
04.txt | WA | 2 ms | 2560 KB |
05.txt | WA | 88 ms | 8448 KB |
06.txt | WA | 94 ms | 8832 KB |
07.txt | WA | 88 ms | 8320 KB |
08.txt | WA | 93 ms | 8704 KB |
09.txt | WA | 2 ms | 2560 KB |
10.txt | WA | 83 ms | 7168 KB |
11.txt | WA | 93 ms | 7808 KB |
12.txt | WA | 90 ms | 7680 KB |
13.txt | WA | 94 ms | 7936 KB |
14.txt | WA | 94 ms | 7808 KB |
15.txt | WA | 95 ms | 7936 KB |
16.txt | WA | 110 ms | 12160 KB |
17.txt | WA | 112 ms | 12160 KB |
18.txt | WA | 110 ms | 12160 KB |
19.txt | WA | 112 ms | 12160 KB |