| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 서브태스크 참고 (추가 시간 없음) | 1024 MB | 8 | 5 | 5 | 71.429% |
It has been almost 15ドル$ years since Sphinny became the premiere programming contestant by mastering the art of scheduling contests. She has grown alongside Coding Competitions and graduated into a programming contest organizer, and her Programming Club League (PCL) is the most popular sport in her city.
There are $\mathbf{N}$ bus stops in Sphinny's city, and $\mathbf{M}$ express bus routes. Each route bidirectionally connects two different bus stops, called their endpoints. Because of the popularity of PCL, the driver of each bus routes cheers for exactly one club.
Sphinny has to pick up the contest materials for the $j$-th contest at bus stop $\mathbf{P_j}$ and then the contest will be run in bus stop $\mathbf{C_j}$. She can only use the given bus routes to travel between them. Formally, a path for Sphinny to go from $\mathbf{P_j}$ to $\mathbf{C_j}$ is a list of bus routes such that each two consecutive routes have a common endpoint. Also the first route in the path has $\mathbf{P_j}$ as an endpoint and the last one has $\mathbf{C_j}$ as an endpoint. Notice that the same bus route can be used multiple times in a path. If Sphinny's path from $\mathbf{P_j}$ to $\mathbf{C_j}$ contains one or more bus routes whose driver cheers for club $c,ドル then club $c$ will join the contest. Otherwise, club $c$ will not join the contest. For organizational reasons, Sphinny needs the number of clubs in each contest to be an odd number.
Given the layout of Sphinny's city's bus routes and the contests' details, find out for how many contests there exists a path for Sphinny to take that can ensure an odd number of clubs joining it.
The first line of the input gives the number of test cases, $\mathbf{T}$. $\mathbf{T}$ test cases follow. The first line of each test case contains three integers $\mathbf{N},ドル $\mathbf{M},ドル and $\mathbf{Q}$: the number of bus stops, bus routes, and contests, respectively.
Then, $\mathbf{M}$ lines follow representing a different bus route each. The $i$-th of these lines contains three integers $\mathbf{U_i},ドル $\mathbf{V_i},ドル and $\mathbf{K_i},ドル meaning that the $i$-th bus route connects bus stops $\mathbf{U_i}$ and $\mathbf{V_i}$ and its driver cheers for club $\mathbf{K_i}$.
Finally, the last $\mathbf{Q}$ lines represent a contest each. The $j$-th of these lines contains two integers $\mathbf{P_j}$ and $\mathbf{C_j},ドル representing that materials for the $j$-th contest need to be picked up at bus stop $\mathbf{P_j}$ and the contest needs to be run at bus stop $\mathbf{C_j}$.
For each test case, output one line containing Case #x: y, where $x$ is the test case number (starting from 1) and $y$ is the number of contests for which Sphinny can find a path that ensures an odd number of clubs join it.
시간 제한: 20 초
시간 제한: 40 초
시간 제한: 120 초
2 5 5 3 1 2 1 2 3 2 2 4 1 2 5 1 4 5 1 1 3 3 4 5 1 3 1 2 1 3 1 1 2 1 3
Case #1: 1 Case #2: 1
Sample Case #1 is pictured above. In the first two contests, both clubs (green and blue) must be involved in it no matter what path is chosen. For the last contest, it is possible to involve only the green club by using the path through bus stops 1,ドル 2, 4, 5$.
For Sample Case #2, the first contest is not possible because there is no path to go from bus stop 1ドル$ to bus stop 2ドル$. For the second contest, there is a path including the only bus route going bus stop 1ドル$ to bus stop 3ドル,ドル therefore yielding a contest involving exactly 1ドル$ club, which is an acceptable odd number of clubs.
1 4 5 2 1 2 3 1 3 3 3 4 7 2 3 3 2 4 6 1 2 1 4
Case #1: 2
This additional Sample Case is pictured above. In this case, both contests can be done with an odd number of clubs. An example path that achieves that is shown in the picture.
Contest > Google > Code Jam > Google Code Jam Farewell Round > Round C D번