CF639A.Bear and Displayed Friends

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Limak is a little polar bear. He loves connecting with other bears via social networks. He has nn friends and his relation with the ii -th of them is described by a unique integer tit_{i} . The bigger this value is, the better the friendship is. No two friends have the same value tit_{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 kk friends. If there are more than kk friends online then the system displays only kk best of them — those with biggest tit_{i} .

Your task is to handle queries of two types:

  • "1 id" — Friend idid becomes online. It's guaranteed that he wasn't online before.
  • "2 id" — Check whether friend idid 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 nn , kk and qq ( 1<=n,q<=150000,1<=k<=min(6,n)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 nn integers t1,t2,...,tnt_{1},t_{2},...,t_{n} ( 1<=ti<=1091<=t_{i}<=10^{9} ) where tit_{i} describes how good is Limak's relation with the ii -th friend.

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

It's guaranteed that no two queries of the first type will have the same idiid_{i} becuase one friend can't become online twice. Also, it's guaranteed that at least one query will be of the second type ( typei=2type_{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
    

说明/提示

In the first sample, Limak has 44 friends who all sleep initially. At first, the system displays nobody because nobody is online. There are the following 88 queries:

  1. "1 3" — Friend 33 becomes online.
  2. "2 4" — We should check if friend 44 is displayed. He isn't even online and thus we print "NO".
  3. "2 3" — We should check if friend 33 is displayed. Right now he is the only friend online and the system displays him. We should print "YES".
  4. "1 1" — Friend 11 becomes online. The system now displays both friend 11 and friend 33 .
  5. "1 2" — Friend 22 becomes online. There are 33 friends online now but we were given k=2k=2 so only two friends can be displayed. Limak has worse relation with friend 11 than with other two online friends ( t_{1}<t_{2},t_{3} ) so friend 11 won't be displayed
  6. "2 1" — Print "NO".
  7. "2 2" — Print "YES".
  8. "2 3" — Print "YES".
首页