Submission #1869088
Source Code Expand
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int n, k, s1, s2, d[100005];
vector<int> a[100005];
int f(int p, int q) {
int i, mn = 2e9;
if (p == n) return 0;
// if (d[p] != 0) return d[p];
for (i = 0; i < a[p].size(); i++) {
if (a[p][i] == q) continue;
mn = min(mn, f(a[p][i], p) + 1);
}
return mn;
}
void g(int p, int q, int w, int z) {
int i;
if (w < 0) return;
if (d[p] != 0 && d[p] != z) return;
d[p] = z;
for (i = 0; i < a[p].size(); i++) {
if (a[p][i] == q) continue;
g(a[p][i], p, w - 1, z);
}
}
int main()
{
int i, t1, t2 ,num;
cin >> n;
for (i =0; i <n - 1; i++) {
scanf ("%d %d", &t1, &t2);
a[t1].push_back(t2);
a[t2].push_back(t1);
}
num = f(1, -1);
g(1, -1, num / 2, 1);
g(n, -1, (num - 1) / 2, 2);
g(1, -1, 100000000, 1);
g(n, -1, 100000000, 2);
for (i = 1; i <= n; i++) {
if (d[i] == 1) s1++;
else s2++;
}
if (s1 > s2) cout << "Fennec";
else cout << "Snuke";
return 0;
}
Submission Info
Submission Time |
|
Task |
D - Fennec VS. Snuke |
User |
sean617 |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
1015 Byte |
Status |
AC |
Exec Time |
47 ms |
Memory |
12416 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:34:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf ("%d %d", &t1, &t2);
^
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 |
3 ms |
2560 KB |
01.txt |
AC |
2 ms |
2560 KB |
02.txt |
AC |
3 ms |
2560 KB |
03.txt |
AC |
2 ms |
2560 KB |
04.txt |
AC |
3 ms |
2560 KB |
05.txt |
AC |
40 ms |
7168 KB |
06.txt |
AC |
43 ms |
7424 KB |
07.txt |
AC |
40 ms |
7168 KB |
08.txt |
AC |
43 ms |
7424 KB |
09.txt |
AC |
2 ms |
2560 KB |
10.txt |
AC |
33 ms |
5760 KB |
11.txt |
AC |
39 ms |
5760 KB |
12.txt |
AC |
36 ms |
6016 KB |
13.txt |
AC |
39 ms |
6144 KB |
14.txt |
AC |
38 ms |
6144 KB |
15.txt |
AC |
38 ms |
6144 KB |
16.txt |
AC |
47 ms |
12416 KB |
17.txt |
AC |
47 ms |
12416 KB |
18.txt |
AC |
47 ms |
12416 KB |
19.txt |
AC |
46 ms |
12416 KB |