Logo
(追記) (追記ここまで)

33299번 - Mod Graph 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB321100.000%

문제

You are given an undirected, connected graph with $n$ vertices. Every vertex $v$ has a counter that operates modulo $b_v$. The initial state of that counter is $a_v$. Every time you visit that vertex, it is increased by one (i.e. $a_v \leftarrow (a_v + 1) \bmod b_v$).

You have to process $q$ queries of the following two types:

  • "1 $s$": Suppose that you start at vertex $s,ドル you have to answer whether it is possible to make $a_v = 0$ for all $v$. You are allowed to take an arbitrary walk through $G,ドル i.e. you can use edges and vertices multiple times. Note that starting the walk at $s$ already counts as visiting $s,ドル i.e. its counter is increased by one initially.
  • "2 $v$ $x$": Update $a_v \leftarrow x$.

입력

The first line contains three integers $n,ドル $m,ドル and $q$ (1ドル \leq n,q \leq 5 \cdot 10^4,ドル 0ドル \leq m \leq 10^5$) --- the number of vertices, edges, and queries, respectively.

The second line contains $n$ integers $a_1, \ldots, a_n$.

The third line contains $n$ integers $b_1, \ldots, b_n$ (0ドル \leq a_v < b_v \leq 10^9$).

The following $m$ lines contain the edges of the graph. Each of those $m$ lines contains two integers $u$ and $v$ (1ドル \leq u, v \leq n,ドル $u \neq v$) describing an edge connecting vertices $u$ and $v$. The given graph is connected.

Finally, there are $q$ lines describing the queries. They can be in the two formats described above, i.e.

  • "1 $s$": (1ドル \leq s \leq n$)
  • "2 $v$ $x$": (1ドル \leq v \leq n,ドル 0ドル \leq x < b_v$)

출력

For each query of type 1, output YES in one line if it is possible to make $a_v = 0$ for all $v$ and NO otherwise.

제한

예제 입력 1

2 1 4
0 0
3 3
1 2
1 1
2 1 1
1 1
1 2

예제 출력 1

YES
NO
YES

노트

In the first query, we start at vertex 1ドル$ with counter states $[1, 0]$.

We move along the walk 1ドル \rightarrow 2 \rightarrow 1 \rightarrow 2 \rightarrow 1 \rightarrow 2$.

The counter states change as follows: $[1, 0] \rightarrow [1, 1] \rightarrow [2, 1] \rightarrow [2, 2] \rightarrow [0, 2] \rightarrow [0, 0]$.

출처

Camp > Petrozavodsk Programming Camp > Summer 2024 > Day 5: Der Kontest H번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /