Orig Description
Score : 400 points
Problem StatementFennec and Snuke are playing a board game.
On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree.
Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored.
Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell.
More specifically, each player performs the following action in her/his turn:
Fennec: selects an uncolored cell that is adjacent to a black cell, and paints it black.
Snuke: selects an uncolored cell that is adjacent to a white cell, and paints it white.
A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.
Constraints
2 \leq N \leq 10^5
1 \leq a_i, b_i \leq N
The given graph is a tree.
InputInput is given from Standard Input in the following format:
N
a_1 b_1
:
a_{N-1} b_{N-1}
OutputIf Fennec wins, print Fennec; if Snuke wins, print Snuke.
Sample Input 17
3 6
1 2
3 1
7 4
5 7
1 4
Sample Output 1Fennec
For example, if Fennec first paints Cell 2 black, she will win regardless of Snuke's moves.
Sample Input 24
1 4
4 2
2 3
Sample Output 2Snuke
Extracted Specification
An integer \(N\) (2 ≤ \(N\) ≤ 10^5), representing some quantity or size.
A list of \(N-1\) tuples \((a_i, b_i)\), where each \(a_i\) and \(b_i\) is an integer (1 ≤ \(a_i, b_i\) ≤ \(N\)).
### Example Input:
```
7
3 6
1 2
3 1
7 4
5 7
1 4
```
### Function Signature:
Write a function `f(N, edges)` that takes in the input.
```python
def f(N: int, edges: List[Tuple[int, int]]):
'''
N: an integer
edges: a list of tuples, each containing two integers
'''
```
Test Case Generator
Sure! Below is a test case generator for the given problem statement involving Fennec and Snuke:
```python
import random
def generate_tree(N):
"""Generates a random tree with N nodes."""
edges = []
for i in range(2, N+1):
edges.append((i, random.randint(1, i-1)))
random.shuffle(edges)
return edges
def tcgen():
N = random.randint(2, 10**5)
edges = generate_tree(N)
return N, edges
def format_test_case(N, edges):
"""Formats the test case in the required input format."""
result = f"{N}\n"
for a, b in edges:
result += f"{a} {b}\n"
return result.strip()
# Example of generating a test case and printing it
if __name__ == "__main__":
N, edges = tcgen()
test_case = format_test_case(N, edges)
print(test_case)
```
### Explanation:
1. **generate_tree(N)**: This function creates a random tree with \(N\) nodes. It does this by ensuring node \(i\) (for \(i\) from 2 to \(N\)) is connected to any of the previous nodes (from 1 to \(i-1\)). This ensures the structure is a connected tree.
2. **tcgen()**: This function generates the number of nodes \(N\) and the corresponding edges by invoking `generate_tree(N)`.
3. **format_test_case(N, edges)**: This function formats the test case into the required input format for the problem statement.
When you run the script, it will print a generated test case that you can use for testing the problem.
### Example Output:
```
7
3 6
1 2
3 1
7 4
5 7
1 4
```
This output can be directly used as input for testing your solution to the problem.
Extract Arguments
def extract_arguments(fh):
N = int(fh.readline().strip())
edges = []
for _ in range(N-1):
a, b = map(int, fh.readline().strip().split())
edges.append((a, b))
return N, edges
# if __name__ == "__main__":
# input_path = sys.argv[1]
# with open(input_path, 'r') as fh:
# N, edges = extract_arguments(fh)
# f(N, edges)