RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00553

Birmingham

Unrated 레이팅 미적용
난이도
1s
시간 제한
512MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

It is well known that all horse races in Birmingham are fixed days in advance.
It is a little less known that people who fix these races (and thereby know
the winner) do that on a secret meeting and start spreading the information
around the city the day after that meeting.
The first day after the meeting, all people that know the information about
the winner start sharing that information with all people that live at most
\(K\) steps away from their house.
The second day after the meeting, all people that know the information about the winner start sharing
that information with all people that live at most \(2 \cdot K\) steps away from their house.
In general, \(X-th\) day after the meeting, all people that know the information about the winner start
sharing that information with all people that live at most \(X \cdot K\) steps away from their house.
We can represent Birmingham as a graph where vertices represent the houses and edges represent
bidirectional roads which connect these houses. Houses are indexed with increasing integers from 1 to \(N\)
and we say that a person can travel each road in a single step. It is possible to reach each house from
each other house by traversing a sequence of roads.
Your task is to determine, for each house, on which day will the information about the race winner reach
it.

제약

In the test cases worth a total of 20 points, it will hold \(K = 1\), \(1 \le N\), \(Q \le 100\) and \(1 \le M \le 200\).
In the test cases worth an additional 15 points, it will hold \(1 \le N\), \(Q \le 100\) and \(1 \le M \le 200\).

입력 형식

The first line contains four integers \(N\), \(M\), \(Q\) and \(K\) (\(1 \le N\), Q, \(K \le 100\,000\), \(Q \le N\), \(1 \le M \le 200\,000\)),
the number of houses in Birmingham, the number of roads in Birmingham, the number of people that
were present on the secret meeting and the number \(K\) from task description.
The next line contains \(Q\) integers where the \(i-th\) integer represents the index of a house where the \(i-th\)
person from the secret meeting lives in.
The \(i-th\) of the next \(M\) lines contains integers \(A@@RISE_MATH_BLOCK_0@@i\) (\(1 \le A@@RISE_MATH_BLOCK_1@@i\)), which denote that
the \(i-th\) road connects houses with indices \(A_{i}\) and \(B_{i}\).

출력 형식

Output \(N\) numbers where the \(i-th\) number represents on which day after the meeting will the person
living in house with index \(i\) find out who will win the race. If the person living in that house was present
on the secret meeting, output 0 instead.

예제 1
입력
6 8 1 1
6
1 3
1 5
1 6
2 5
2 6
3 4
3 5
5 6
출력
1 1 2 2 1 0
예제 2
입력
6 8 2 1
6 4
1 3
1 5
1 6
2 5
2 6
3 4
3 5
5 6
출력
1 1 1 0 1 0
예제 3
입력
6 8 1 2
6
1 3
1 5
1 6
2 5
2 6
3 4
3 5
5 6
출력
1 1 1 2 1 0
설명

Clarification of the third example: The figure represents a graph from the third example. Since
houses 1, 2, 3 and 5 are at most two steps away from house 6, people living in them will find out about
the winner the day after the meeting. Person living in house 4 will find out about the winner two days
after the meeting.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2019/2020 Contest 6

평가 및 의견

Birmingham

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Birmingham

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8