Edge Coloring
시간 제한2초메모리 제한256 MB
각 간선에 목표 색이 정해진 연결 무향 그래프에서, 한 번의 보행으로 모든 간선을 지나며 빨강과 파랑을 번갈아 칠할 수 있는지 판정한다. 각 간선의 최종 색은 보행에서 몇 번째로 지났는지에 따라 결정된다.
문제
You are given a simple connected undirected graph with vertices and edges. The -th edge connects the vertices and .
Initially, the edges are not colored. Takahashikun wants to color the -th edge with the color .
He can color the edges in the following way:
- First he chooses a vertex, and he repeats zero or more steps.
- In each step, he chooses a vertex adjacent to the current vertex and moves to the chosen vertex along an edge. This edge is colored red or blue (the color is defined according to the rule below).
- In odd-indexed (1-based) steps he uses red. In even-indexed steps he uses blue.
- If he colors an already-colored edges, the color of the edge is updated to the new color.
Determine if he can color all edges with correct colors.
입력
출력
Print "Yes", if Takahashikun can color all edges with correct colors or "No" otherwise.
제한
- The pairs are pairwise distinct.
- is either an '
r' (red) or a 'b' (blue). - The graph is connected.