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 ti. The bigger this value is, the better the friendship is. No two friends have the same value ti.
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 ti.
Your task is to handle queries of two types:
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 ≤ 150 000, 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 t1, t2, ..., tn (1 ≤ ti ≤ 109) where ti describes how good is Limak's relation with the i-th friend.
The i-th of the following q lines contains two integers typei and idi (1 ≤ typei ≤ 2, 1 ≤ idi ≤ n) — the i-th query. If typei = 1 then a friendidi becomes online. If typei = 2 then you should check whether a friend idi is displayed.
It's guaranteed that no two queries of the first type will have the same idi becuase one friend can't become online twice. Also, it's guaranteed that at least one query will be of the second type (typei = 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.
4 2 8 300 950 500 200 1 3 2 4 2 3 1 1 1 2 2 1 2 2 2 3
NO YES NO YES YES
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
NO YES NO YES
In the first sample, Limak has 4 friends who all sleep initially. At first, the system displays nobody because nobody is online. There are the following 8 queries:
#include<stdio.h> #include<iostream> #include<string.h> #include<string> #include<ctype.h> #include<math.h> #include<set> #include<map> #include<vector> #include<queue> #include<bitset> #include<algorithm> #include<time.h> using namespace std; void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); } #define MS(x,y) memset(x,y,sizeof(x)) #define MC(x,y) memcpy(x,y,sizeof(x)) #define MP(x,y) make_pair(x,y) #define ls o<<1 #define rs o<<1|1 typedef long long LL; typedef unsigned long long UL; typedef unsigned int UI; template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b>a)a = b; } template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b<a)a = b; } const int N = 150010, M = 0, Z = 1e9 + 7, ms63 = 0x3f3f3f3f; int n, k, q; int op, o; int t[N]; set<int>sot; set<int>::iterator it; int main() { while (~scanf("%d%d%d", &n, &k, &q)) { sot.clear(); for (int i = 1; i <= n; ++i)scanf("%d", &t[i]); while (q--) { scanf("%d%d", &op, &o); if (op == 1)sot.insert(t[o]); else { bool flag = 0; int p = 0; if(sot.size())for (it = --sot.end(); ; --it) { if (++p > k)break; if (*it == t[o]) { flag = 1; break; } if (it == sot.begin())break; } puts(flag ? "YES" : "NO"); } } } return 0; } /* 【题意】 有n(15e4)个朋友 有q(15e4)个事件。 friend list即时只是显示前k(min(6,k))个在线着 对于每个事件,有两种类型—— (1 id)某人上线 (2 id)询问某人是否在线且排在优先度的前k名 【类型】 水题 【分析】 这题可以直接用set维护。 也可以只维护一个长度为6的数组,记录最大的前6个。 【时间复杂度&&优化】 O(6q) */