Submit | All submissions | Best solutions | Back to list |
EIBUYGIFTS - Buy Gifts |
Today Ngan and her friends want to go buy gifts for their birthday friends next week. Given friend relationships, each person's birthday and current date. For each person, tell us how many of your friends have birthdays within the next k days (including the current date). Assume that the years considered are not leap years.
Input
The first line contains 4 integers: n, m, d, k are the number of people, the number of friendships, the current date. (0 ≤ n, m ≤ 2 * 105, 0 ≤ d ≤ 365). People are numbered from 0 to n – 1.
The ith number in the second line represents the date of birth of the ith person (day of year). (0 ≤ bi ≤ 365).
Each of the following m lines contains two integers u, v denoting that u and v are friends.
Output
For each person, output the number of friends that have birthdays in the next k days in one line.
Sample
Input |
Output |
5 6 10 7 9 10 15 16 18 1 3 1 4 1 2 0 2 4 0 0 1 |
2
|
Added by: | Ha Minh Ngoc |
Date: | 2021-03-19 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET |