题库练习 Bear and Displayed Friends
← 上一题 下一题 →

A10339 | Bear and Displayed Friends

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Limak is a little polar bear. He loves connecting with other bears via social networks. He has $n$ friends and his relation with the $i$ -th of them is described by a unique integer $t_{i}$ . The bigger this value is, the better the friendship is. No two friends have the same value $t_{i}$ .

Spring is starting and the Winter sleep is over for bears. Limak has just woken up and logged in. All his friends still sleep and thus none of them is online. Some (maybe all) of them will appear online in the next hours, one at a time.

The system displays friends who are online. On the screen there is space to display at most $k$ friends. If there are more than $k$ friends online then the system displays only $k$ best of them — those with biggest $t_{i}$ .

Your task is to handle queries of two types:

- "1 id" — Friend $id$ becomes online. It's guaranteed that he wasn't online before.
- "2 id" — Check whether friend $id$ is displayed by the system. Print "YES" or "NO" in a separate line.

Are you able to help Limak and answer all queries of the second type?

输入格式

The first line contains three integers $n$ , $k$ and $q$ ( $1<=n,q<=150000,1<=k<=min(6,n)$ ) — the number of friends, the maximum number of displayed online friends and the number of queries, respectively.

The second line contains $n$ integers $t_{1},t_{2},...,t_{n}$ ( $1<=t_{i}<=10^{9}$ ) where $t_{i}$ describes how good is Limak's relation with the $i$ -th friend.

The $i$ -th of the following $q$ lines contains two integers $type_{i}$ and $id_{i}$ ( $1<=type_{i}<=2,1<=id_{i}<=n$ ) — the $i$ -th query. If $type_{i}=1$ then a friend $id_{i}$ becomes online. If $type_{i}=2$ then you should check whether a friend $id_{i}$ is displayed.

It's guaranteed that no two queries of the first type will have the same $id_{i}$ becuase one friend can't become online twice. Also, it's guaranteed that at least one query will be of the second type ( $type_{i}=2$ ) so the output won't be empty.

输出格式

For each query of the second type print one line with the answer — "YES" (without quotes) if the given friend is displayed and "NO" (without quotes) otherwise.

输入输出样例

输入 #1
4 2 8
300 950 500 200
1 3
2 4
2 3
1 1
1 2
2 1
2 2
2 3
输出 #1
NO
YES
NO
YES
YES
输入 #2
6 3 9
50 20 51 17 99 24
1 3
1 4
1 5
1 2
2 4
2 2
1 1
2 4
2 3
输出 #2
NO
YES
NO
YES
C++ 编辑器
输入
输出