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

33204번 - Old Orhei 서브태스크다국어

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

문제

Old Orhei (Orheiul Vechi) is a natural and historical complex located on a narrow bend of the Răut River. It consists of $N$ archaeological vestiges and $M$ one-way roads between some pairs of vestiges. Every road has a unique index between 1ドル$ and $M,ドル defined by the input order in which it is given. Please refer to the Examples section for visualizing such a configuration.

Recently an array left by the Cucuteni–Trypillia civilization was discovered by the local scientists. The array consists of $T$ integers with values between 1ドル$ and $M$. In order to figure out the mystical meaning of this array, the new intern will be instructed to follow this procedure:

At the beginning, the intern starts at some initial archaeological vestige. The other scientists start broadcasting to him a contiguous sub-array of the main array (first broadcasting the first element of the subarray, then the second one, and so on). The intern then changes his location depending on the following rules:

  • If the intern can use the road indexed with the current broadcast number (in other words, the intern's current location is equal to the starting point of the corresponding road), the intern traverses it (goes to the end-point of the corresponding road).
  • Otherwise the intern does nothing, and remains in his current location.

With the occasion of the 8ドル$-th European Junior Olympiad in Informatics, the local scientists have asked you to help them perform the following $Q$ queries:

  • 1ドル$ $L$ $R$ $S$ - the scientists want to know what will be the final location of the intern if initially he is located in the $S$-th vestige, and only the contiguous sub-array of the initial array which starts at index $L$ and ends at index $R$ is broadcasted.
  • 2ドル$ $i$ $K$ - the scientists override the $i$-th element of the array with the value $K$. The change is permanent. (In other words, the array changes so that $A_i = K$ after performing the query).

Your task is to answer correctly to all the queries of type 1ドル$.

입력

The first line contains two space-separated integers $N$ and $M,ドル the number of archaeological vestiges and one-way roads.

The next $M$ lines contain the description of the roads. In particular, line i will contain two space-separated numbers indicating that the $i$-th road starts in $X_i$ and ends in $Y_i$. There can exist roads for which $X_i = Y_i$ as well as pairs of roads for which $X_i = X_j$ , $Y_i = Y_j$ but $i \ne j$.

The next line contains an integer $T,ドル the length of the found array.

The next line contains $T$ space-separated integers $A_1 ,A_2, \dots ,A_T,ドル representing the array elements.

The next line contains an integer $Q,ドル the number of queries.

The next $Q$ lines contain the query description:

  • 1ドル$ $L$ $R$ $S$ for a query of type 1ドル$.
  • 2ドル$ $i$ $K$ for a query of type 2ドル$.

출력

For each query of type 1ドル$ output the answer on a separate line.

제한

  • 1ドル ≤ N ≤ 50$
  • 1ドル ≤ M,T,Q ≤ 10^5$
  • 1ドル ≤ X ,Y ≤ N$
  • 1ドル ≤ A ≤ M$
  • 1ドル ≤ L ≤ R ≤ T$
  • 1ドル ≤ S ≤ N$
  • 1ドル ≤ i ≤ T$
  • 1ドル ≤ K ≤ M$

서브태스크

번호배점제한
17

$Q = 1$ (The only existing query is of type 1ドル$).

216

$N = 2$

317

$M = N - 1,ドル $X_i = i,ドル $Y_i = i + 1$.

431

There are no queries of type 2ドル$. Additionally, $T ≤ 3 \cdot 10^4$.

529

No additional constraints.

예제 입력 1

5 6
1 2
3 2
4 2
2 5
5 1
4 5
6
2 1 4 2 5 3
3
1 3 5 2
1 3 5 2
1 1 2 3

예제 출력 1

1
1
2

Initially, the intern starts in vestige 2, and the sub-array broadcasted is [4, 2, 5].

The number 4ドル$ is broadcasted so the intern moves to vestige 5ドル,ドル since the road with index 4ドル$ can be traversed.

Afterwards, number 2ドル$ is broadcasted. The intern remains in the same location as the road with index 2ドル$ cannot be used.

Finally, number 5ドル$ is broadcasted, and the intern can traverse the corresponding road, so the intern ends up in vestige 1ドル,ドル which is the answer for that corresponding query.

예제 입력 2

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

예제 출력 2

2
1
3

예제 입력 3

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

예제 출력 3

1
2

For the first query the intern will traverse the first road going from vestige 1ドル$ to itself two times in a row, hence the answer for this query is 1ドル$.

The second query updates the first element of the array to 2ドル$.

During the third query the number 2ドル$ is first broadcasted to the intern located in vestige 1ドル$. Since the corresponding road is adjacent to this vestige, the intern traverses it and changes his location to vestige 2ドル$. Finally, number 1ドル$ is broadcasted, and the intern cannot traverse the corresponding road, so the intern's end location is vestige 2ドル$.

힌트

출처

Olympiad > European Junior Olympiad in Informatics > eJOI 2024 3번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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