Submission #3246698
Source Code Expand
# -*- coding: utf-8 -*- """ Created on Sat Sep 22 16:27:11 2018 @author: maezawa """ from collections import deque import copy n = int(input()) adj = [[] for _ in range(n+1)] for i in range(n-1): ai, bi = list(map(int, input().split())) adj[ai].append(bi) adj[bi].append(ai) #print(adj) node = [0]*(n+1) f = 1 s = n node[f] = 1 node[s] = -1 stack1 = deque([f]) stack2 = deque([s]) nextstack1 = deque([]) nextstack2 = deque([]) cnt1 = 0 cnt2 = 0 turn = 1 while stack1 or stack2: turn += 1 while stack1: f = stack1.pop() for m1 in adj[f]: if node[m1] != 0: continue else: node[m1] = turn nextstack1.append(m1) stack1 = copy.deepcopy(nextstack1) nextstack1 = deque([]) while stack2: s = stack2.pop() for m2 in adj[s]: if node[m2] != 0: continue else: node[m2] = -turn nextstack2.append(m2) stack2 = copy.deepcopy(nextstack2) nextstack2 = deque([]) cnt = 0 for i in node: if i>0: cnt += 1 elif i<0: cnt -= 1 if cnt > 0: print('Fennec') else: print('Snuke')
Submission Info
Submission Time | |
---|---|
Task | D - Fennec VS. Snuke |
User | km1216jp |
Language | Python (3.4.3) |
Score | 400 |
Code Size | 1317 Byte |
Status | AC |
Exec Time | 1869 ms |
Memory | 31780 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 | 22 ms | 3444 KB |
00_example_02.txt | AC | 22 ms | 3444 KB |
01.txt | AC | 22 ms | 3444 KB |
02.txt | AC | 22 ms | 3444 KB |
03.txt | AC | 22 ms | 3444 KB |
04.txt | AC | 22 ms | 3444 KB |
05.txt | AC | 793 ms | 26160 KB |
06.txt | AC | 860 ms | 27756 KB |
07.txt | AC | 825 ms | 26108 KB |
08.txt | AC | 853 ms | 27672 KB |
09.txt | AC | 22 ms | 3444 KB |
10.txt | AC | 503 ms | 27472 KB |
11.txt | AC | 501 ms | 27252 KB |
12.txt | AC | 532 ms | 29040 KB |
13.txt | AC | 584 ms | 30400 KB |
14.txt | AC | 535 ms | 28128 KB |
15.txt | AC | 537 ms | 28552 KB |
16.txt | AC | 1822 ms | 31780 KB |
17.txt | AC | 1806 ms | 31780 KB |
18.txt | AC | 1869 ms | 31780 KB |
19.txt | AC | 1801 ms | 31780 KB |