编程介的小学生 2017-09-22 09:30 采纳率: 20.5%
浏览 737
已采纳

Graph Game

Description

Consider the following game on an undirected graph G. There are two players, a red color player R and a blue color player B. Initially all edges of G are uncolored. The two players alternately color an uncolored edge of G with their color until all edges are colored. The goal of B is that in the end, the blue-colored edges form a connected spanning subgraph of G. A connected spanning subgraph of G is a connected subgraph that contains all the vertexes of graph G. The goal of R is to prevent B from achieving his goal.

Assume that R starts the game. Suppose that both players play in the smartest way. Your task is to find out whether B will win the game.
Input

The input contains several test cases, ended by a line of `-1 -1'.

Each test case begins with a line of two integers n (1 <= n <= 10) and m (0 <= m <= 30), indicating the number of vertexes and edges in the graph. All vertexes are numbered from 0 to n - 1.

Then m lines follow. Each line contains two integers p and q (0 <= p, q < n), indicating there is an edge between vertex p and vertex q.

It is possible that the graph contains more than one edge between two vertexes and self-loops.
Output

For each test case print a line which is either 'YES' or 'NO' indicating B will win the game or not.
Sample Input

3 4
0 1
1 2
2 0
0 2
4 6
1 0
1 2
2 0
0 2
3 0
1 0
-1 -1
Sample Output

YES
NO

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-10-08 00:28
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败