Submission #4640841
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
using VS = vector<string>; using LL = long long;
using VI = vector<int>; using VVI = vector<VI>;
using PII = pair<int, int>; using PLL = pair<LL, LL>;
using VL = vector<LL>; using VVL = vector<VL>;
#define ALL(a) begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3")
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x)
#endif
const int INF = 1e9; const LL LINF = 1e16;
const LL MOD = 1000000007; const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 }; int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };
/* ----- __MAKE_TIME__ Problem: __PROBLEM__ / Link: __CONTEST_URL__ ----- */
/* ------問題------
-----問題ここまで----- */
/* -----解説等-----
----解説ここまで---- */
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
LL N; cin >> N;
VVI G(N);
FOR(i, 0, N - 1) {
int a, b; cin >> a >> b;
a--, b--;
G[a].push_back(b);
G[b].push_back(a);
}
VL dist0(N, INF), distN(N, INF);
function<void(int, int, int, const VVI&, VL&) > dfs = [&](int v, int p, int d, const VVI& G, VL &dist) {
dist[v] = d;
for (auto nx : G[v]) {
if (nx == p)continue;
dfs(nx, v, d + 1, G, dist);
}
};
dfs(0, -1, 0, G, dist0);
dfs(N - 1, -1, 0, G, distN);
LL ans = 0;
FOR(i, 0, N) {
if (dist0[i] <= distN[i])ans++;
else ans--;
}
cout << (ans > 0 ? "Fennec" : "Snuke") << endl;
return 0;
}
Submission Info
| Submission Time |
|
| Task |
D - Fennec VS. Snuke |
| User |
Yang33 |
| Language |
C++14 (GCC 5.4.1) |
| Score |
400 |
| Code Size |
1841 Byte |
| Status |
AC |
| Exec Time |
46 ms |
| Memory |
16640 KiB |
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 |
1 ms |
256 KiB |
| 00_example_02.txt |
AC |
1 ms |
256 KiB |
| 01.txt |
AC |
1 ms |
256 KiB |
| 02.txt |
AC |
1 ms |
256 KiB |
| 03.txt |
AC |
1 ms |
256 KiB |
| 04.txt |
AC |
1 ms |
256 KiB |
| 05.txt |
AC |
36 ms |
8576 KiB |
| 06.txt |
AC |
39 ms |
9216 KiB |
| 07.txt |
AC |
37 ms |
8576 KiB |
| 08.txt |
AC |
39 ms |
8960 KiB |
| 09.txt |
AC |
1 ms |
256 KiB |
| 10.txt |
AC |
34 ms |
6272 KiB |
| 11.txt |
AC |
39 ms |
6528 KiB |
| 12.txt |
AC |
36 ms |
6784 KiB |
| 13.txt |
AC |
39 ms |
7168 KiB |
| 14.txt |
AC |
38 ms |
7168 KiB |
| 15.txt |
AC |
38 ms |
7168 KiB |
| 16.txt |
AC |
45 ms |
16640 KiB |
| 17.txt |
AC |
45 ms |
16640 KiB |
| 18.txt |
AC |
45 ms |
16640 KiB |
| 19.txt |
AC |
46 ms |
16640 KiB |