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

27430번 - Gossips 다국어

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

문제

Poli is in her first year at college. Although she went to one of the best universities she quickly discovered that her colleagues are split into N friendship groups, the main purpose of these groups being spreading gossips. Poli knows that each group i is formed out of one or more subgroups so that each subgroup can be a part of only one group. Now, let's say that a group i finds a gossip about group j; then all the subgroups of i (and the subgroups of these subgroups etc.) and all the groups of which group i is a part of know the gossip about group j. Also all of these groups know the gossip about every group of which group j is a part of (but they don't know anything about the subgroups of j, because those members may not be implicated in the gossip).

Because Poli is a friend with every one of her colleagues she knows when a gossip appears (that is when a group i finds a gossip about a group j). Now she wants to be able to answer fast to questions like: << Does a group i know a gossip about group j? >>.

Unfortunately Poli's college is rather big, so you have to help her!

입력

On the first line of the standard input there are three numbers N - the number of groups, M - the number of relations between the groups and Q - the number of queries. Next there are M lines of the form a b representing that group b is a subgroup of group a. The next Q lines have three numbers each: s - the type of query, and x y - two groups. If s is 1 then you have to answer YES if there is at least one gossips between group x and group y or NO if not. If s is 2 then group x just found out a gossip about group y.

출력

You must print to the standard output several lines, one for each query of type 1, each line being YES or NO (without quotation marks).

제한

  • 1 ≤ N, Q ≤ 100,000
  • 1 ≤ M < N
  • 1 ≤ x, y ≤ N
  • if a group i knows a gossip about group j it doesn't mean that group j knows also a gossip about i.

예제 입력 1

9 7 7
6 1
6 2
7 6
7 3
8 4
8 5
9 7
2 6 4
2 8 6
1 2 4
1 2 5
1 4 7
1 8 1
1 5 9

예제 출력 1

YES
NO
YES
NO
YES

힌트

출처

Olympiad > Romanian Master of Informatics > Romanian Master of Informatics 2011 4번

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

출처

대학교 대회

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

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