Submission #1422562
Source Code Expand
#include <cstdio>
#include <vector>
using namespace std;
int d[2][100000];
vector <int> v[100000];
void dfs(int x, int y, int z, int w) {
int i;
d[w][x] = z;
for (i = 0; i < v[x].size(); i++) {
if (v[x][i] == y) continue;
dfs(v[x][i], x, z + 1, w);
}
}
int main() {
int n, c1 = 0, c2 = 0, i;
scanf("%d", &n);
for (i = 0; i < n - 1; i++) {
int x, y;
scanf("%d %d", &x, &y);
x--;
y--;
v[x].push_back(y);
v[y].push_back(x);
}
dfs(0, -1, 0, 0);
dfs(n - 1, -1, 0, 1);
for (i = 0; i < n; i++) {
if (d[0][i] <= d[1][i]) {
c1++;
} else {
c2++;
}
}
if (c1 > c2) {
puts("Fennec");
} else {
puts("Snuke");
}
return 0;
}
Submission Info
Submission Time |
|
Task |
D - Fennec VS. Snuke |
User |
kawatea |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
937 Byte |
Status |
AC |
Exec Time |
44 ms |
Memory |
14336 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:24:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:29:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &x, &y);
^
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 |
36 ms |
7936 KB |
06.txt |
AC |
39 ms |
8192 KB |
07.txt |
AC |
36 ms |
7936 KB |
08.txt |
AC |
40 ms |
8064 KB |
09.txt |
AC |
2 ms |
2560 KB |
10.txt |
AC |
33 ms |
6016 KB |
11.txt |
AC |
38 ms |
6144 KB |
12.txt |
AC |
36 ms |
6272 KB |
13.txt |
AC |
38 ms |
6528 KB |
14.txt |
AC |
38 ms |
6528 KB |
15.txt |
AC |
38 ms |
6528 KB |
16.txt |
AC |
44 ms |
14336 KB |
17.txt |
AC |
44 ms |
14336 KB |
18.txt |
AC |
44 ms |
14336 KB |
19.txt |
AC |
44 ms |
14336 KB |