题意:
求多维偏序下比给定值小的个数。
题解:
不多说,这种毒瘤题直接bitset+分块吧。。
#include<bits/stdc++.h>
using namespace std;
inline int rd(){
char ch=getchar();int i=0,f=1;
while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
while(isdigit(ch)){i=(i<<1)+(i<<3)+ch-'0';ch=getchar();}
return i*f;
}
int n,m,S,cnt,v[300],lst;
struct data{
int a[6];
}a[50010];
bitset<50010>win[6][300];
vector< pair<int,int> >t[6];
inline void getorder(int val,int id,bitset<50010> &A){
int pos=1;while(v[pos]<val&&pos<=cnt)++pos;
if(pos>1)A=win[id][pos-1];
pos=lower_bound(t[id].begin(),t[id].end(),make_pair(v[pos-1]+1,0))-t[id].begin();
while(pos<n&&t[id][pos].first<=val)
A.set(t[id][pos].second),++pos;
}
inline void solve(){
n=rd();m=rd();
S=sqrt(m)+1;
cnt=0;lst=0;
while(S*cnt<m)++cnt,v[cnt]=min(S*cnt,m);
for(int i=1;i<=5;i++){
t[i].clear();
for(int j=1;j<=cnt;j++)
win[i][j].reset();
}
for(int i=1;i<=n;i++)
for(int j=1;j<=5;j++){
a[i].a[j]=rd();
t[j].push_back(make_pair(a[i].a[j],i));
int pos=1;
while(v[pos]<a[i].a[j])++pos;
win[j][pos].set(i);
}
for(int i=1;i<=5;i++){
sort(t[i].begin(),t[i].end());
for(int j=2;j<=cnt;j++)
win[i][j]|=win[i][j-1];
}
int q=rd();
for(int i=1;i<=q;i++){
bitset<50010> tp;
bitset<50010> tp2;
tp.reset();tp2.reset();
tp|=(getorder(rd()^lst,1,tp2),tp2);
for(int j=2;j<=5;j++){
tp2.reset();
tp&=(getorder(rd()^lst,j,tp2),tp2);
}
lst=tp.count();
printf("%d\n",lst);
}
}
int main(){
int T;T=rd();
while(T--)solve();
}