题意:

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. python 基础 4.5 用函数实现九九乘法表

    #/usr/bin/python #coding=utf-8 #@Time   :2017/11/3 10:44 #@Auther :liuzhenchuan #@File   :用函数实现九九乘法口 ...

  2. 用apache做为代理下载本地pdf文件

    有一些公司会用apache做为代理,下载服务器上的pdf文件.以下是apache做为代理的配置 一. 环境 centos6.5  192.168.69.3 二. yum安装apache 服务 [zxj ...

  3. BZOJ 1597: [Usaco2008 Mar]土地购买 斜率优化

    1597: [Usaco2008 Mar]土地购买 Time Limit: 10 Sec  Memory Limit: 162 MB Description 农夫John准备扩大他的农场,他正在考虑N ...

  4. 【分享】自己写的一个可空的DateTimePicker控件-附源码

    最近这段时间在重构以前的一个项目,其中有一项就是要把DateTimePicker控件值可空.大家都知道的DateTimePicker值为DateTime类型,DateTime类型值不能等于Null.但 ...

  5. iOS 10 权限配置大全

    <!-- 相册 --> <key>NSPhotoLibraryUsageDescription</key> <string>App需要您的同意,才能访问 ...

  6. 一起来学linux:shell script(二)关于脚本

    (一)首先来看shell脚本的执行方式,shell脚本的后缀名都是sh文件. 1 sh test.sh 2 source test.sh 这两种方式有什么区别呢.test.sh 里的脚本很简单, 从键 ...

  7. python cookbook第三版学习笔记十四:类和对象(五)代理类以及内存回收

    代理类: 代理类的作用其实有继承有些类似,如果你想将某个实例的属性访问代理到内部另外一个实例中去,可以用继承也可以用代理.来看下代理的应用: class A:     def spam(self,x) ...

  8. MySQL——多版本并发控制

    核心心知识点: (1)MVCC的优点和缺点 (2)MVCC的工作机制 之前在提及幻读的时候,提到过InnoDB的多版本并发控制可以解决幻读问题. 大多数MySQL的事务性存储引擎,例如InnoDB.F ...

  9. Android Wifi简单的梳理【转】

    本文转载自:http://blog.csdn.net/gabbzang/article/details/10005411 代表一个已经配置过的网络.包含网络ID(networkId).该网络ID代表的 ...

  10. Spring Boot2.0之多数据源分布式事务问题

    分布式事务解决方案的问题, 分布式事务产生的原因: 多个不同的服务连接不同的数据源 ,做分布式事务的管理. 这种情况是连接两个数据源的情况,然后事务管理器是这样的 只管理了test02的这端业务代码. ...