Scores

求五维偏序(≤)。强制在线。

\(n,q\le 50000\)

烂大街的题解

考虑如果我们能用bitset找到每一维有哪些比询问点小,然后把每一维的结果取交集,得到的就是答案了。

然后对每一维分块处理前缀,询问时二分得到排名,将前面整块的和末尾的合并一下就行了。

时间复杂度\(O(\frac{nq}{32})\)。分块对时间复杂度几乎没什么影响,重要的是bitset的操作。

#include<bits/stdc++.h>
#define co const
#define il inline
template<class T> T read(){
T x=0,w=1;char c=getchar();
for(;!isdigit(c);c=getchar())if(c=='-') w=-w;
for(;isdigit(c);c=getchar()) x=x*10+c-'0';
return x*w;
}
template<class T>il T read(T&x){
return x=read<T>();
}
using namespace std;
typedef long long LL;
typedef pair<int,int> pii; co int N=50000+1,M=250;
int n,m,q,L[M],R[M],B[N];
pii scores[5][N];
bitset<N> S[5][M],A[5]; void solve(int u,int x){
int t=lower_bound(scores[u],scores[u]+n,pii(x,n))-scores[u];
A[u]=S[u][B[t]-1];
for(int i=L[B[t]];i<t;++i) A[u][scores[u][i].second]=1;
}
void real_main(){
read(n),read(m);
for(int i=0;i<n;++i)
for(int j=0;j<5;++j) read(scores[j][i].first),scores[j][i].second=i;
int len=sqrt(n),block=n/len+(n%len?1:0);
L[0]=R[0]=-1;
for(int i=1;i<=block;++i) L[i]=(i-1)*len,R[i]=i*len;
R[block]=n;
for(int i=0;i<5;++i){
sort(scores[i],scores[i]+n);
S[i][0]=0;
for(int j=1;j<=block;++j){
S[i][j]=S[i][j-1];
for(int k=L[j];k<R[j];++k) S[i][j][scores[i][k].second]=1;
}
}
for(int i=1;i<=block;++i)
for(int j=L[i];j<R[i];++j) B[j]=i;
read(q);
int ans=0;
while(q--){
for(int i=0;i<5;++i) solve(i,read<int>()^ans);
for(int i=4;i;--i) A[i-1]&=A[i];
ans=A[0].count();
printf("%d\n",ans);
}
}
int main(){
for(int t=read<int>();t--;) real_main();
return 0;
}

HihoCoder1236 Scores的更多相关文章

  1. [hihoCoder1236 Scores 2015BeijingOnline]简单粗暴的分块+简单粗暴的bitset

    题意:50000个5维向量,50000次询问每一维都不大于某一向量的向量个数,强制在线. 思路:做完这题才知道bitset效率这么高,自己本地测试了下1s可以操作1010个bit,orz简单粗暴 令S ...

  2. hihocoder1236(北京网络赛J):scores 分块+bitset

    北京网络赛的题- -.当时没思路,听大神们说是分块+bitset,想了一下发现确实可做,就试了一下,T了好多次终于过了 题意: 初始有n个人,每个人有五种能力值,现在有q个查询,每次查询给五个数代表查 ...

  3. hihocoder1236(2015长春网赛J题) Scores(bitset && 分块)

    题意:给你50000个五维点(a1,a2,a3,a4,a5),50000个询问(q1,q2,q3,q4,q5),问已知点里有多少个点(x1,x2,x3,x4,x5)满足(xi<=qi,i=1,2 ...

  4. [LeetCode] Rank Scores 分数排行

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

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. LeetCode:Rank Scores

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

  9. (Problem 22)Names scores

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

随机推荐

  1. LeetCode 84. 柱状图中最大的矩形(Largest Rectangle in Histogram)

    84. 柱状图中最大的矩形 84. Largest Rectangle in Histogram

  2. spring boot 初始

    前言 与时俱进是每一个程序员都应该有的意识,当一个Java程序员在当代步遍布的时候,你就行该想到我能多学点什么.可观的是后端的框架是稳定的,它们能够维持更久的时间在应用中,而不用担心技术的更新换代.但 ...

  3. python 安装pytorch 及 安装失败解决办法

    python 安装pytorch 及 安装失败解决办法 [转] pytorch安装失败解决办法 [转] 一分钟在win10终端成功安装pytorch pytorch 的安装方法有2种,一种是pip安装 ...

  4. L2R 二:常用评价指标之AUC

    零零散散写了一些,主要是占个坑: AUC作为一个常用的评价指标,无论是作为最后模型效果评价还是前期的特征选择,都发挥着不可替代的作用,下面我们详细介绍下这个指标. 1.定义 2.实现 # coding ...

  5. LOJ2484 CEOI2017 Palindromic Partitions DP、回文树

    传送门 当我打开Luogu题解发现这道题可以Hash+贪心的时候我的内心是崩溃的-- 但是看到这道题不都应该认为这是一道PAM的练手好题么-- 首先把原字符串重排为\(s_1s_ks_2s_{k-1} ...

  6. [高清·非影印] 深度学习入门:基于Python的理论与实现 + 源代码

    ------ 郑重声明 --------- 资源来自网络,纯粹共享交流, 如果喜欢,请您务必支持正版!! --------------------------------------------- 下 ...

  7. 1+X证书学习日志——css 3D效果+立方体效果的实现

    形成一个3D的空间 transform-style: preserve-3d; ### 3D在2D的基础上,多了这些内容 位移 transform:translateZ(); 旋转 transform ...

  8. 十、vue mixins 的用法

    vue中mixins个人理解就是定义一些公用的比较常用的方法,类似我们vue中将一些常用的组件也会抽离出来做成一个公共组件一样,只不过vue中mixins是定义的是法或者计算属性,然后将其混入(合并) ...

  9. 【干货】小程序内嵌 H5 代码详解

    自从微信小程序发布了 web-view 组件,使得之前的 H5 网站移植到小程序成为可能.现在,很多项目在迁移的过程中遇到了许多问题,本文通过实例代码,为你讲解迁移过程中的几个典型场景. 1.小程序和 ...

  10. 字符串导出xml文件并弹出下载对话框

    转自:https://blog.csdn.net/zhandingfeng/article/details/53887354 导出单个xml文件:[java] view plain copy      ...