시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 256 MB | 8 | 5 | 5 | 62.500% |
You are given a simple connected undirected graph with $N$ vertices and $M$ edges. The $i$-th edge connects the vertices $a_i$ and $b_i$.
Initially, the edges are not colored. Takahashikun wants to color the $i$-th edge with the color $c_i$.
He can color the edges in the following way:
Determine if he can color all edges with correct colors.
$N$ $M$
$a_1$ $b_1$ $c_1$
$a_2$ $b_2$ $c_2$
$\vdots$
$a_M$ $b_M$ $c_M$
Print "Yes
", if Takahashikun can color all edges with correct colors or "No
" otherwise.
r
' (red) or a 'b
' (blue).6 5 1 2 r 2 3 b 3 4 r 4 5 b 5 6 r
Yes
Start from vertex 1.
4 3 1 2 r 1 3 r 1 4 r
Yes
Start from vertex 2.
Dashed lines represent overpainted colors.
3 3 1 2 b 1 3 b 2 3 b
No