### 题目描述

#### 样例输入

6 3 2
1 3
3 6
1 3
4 2 2 3 0 7
5 3 8 2 1 9

#### 样例输出

AC
WA

### 代码

#include <bits/stdc++.h>
#define maxm 1001000
#define maxn 1505
#define ls (p<<1)
#define rs (p<<1|1)
#define mid ((l+r)>>1)
#define min(a,b) (a<b?a:b)
struct ios{
static const int IN_LEN=1<<18|1;
static char buf[IN_LEN],*s,*t;
}
template <typename _Tp> inline ios & operator >> (_Tp&x){
static char c11,boo;
if(c11==-1)return *this;
boo|=c11=='-';
}
boo&&(x=-x);
return *this;
}
}io;
struct Node{
int val,id;
Node(int a=0,int b=0){
val=a,id=b;
}
bool operator < (const Node &x) const{
return val==x.val?id<x.id:val<x.val;
}
}per[maxn];
struct Opera{
int x,y;
Opera(int a=0,int b=0){
x=a,y=b;
}
}ope[maxm];
int n,m,q,c[maxn],b[maxn];
int posc[maxn],posb[maxn];
std::set<int>s;
inline void Sort(int l,int r){
int t=*s.upper_bound(l-1);
while(t>=l&&t<r){
s.erase(t);
c[t]^=c[t+1]^=c[t]^=c[t+1];
if (c[t-1]<c[t]) s.insert(t-1);
if (c[t+1]<c[t+2]) s.insert(t+1);
t=*s.upper_bound(l-1);
}
}
int t[maxn<<2],a[maxn<<2];
inline void Pushup(int p){
t[p]=min(t[ls],t[rs]);
}
inline void Pushdown(int p){
int lp=a[p];a[p]=0;
a[ls]+=lp;a[rs]+=lp;
t[ls]+=lp;t[rs]+=lp;
}
inline void Update(int l,int r,int L,int R,int v,int p){
if (l>=L&&r<=R){t[p]+=v;a[p]+=v;return;}
if (a[p]) Pushdown(p);
if (mid>=L) Update(l,mid,L,R,v,ls);
if (mid<R) Update(mid+1,r,L,R,v,rs);
Pushup(p);
}
int main(){
io>>n>>m>>q;
for (register int i=1;i<=n;++i) c[i]=i;
for (register int i=1;i<n;++i) s.insert(i);
for (register int i=1,l,r;i<=m;++i)
io>>l>>r,ope[i]=Opera(l,r);
for (register int i=m;i>=1;--i) Sort(ope[i].x,ope[i].y);
for (register int i=1;i<=n;++i) posc[c[i]]=i;
while(q--){
memset(t,0,sizeof(t));
memset(a,0,sizeof(a));
for (register int i=1,x;i<=n;++i)
io>>x,per[i]=Node(x,i);
std::sort(per+1,per+1+n);
for (register int i=1;i<=n;++i) b[per[i].id]=i;
for (register int i=1;i<=n;++i) posb[b[i]]=i;
bool flag=1;
for (register int k=1;k<=n;++k){
Update(1,n,posc[k],n,-1,1);
Update(1,n,posb[k],n,1,1);
if (t[1]<0){flag=0;break;}
}
puts(flag?"AC":"WA");
}
}