1 /**************************************************************
2 Problem: 3207
3 User: Tunix
4 Language: C++
5 Result: Accepted
6 Time:3164 ms
7 Memory:79404 kb
8 ****************************************************************/
9
10 //BZOJ 3207
11 #include<vector>
12 #include<cstdio>
13 #include<cstring>
14 #include<cstdlib>
15 #include<iostream>
16 #include<algorithm>
17 #define rep(i,n) for(int i=0;i<n;++i)
18 #define F(i,j,n) for(int i=j;i<=n;++i)
19 #define D(i,j,n) for(int i=j;i>=n;--i)
20 #define pb push_back
21 using namespace std;
22 inline int getint(){
23 int v=0,sign=1; char ch=getchar();
24 while(ch<‘0‘||ch>‘9‘){ if (ch==‘-‘) sign=-1; ch=getchar();}
25 while(ch>=‘0‘&&ch<=‘9‘){ v=v*10+ch-‘0‘; ch=getchar();}
26 return v*sign;
27 }
28 const int N=2e5+10,INF=~0u>>2;
29 typedef long long LL;
30 typedef unsigned long long u64;
31 /******************tamplate*********************/
32
33 int n,m,k,a[N],x[N],y[N];
34 u64 s[N],ask[N],c[N];
35 int rt[N],cnt,tot;
36 struct node{
37 int cnt,l,r;
38 }t[N*30];
39 #define mid (l+r>>1)
40 void update(int &o,int l,int r,int pos){
41 t[++tot]=t[o], o=tot, t[o].cnt++;
42 if (l==r) return;
43 if (pos<=mid) update(t[o].l,l,mid,pos);
44 else update(t[o].r,mid+1,r,pos);
45 }
46 int query(int i,int j,int val){
47 i=rt[i],j=rt[j];
48 int l=1,r=cnt;
49 while(l<r){
50 if (t[j].cnt-t[i].cnt==0) return 0;
51 if (val<=mid) r=mid,i=t[i].l,j=t[j].l;
52 else l=mid+1,i=t[i].r,j=t[j].r;
53 }
54 return t[j].cnt-t[i].cnt;
55 }
56 int main(){
57 #ifndef ONLINE_JUDGE
58 freopen("3207.in","r",stdin);
59 freopen("3207.out","w",stdout);
60 #endif
61 n=getint(); m=getint(); k=getint();
62 F(i,1,n) a[i]=getint();
63 n=n-k+1;
64 F(i,1,n){
65 F(j,i,i+k-1) s[i]=s[i]*131+a[j];
66 c[++cnt]=s[i];
67 }
68 F(i,1,m){
69 x[i]=getint(); y[i]=getint()-k+1;
70 F(j,1,k) ask[i]=ask[i]*131+getint();
71 c[++cnt]=ask[i];
72 }
73 sort(c+1,c+cnt+1);
74 cnt=unique(c+1,c+cnt+1)-c-1;
75 F(i,1,n) s[i]=lower_bound(c+1,c+cnt+1,s[i])-c;
76 F(i,1,m) ask[i]=lower_bound(c+1,c+cnt+1,ask[i])-c;
77 F(i,1,n){
78 rt[i]=rt[i-1];
79 update(rt[i],1,cnt,s[i]);
80 }
81 F(i,1,m){
82 if (query(x[i]-1,y[i],ask[i])) puts("No");
83 else puts("Yes");
84 }
85 return 0;
86 }