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

24797번 - Through the Grapevine 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 (추가 시간 없음) 1024 MB378861.538%

문제

According to Wikipedia, to hear something "through the grapevine" is to learn of something informally and unofficially by means of gossip or rumor. In this problem, you are tasked with determining how many people will hear about a particular rumor "through the grapevine" after a certain number of days.

Rumors are always started by a single person. On any given day, a person who knows the rumor can spread it by telling the people that they know. Upon hearing of the rumor, that person must wait until the following day before they can begin to spread it themselves. Furthermore, some people are skeptical and will only spread the rumor once they've heard it from a number of distinct sources. However once a person has heard the rumor from enough people, they will always try to spread the rumor to as many people as possible.

입력

The first line will contain three integers: 0ドル < n \leq 100,000円,ドル 0ドル < m \leq 100,000円,ドル and 0ドル \leq d \leq 10,000円,ドル where $n$ is the number of people, $m$ is the number of connections, and $d$ is the number of days that elapse.

The next $n$ lines will each consist of a unique string $s$ and an integer 0ドル \leq t \leq 1000$ where $s$ is the name of a person and $t$ is their level of skepticism. In other words, person $s$ must hear the rumor from $t$ distinct other people before $s$ will begin spreading the rumor.

This is followed by $m$ lines each consisting of two strings $u$ and $v$ which indicates that person $u$ and person $v$ know each other. Each of these lines represents a unique pair of persons.

The final line will contain a single string $r,ドル the name of the person that the rumor originates from. Note that $r$ is the only person with skepticism $t = 0$. All strings are between 1ドル$ and 20ドル$ characters long and consists only of letters and digits.

출력

Output a single integer: the number of people (not including person $r$) that have heard the rumor after $d$ days.

제한

예제 입력 1

3 2 1
Alice 0
Bob 1
Carol 1
Alice Bob
Bob Carol
Alice

예제 출력 1

1

예제 입력 2

5 5 3
Alice 0
Bob 1
Carol 1
Dan 3
Erin 1
Alice Bob
Alice Carol
Bob Dan
Carol Dan
Dan Erin
Alice

예제 출력 2

3

힌트

출처

School > Virginia Tech High School Programming Contest > 2017 Virginia Tech High School Programming Contest E번

  • 문제를 만든 사람: Harrison Fang
(追記) (追記ここまで)

출처

대학교 대회

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

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