#P14501. [NCPC 2025] Gotta Trade Some of 'Em
[NCPC 2025] Gotta Trade Some of 'Em
题目背景
:::align{center}

Two Game Boy systems connected with a DMG-04 (link cable). Public domain photo by KoS.
:::
题目描述
The kids at school are obsessed with a new video game of collectible pocket monsters called . Their goal is to "catch 'em all" by completing the Pokédex, meaning they want to catch a copy of every Pokémon. Typically they do this by playing the game, encountering Pokémon, and catching them with a Pokéball.
Pokémon games are released in different variants. Each variant contains a number of Pokémon, some of which are exclusive to that variant. For example, only (variant ) allows encounters with the Pokémon known as Meowth. Thus, a kid owning (variant ) cannot catch Meowth, and therefore must trade with a friend who has a Meowth to fill the Pokédex. This friend may either own Pokémon Blue or have received Meowth through another trade.
Your task is to distribute Pokémon variants to the kids so that, through trading among friends, every kid can eventually collect at least one of each Pokémon. Each kid receives exactly one Pokémon game variant. Each variant comes with enough copies of its Pokémon, both its exclusives and the non-exclusives, ensuring trades are always possible.
输入格式
The input consists of:
- One line with three integers , , and : the number of kids, with , the number of friendships, with , and the number of different game variants, with .
- lines, each containing two integers and with , representing that and are friends.
输出格式
Output integers, one for each kid, representing which game variant that kid should get. Your output will be considered correct if all kids can fill their Pokédex by using any number of trades with their friends.
If there are multiple valid solutions, you may output any one of them.
If there is no assignment of game variants to kids that allows all kids to fill their Pokédex, output .
8 5 2
1 2
2 5
3 4
5 6
7 8
1 2 1 2 1 2 1 2
8 5 3
1 2
2 5
3 4
5 6
7 8
impossible
8 7 8
1 2
2 3
3 4
4 5
5 6
6 7
7 8
1 2 3 4 5 6 7 8
京公网安备 11011102002149号