Mod Graph
시간 제한1초메모리 제한2048 MB
정점을 방문할 때마다 값이 b_v로 나눈 나머지로 1씩 증가하는 연결 그래프에서, s에서 시작하는 보행으로 모든 값을 0으로 만들 수 있는지 판정한다.
문제
You are given an undirected, connected graph with vertices. Every vertex has a counter that operates modulo . The initial state of that counter is . Every time you visit that vertex, it is increased by one (i.e. ).
You have to process queries of the following two types:
- "
1": Suppose that you start at vertex , you have to answer whether it is possible to make for all . You are allowed to take an arbitrary walk through , i.e. you can use edges and vertices multiple times. Note that starting the walk at already counts as visiting , i.e. its counter is increased by one initially. - "
2": Update .
입력
The first line contains three integers , , and (, ) --- the number of vertices, edges, and queries, respectively.
The second line contains integers .
The third line contains integers ().
The following lines contain the edges of the graph. Each of those lines contains two integers and (, ) describing an edge connecting vertices and . The given graph is connected.
Finally, there are lines describing the queries. They can be in the two formats described above, i.e.
- "
1": () - "
2": (, )
출력
For each query of type 1, output YES in one line if it is possible to make for all and NO otherwise.
힌트
In the first query, we start at vertex with counter states .
We move along the walk .
The counter states change as follows: .