Submission #3239721
Source Code Expand
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
int x;
int y;
} P;
using namespace std;
int N;
int a[100010], b[100010];
int dto1[100010]={}, dtoN[100010]={};
vector<int> edge[100010];
void dfs1(int v, int p, int d){
dto1[v] = d;
for(auto &e : edge[v]){
if(p == e) continue;
dfs1(e, v, d+1);
}
}
void dfs2(int v, int p, int d){
dtoN[v] = d;
for(auto &e : edge[v]){
if(p == e) continue;
dfs2(e, v, d+1);
}
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N;
rep(i,0,N-1){
cin >> a[i] >> b[i];
a[i]--; b[i]--;
edge[a[i]].push_back(b[i]);
edge[b[i]].push_back(a[i]);
}
dfs1(0, -1, 0);
dfs2(N-1, -1, 0);
int ans_1 = 0;
int ans_2 = 0;
rep(i,0,N){
if(dto1[i] <= dtoN[i]){
ans_1++;
}else{
ans_2++;
}
}
if(ans_1 > ans_2){
print("Fennec");
}else{
print("Snuke");
}
}
Submission Info
Submission Time |
|
Task |
D - Fennec VS. Snuke |
User |
yuji9511 |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
1386 Byte |
Status |
AC |
Exec Time |
41 ms |
Memory |
12032 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 |
35 ms |
7808 KB |
06.txt |
AC |
36 ms |
8064 KB |
07.txt |
AC |
34 ms |
7808 KB |
08.txt |
AC |
37 ms |
8064 KB |
09.txt |
AC |
2 ms |
2560 KB |
10.txt |
AC |
31 ms |
6784 KB |
11.txt |
AC |
37 ms |
6784 KB |
12.txt |
AC |
35 ms |
7040 KB |
13.txt |
AC |
36 ms |
7296 KB |
14.txt |
AC |
36 ms |
7296 KB |
15.txt |
AC |
37 ms |
7296 KB |
16.txt |
AC |
41 ms |
12032 KB |
17.txt |
AC |
40 ms |
12032 KB |
18.txt |
AC |
41 ms |
12032 KB |
19.txt |
AC |
40 ms |
12032 KB |