No.2220 Range Insert & Point Mex
タグ : / 解いたユーザー数 106
作問者 :
stoq
/ テスター :
ぷら
Problem Statement
There are $10^9$ sets $S_1,S_2,\dots,S_{10^9}$. Initially, all of the sets are empty.
First, $N$ operations are performed on these sets. The $i$-th operation $(1 \le i \le N)$ is described by a tuple $(l_i,r_i,a_i)$ as follows.
- For $j = l_i,l_i+1,\dots,r_i$, replace $S_j$ with $S_j \cup \{ a_i \}$.
Next, $Q$ integers $x_1,\dots,x_Q$ are given.
For each $i=1,\dots,Q$, find ${\rm Mex}(S_{x_i})$.
Here, ${\rm Mex}(X)$ denotes the smallest non-negative integer not contained in $X$.
Input
$N$ $l_1$ $r_1$ $a_1$ $\vdots$ $l_N$ $r_N$ $a_N$ $Q$ $x_1$ $\dots$ $x_Q$
- All input values are integers.
- $1\le N \le 10^5$
- $1 \le l_i \le r_i \le 10^9$
- $0 \le a_i \le 10^9$
- $1 \le Q \le 10^5$
- $1 \le x_1 < x_2 < \cdots < x_Q \le 10^9$
Output
On line $i\ (1 \le i \le Q)$, print ${\rm Mex}(S_{x_i})$.
Sample
Sample 1
Input
4 1 3 0 2 3 2 3 5 1 5 5 0 6 1 2 3 4 5 6
Output
1 1 3 0 2 0
After all the operations are performed, the sets $S_i$ are as follows.
- $S_1 = \{ 0\}$
- $S_2 = \{ 0,2 \}$
- $S_3 = \{ 0,1,2 \}$
- $S_4 = \{ 1 \}$
- $S_5 = \{ 0,1 \}$
- $S_6 = S_7 = \cdots = S_{10^9} = \{ \}$
Sample 2
Input
6 1 1 0 1 1 2 1 1 1 1 1 0 1 1 3 1 1 2 1 1
Output
4
We have $S_1 = \{ 0,1,2,3 \}$.
Sample 3
Input
8 10 100000 0 1000000 1000000000 0 1 1000000000 1 100 10000 2 100000 100000000 2 100 1000 3 1000 1000 4 1000000000 1000000000 1000000000 10 1 10 100 1000 10000 100000 1000000 10000000 100000000 1000000000
Output
0 2 4 5 3 3 3 3 3 2
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。