아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Through the Grapevine

면접 대비

시간 제한4초메모리 제한1024 MB

요약
각 사람이 서로 다른 이웃 t명에게 소문을 들은 뒤에야 퍼뜨리기 시작하는 그래프에서 d일 후 소문을 아는 사람 수를 센다.
난이도

보통10점 중 5점

유형
그래프, BFS, 시뮬레이션
정답자
아직 제출이 없습니다

문제

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≤100,0000 < n \leq 100\\,000, 0<m≤100,0000 < m \leq 100\\,000, and 0≤d≤10,0000 \leq d \leq 10\\,000, where nn is the number of people, mm is the number of connections, and dd is the number of days that elapse.

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

This is followed by mm lines each consisting of two strings uu and vv which indicates that person uu and person vv know each other.  Each of these lines represents a unique pair of persons.

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

출력

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

예제2

  1. 예제 1

    입력
    3 2 1
    Alice 0
    Bob 1
    Carol 1
    Alice Bob
    Bob Carol
    Alice
    
    예상 출력
    1
    
  2. 예제 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
    
    예상 출력
    3