Touya Akira vs Shindou Hikaru
All submissions for this problem are available.
After losing to Touya many times in Go, Hikaru wants to defeat Touya in graph game. Graph game is played on an undirected graph as follows - First Hikaru selects a node x. Then touya selects a node y which is adjacent to last selected node i.e. x. Then Hikaru selects a node which is not selected already and is adjacent to y and so on. A player cannot make a move if there is no un-selected node adjacent to last selected node. The last one to make a move wins.
Given the description of graph, can you tell whether Hikaru can win the game ?
First Line contains N, the number of nodes in the graph and M the number of edges.
Next M lines follow, each containing two integers x and y, denoting edge between node x and node y. The graph will not have self loops and multiple edges.
output on a single line "Yes" if Hikaru can defeat Touya, "No" otherwise.
- 1 ≤ N, M ≤ 100
- 1 ≤ x,y ≤ N
Input1: 2 1 1 2 Input2: 3 2 1 2 1 3 Output1: No Output2: Yes
Example case 1. Touya picks the node Hikaru did not select and wins.
Example case 2. Hikaru selects 2. Touya is forced to select 1. Then, Hikaru selects 3 and wins.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, LISP sbcl, LISP clisp, SCM guile, ERL, TCL, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions