题意:

m维偏序问题。

解法:

考虑对每一维按照每一个元素在这一维的数值分块,对于每一个块维护一个大小为 n 的bitset,表示前缀/后缀满足条件的元素集合。

对于每一个询问,我们可以枚举找到相应的块,将剩余元素暴力插入,得到 m 个限制条件下分别的满足条件集合,最后和已插入元素求交即可。

$O(q \sqrt n m + \frac{nmq}{64})$

const int N = ,M = ;

struct node
{
int x[];
void scan()
{
FOR(i,,) scanf("%d",&x[i]);
}
}a[N]; bitset<N> blc[][M],ans[];
vector<int> pos[][N];
int n,m,siz,tot,L[M],R[M]; int main()
{
int T;
cin >> T;
while(T--)
{
cin >> n >> m;
FOR(i,,) FOR(j,,m) pos[i][j].clear();
FOR(i,,n)
{
a[i].scan();
FOR(j,,) pos[j][a[i].x[j]].pb(i);
}
siz = sqrt(m);
tot = m/siz+;
FOR(i,,) ans[i].reset();
FOR(i,,tot)
{
L[i] = max((i-)*siz,);
R[i] = min(i*siz-, m);
FOR(j,L[i],R[i]) FOR(k,,) for(auto x:pos[k][j]) ans[k].set(x);
FOR(k,,) blc[k][i] = ans[k];
}
int q,lastans=;;
node tmp;
cin >> q;
while(q--)
{
tmp.scan();
FOR(i,,) tmp.x[i]^=lastans;
FOR(t,,)
{
ans[t].reset();
int tp;
FOR(i,,tot)
if(R[i]>=tmp.x[t])
{
tp=i;
ans[t]=blc[t][i-];
break;
}
FOR(i,L[tp],tmp.x[t]) for(auto x:pos[t][i]) ans[t].set(x);
}
FOR(i,,) ans[]&=ans[i];
printf("%d\n",lastans = ans[].count());
}
}
return ;
}

scores的更多相关文章

  1. [LeetCode] Rank Scores 分数排行

    Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ra ...

  2. Codeforces Round #370 (Div. 2) D. Memory and Scores DP

    D. Memory and Scores   Memory and his friend Lexa are competing to get higher score in one popular c ...

  3. Faster RCNN 运行自己的数据,刚开始正常,后来就报错: Index exceeds matrix dimensions. Error in ori_demo (line 114) boxes_cell{i} = [boxes(:, (1+(i-1)*4):(i*4)), scores(:, i)];

    function script_faster_rcnn_demo() close all; clc; clear mex; clear is_valid_handle; % to clear init ...

  4. LeetCode Database: Rank Scores

    Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ra ...

  5. LeetCode:Rank Scores

    做到这题时卡了不少时间,参考了别人的解法,觉得挺不错的,还挺巧妙. SELECT s2.Score,s1.Rank From ( SELECT S1.Score, COUNT(*) as Rank F ...

  6. (Problem 22)Names scores

    Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-tho ...

  7. Memory and Scores

    Memory and Scores 题目链接:http://codeforces.com/contest/712/problem/D dp 因为每轮Memory和Lexa能取的都在[-k,k],也就是 ...

  8. [SQL]LeetCode178. 分数排名 | Rank Scores

    Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ra ...

  9. [LeetCode] Rank Scores -- 数据库知识(mysql)

    Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ra ...

  10. sql -leetcode 178. Rank Scores

    Score 很好得到: select Score from Scores order by Score desc; 要得到rank, 可以通过比较比当前Score 大的Score 的个数得到: sel ...

随机推荐

  1. Ubuntu 14.04下单节点Ceph安装(by quqi99)

    作者:张华  发表于:2014-06-23版权声明:能够随意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 (http://blog.csdn.net/quqi99 ) Ceph ...

  2. C#的默认访问权限(转)

    1.在namespace中的类.接口默认是internal类型的,也可以显示的定义为public类型,不允许是其他访问类型.2.在一个类里面,属性和方法默认是private的,可以显示的定义为publ ...

  3. 开启unity3D的学习之路

    2014年5月11号.我開始了我的Unity3D的学习之路.我将在此记录我学习过程中各个进程,这样在将来的某天,自己忘记了某部分内容时.也能够回过头来复习一下.

  4. Mongo 分组后排序取时间最大的一整条数据对象

    db.getCollection('product_protocol_new').aggregate([ {$sort:{"end_date":-1}}, {$group:{ _i ...

  5. PAT 天梯赛 L2-025. 分而治之 【图】

    题目链接 https://www.patest.cn/contests/gplt/L2-025 思路 只要把被攻下的城市标记一下 与 其他城市之间的通路都取消 然后判断一下剩下的城市 是否都是孤立的 ...

  6. Maven简介(六)——Dependency

    7      Dependency介绍 http://elim.iteye.com/category/269897 7.1     依赖的传递性 当项目A依赖于B,而B又依赖于C的时候,自然的A会依赖 ...

  7. HTML5_CSS3可切换注册登录表单

    在线演示 本地下载

  8. 让django完成翻译,迁移数据库模型

    声明:此Django分类下的教程是追梦人物所有,地址http://www.jianshu.com/u/f0c09f959299,本人写在此只是为了巩固复习使用 上篇我们完成了数据库模型的代码,但是还只 ...

  9. gVIM+zencoding快速开发HTML/CSS/JS(适用WEB前端)

    一.真正解决了UTF-8中文乱码的各种问题(菜单乱码,内容乱码,提示信息乱码),不用担心WIN用默认编码写的东西在Linux乱码,或在Linux(zh_CN.UTF-8时)写的东西在WIN下乱码.在A ...

  10. jquery 3D分页翻转滑块

    jquery 3D分页翻转滑块,jquery分页,jquery插件,jquery,3D翻转,css3分页,360度旋转,网页特效代码3D分页翻转滑块是一款使用网格样式与滑块效果分页的特效.