시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 1024 MB | 77 | 18 | 15 | 21.127% |
Pak Dengklek has just developed a social media site. There are $N$ users using the site, numbered $0$ to $N - 1$. There are $S$ hours in one day. All of these users have a fixed usage schedule from day to day. For each $i$ such that $0 ≤ i ≤ N - 1$, user $i$ will be online $T[i]$ times every day:
At any time, all users on the site like to share news to all other online users. Unfortunately, one of the $N$ users has a hoax at the start of the first day and will spread it. Hence, all users who meet the user with the hoax will also have the hoax at the end of the first day. Two users are stated to be met if there is at least an hour where the two users are both online.
This hoax will also be spread on the second day. Therefore, all users who meet the user with the hoax at the end of the first day will also have the hoax at the end of the second day. This continued the following days.
There are $Q$ scenarios, each can be represented as an integer $P$. For each scenario, the user who has the hoax at the start of the first day is user $P$. A different scenario might cause a different hoax spreading. Therefore, for each scenario, Pak Dengklek wonders on the number of users with the hoax at the end of the $N$th day, where $N$ is the number of users.
You should implement the following procedures:
void init(int N, int S, int[] T, int[][] A, int[][] B)
count_users
.int count_users(int P)
Consider the following sequence of calls:
init(5, 10, [2, 1, 1, 1, 1], [[2, 7], [1], [1], [9], [5]], [[4, 9], [3], [1], [10], [6]])
count_users(0)
This means user $0$ has the hoax at the start of the first day. User $0$ meets user $1$ (at the second hour to the third hour) and user $3$ (at the ninth hour). Therefore, at the end of the first day, the two users will have the hoax. User $1$ also meets user $2$ (at the first hour). Therefore, at the end of the second day, user $2$ will also have the hoax. There will be no hoax spreading on the third, fourth, and fifth day, thus $4$ users will have the hoax at the end of the fifth day. Therefore, the procedure should return $4$.
count_users(4)
This means user $4$ has the hoax at the start of the first day. User $4$ does not meet other users, thus other users will not have the hoax. Therefore, the procedure should return $1$.
번호 | 배점 | 제한 |
---|---|---|
1 | 15 | $N,S,Q ≤ 50$ and the sum of all elements of $T$ does not exceed $50$. |
2 | 17 | $N,Q ≤ 50$ and the sum of all elements of $T$ does not exceed $50$. |
3 | 21 | $N,Q ≤ 300$ and the sum of all elements of $T$ does not exceed $300$. |
4 | 26 | $N,Q ≤ 2000$ and the sum of all elements of $T$ does not exceed $2000$. |
5 | 21 | No additional constraints. |
The sample grader reads the input in the following format:
The sample grader prints your answers in the following format:
count_users
for scenario $k$C++17, C++20, C++17 (Clang), C++20 (Clang)