A safari park(野生动物园)has K species of animals, and is divided into N regions. The managers hope to spread the animals to all the regions, but not the same animals in the two neighboring regions. Of course, they also realize that this is an NP complete problem, you are not expected to solve it. Instead, they have designed several distribution plans. Your job is to write a program to help them tell if a plan is feasible.
Input Specification:
Each input file contains one test case. For each case, the first line gives 3 integers: N (0<N≤500), the number of regions; R (≥0), the number of neighboring relations, and K (0<K≤N), the number of species of animals. The regions and the species are both indexed from 1 to N.
Then R lines follow, each gives the indices of a pair of neighboring regions, separated by a space.
Finally there is a positive M (≤20) followed by M lines of distribution plans. Each plan gives N indices of spec

博客介绍了PAT甲级编程竞赛中的一道题目,即在野生动物园的N个区域分配K种动物,使得相邻区域不包含相同动物。文章提供输入输出规范、题目分析及代码实现,旨在解决图着色问题,确保每个分配方案的可行性。
最低0.47元/天 解锁文章
1813

被折叠的 条评论
为什么被折叠?



