ASC(21)A(二分图最大匹配)
2014-10-02 21:55
183 查看
A - Graph Game
Time Limit: 6000/3000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)SubmitStatus
Problem Description
Nick and Peter like to play the following game when attending their complexity theory lectures. They draw an undirected bipartite graph G on a sheet of paper, and put a token to one of its vertices. After that they make moves in turn. Nick moves first.A move consists of moving the token along the graph edge. After it the vertex where the token was before the move, together with all edges incident to it, are removed from the graph. The player who has no valid moves loses the game.
You are given the graph that Nick and Peter have drawn. For each vertex of the graph find out who wins if the token is initially placed in that vertex. Assume that both Nick and Peter play optimally
Input
The first line of the input file contains three integer numbers n1 , n2,and m — the number of vertices in each part, and the number of edges, respectively (1 ≤ n1; n2 ≤
500, 0 ≤ m ≤ 50 000). The following m lines describe edges — each line contains the numbers of vertices connected by the corresponding edge. Vertices in each part are numbered independently, starting from 1.
Output
Output two lines. The first line must contain n1 characters, the i-th character must be ‘N’ in case Nick wins if the token is initially placedin the i-th vertex of the first part, and ‘P’ if Peter does. The second line must contain n2 characters and describe the second part in the same
way.
Sample Input
3 3 5 1 1 1 2 1 3 2 1 3 1
Sample Output
NPP NPP
题意:给了一个二分图,nike和peter一人走一步,走过的点不能再走,nick先走,他可以选择任何点为起始点,谁走不了了就输了,求nick选择每个点为起始点的输赢情况
思路:二分图匹配,如果一个点可以不在最大匹配中,那么nick先走这个点一定输,否则一定赢
相关文章推荐
- hdu5090 匈牙利算法二分图最大匹配问题
- SPOJ 4206 Fast Maximum Matching (二分图最大匹配 Hopcroft-Carp 算法 模板)
- HDU1607--二分图最大匹配
- CUGB图论专场2:B - Asteroids 二分图:最小顶点覆盖=最大匹配数
- HDU2819Swap(二分图最大匹配)
- 二分图最大匹配(匈牙利算法)
- 二分图的最大匹配(模板)
- HDOJ 2389 - Hopcroft-Carp模板二分图最大匹配
- 学习匈牙利算法总结(求解二分图最大匹配)
- 二分图最大匹配总结
- 二分图最大匹配模板
- 二分图最大匹配--匈牙利算法
- 二分图的最大匹配介绍及匈牙利算法
- poj 2239 Selecting Courses 二分图最大匹配
- Ural1109_Conference(二分图最大匹配/匈牙利算法/网络最大流)
- POJ 2446 Chessboard(二分图最大匹配)
- uva 11383(二分图最大权匹配)
- 彻底搞定二分图的匈牙利算法,最大匹配数(最小覆盖数)、最大独立数、最小路径覆盖
- HDU1150/POJ1325_Machine Schedule(二分图/最小点覆盖=最大匹配)
- [BZOJ 1191][HNOI 2006]超级英雄Hero(二分图最大匹配)