Submission #1516962
Source Code Expand
#include<iostream> #include<vector> #include<math.h> #include<map> #include<stdio.h> #include<queue> #include<algorithm> #include<functional> using namespace std; #define MP make_pair #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,a) for(int i=0;i<(a);++i) typedef pair<int, int> P; typedef pair<pair<P, P>, P>PP; typedef long long LL; #define INF LL(1e18) #define N 100000 int n, judge; int flag1[N], flag2[N]; vector<int> edge[N]; int bfs(int s, int flag[]) { queue<int> que; que.push(s); while(!(que.empty())) { int now = que.front(); que.pop(); REP(i, edge[now].size()) { int to = edge[now][i]; if(!flag[to] && to != s) { flag[to] = flag[now] + 1; que.push(to); } } } } int main() { cin >> n; REP(i, n - 1) { int a, b; cin >> a >> b; --a; --b; edge[b].push_back(a); edge[a].push_back(b); } bfs(0, flag1); bfs(n - 1, flag2); REP(i, n) { if(flag1[i] <= flag2[i]) { judge++; } } if(judge > n / 2) { cout << "Fennec" << endl; } else { cout << "Snuke" << endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Fennec VS. Snuke |
User | kazu123 |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1131 Byte |
Status | AC |
Exec Time | 78 ms |
Memory | 6656 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 | 2 ms | 2560 KB |
00_example_02.txt | AC | 2 ms | 2560 KB |
01.txt | AC | 2 ms | 2560 KB |
02.txt | AC | 2 ms | 2560 KB |
03.txt | AC | 2 ms | 2560 KB |
04.txt | AC | 2 ms | 2560 KB |
05.txt | AC | 67 ms | 5888 KB |
06.txt | AC | 71 ms | 6144 KB |
07.txt | AC | 66 ms | 5888 KB |
08.txt | AC | 72 ms | 6144 KB |
09.txt | AC | 2 ms | 2560 KB |
10.txt | AC | 65 ms | 6144 KB |
11.txt | AC | 73 ms | 6144 KB |
12.txt | AC | 71 ms | 6400 KB |
13.txt | AC | 75 ms | 6656 KB |
14.txt | AC | 74 ms | 6656 KB |
15.txt | AC | 74 ms | 6656 KB |
16.txt | AC | 78 ms | 6528 KB |
17.txt | AC | 78 ms | 6528 KB |
18.txt | AC | 77 ms | 6528 KB |
19.txt | AC | 77 ms | 6528 KB |