题意:

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 基础 2.8 python练习题

    python 练习题:   #/usr/bin/python #coding=utf-8 #@Time   :2017/10/26 9:38 #@Auther :liuzhenchuan #@File ...

  2. 初学shell,今天遇到由wget下载到本地的网页源代码的乱码问题,无聊的写了一个转码的脚本

    今天用wget想下载文件,结果下载了一堆本地的index.html文件,一查看全是乱码,然后百度了一下,网页的编码格式大概有三种: 1.utf-8 2.gb2312 3.gbk 要在网页源码中的< ...

  3. django使用自己的setting的方法

    创建一个自己的setting xxx.setting export DJANGO_SETTINGS_MODULE="xxx.setting" 然后在项目中import原生的sett ...

  4. 限制线程数 Limit the number of threads started by colly 随机延迟

    random delay | Colly http://go-colly.org/docs/examples/random_delay/

  5. dm层 集市层 四层 Build a multi-level data strategy

    集市层 四层模型 ODS(临时存储层) MID(中间层) DM(数据集市层) APP(应用层) http://www.datamartist.com/data-warehouse-vs-data-ma ...

  6. 题解 P3389 【【模板】高斯消元法】

    题解 P3389 [[模板]高斯消元法] 看到大家都没有重载运算符,那我就重载一下运算符给大家娱乐一下 我使用的是高斯-约旦消元法,这种方法是精度最高的(相对地) 一句话解释高斯约旦消元法: 通过加减 ...

  7. AsyncTask==Handler+Thread对比使用说明

    AsyncTask能够合理且轻松使用UI线程,该类允许执行后台操作和发送结果到UI线程而不需要操作threads或handlers. AsyncTask是针对Thread和Handler代替而封装好的 ...

  8. Spring IOC 容器源码分析(转)

    原文地址 Spring 最重要的概念是 IOC 和 AOP,本篇文章其实就是要带领大家来分析下 Spring 的 IOC 容器.既然大家平时都要用到 Spring,怎么可以不好好了解 Spring 呢 ...

  9. 3D焦点图插件

    在线演示 本地下载

  10. 【博弈论】hihocoder

    #1163 : 博弈游戏·Nim游戏 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 今天我们要认识一对新朋友,Alice与Bob. Alice与Bob总是在进行各种各样 ...