Problem H
Red/Blue Spanning Tree
Given an undirected, unweighted, connected graph, where each
edge is colored either blue or red, determine whether a
spanning tree with exactly
Input
There will be a single test case in the input. Each test case will begin with a line with three integers:
Where
Where
Output
Output a single line, containing
Sample Input 1 | Sample Output 1 |
---|---|
3 3 2 B 1 2 B 2 3 R 3 1 |
1 |
Sample Input 2 | Sample Output 2 |
---|---|
2 1 1 R 1 2 |
0 |