HihoCoder1236 Scores
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的更多相关文章
- [hihoCoder1236 Scores 2015BeijingOnline]简单粗暴的分块+简单粗暴的bitset
题意:50000个5维向量,50000次询问每一维都不大于某一向量的向量个数,强制在线. 思路:做完这题才知道bitset效率这么高,自己本地测试了下1s可以操作1010个bit,orz简单粗暴 令S ...
- hihocoder1236(北京网络赛J):scores 分块+bitset
北京网络赛的题- -.当时没思路,听大神们说是分块+bitset,想了一下发现确实可做,就试了一下,T了好多次终于过了 题意: 初始有n个人,每个人有五种能力值,现在有q个查询,每次查询给五个数代表查 ...
- 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 ...
- [LeetCode] Rank Scores 分数排行
Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ra ...
- 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 ...
- 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 ...
- 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 ...
- LeetCode:Rank Scores
做到这题时卡了不少时间,参考了别人的解法,觉得挺不错的,还挺巧妙. SELECT s2.Score,s1.Rank From ( SELECT S1.Score, COUNT(*) as Rank F ...
- (Problem 22)Names scores
Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-tho ...
随机推荐
- js 打印条形码
相应的文件大家去github上下载吧 https://github.com/lindell/JsBarcode <!DOCTYPE html> <html> <head& ...
- celery无法启动的问题 SyntaxError: invalid syntax
遇到了celery无法启动的问题,报错:SyntaxError: invalid syntax ,这是因为我使用的python版本为最新3.7.3 ,而async已经作为关键字而存在了 在 celer ...
- Springboot采用hibernate-validate验证请求参数
在springboot项目使用hibernate-validate对请求参数添加注解进行校验 常用注解 @Null,标注的属性值必须为空 @NotNull,标注的属性值不能为空 @AssertTrue ...
- Django 报错 admin.E408 admin.E409 admin.E410
报错内容 ERRORS: ?: (admin.E408) 'django.contrib.auth.middleware.AuthenticationMiddleware' must be in MI ...
- python 之网络并发(非阻塞IO模型)
实现gevent模块 服务端: from socket import * import time s = socket() s.bind(('127.0.0.1',8080)) s.listen(5) ...
- 图片url地址的生成获取方法
在写博客插入图片时,许多时候需要提供图片的url地址.作为菜鸡的我,自然是一脸懵逼.那么什么是所谓的url地址呢?又该如何获取图片的url地址呢? 首先来看一下度娘对url地址的解释:url是统一资源 ...
- linux 系统扩容 VMware Centos---VMware ESXi
用到的命令 df fdisk pvcreate pvdisplay vgdisplay vgextend lvdisplay lvextend resize2fs 0 ...
- vscode插件之背景插件(background)
1.在插件tab搜索background 2.打开vscode的配置页 { "background.useDefault": false, "background.cus ...
- Windows中的消息与消息队列
消息 在Windows中,消自由MSG结构体表示 typedef struct tagMSG { HWND hwnd; UINT message; WPARAM wParam; LPARAM lPar ...
- SQL Server修改表的模式schema
use myDBgo create schema myschema --先建立go alter schema myschema transfer dbo.myTable --移动对象至建立的schem ...