五维偏序。。一开始被吓到了,后来知道了一种BITSET分块的方法,感觉非常不错。

呆马:

 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <bitset>
#define inf 1000000007
#define maxn 52000
#define maxm 520 using namespace std; struct score
{
int x,y;
friend bool operator <(score a, score b)
{
return a.x<b.x;
}
}s[][maxn]; int n,m,p,num,block;
int bel[maxn],l[maxm],r[maxm];
int a[][maxn];
bitset<> b[][maxm];
bitset<> now[]; int main()
{
int Case;
scanf("%d",&Case);
for (int i=;i<=;i++) b[i][].reset();
for (int o=;o<=Case;o++)
{
scanf("%d%d",&n,&m);
for (int j=;j<=n;j++)
for (int i=;i<=;i++)
{
scanf("%d",&a[i][j]);
s[i][j].x=a[i][j];
s[i][j].y=j;
}
for (int i=;i<=;i++)
{
sort(s[i]+,s[i]+n+);
sort(a[i]+,a[i]+n+);
}
int block=sqrt(n);
int num=n/block+(n%block!=);
for (int i=;i<=n;i++) bel[i]=(i-)/block+;
for (int i=;i<=num;i++) l[i]=(i-)*block+;
for (int i=;i<=num;i++) r[i]=i*block;
r[num]=n;
for (int i=;i<=;i++)
for (int j=;j<=num;j++)
{
b[i][j]=b[i][j-];
for (int k=l[j];k<=r[j];k++)
b[i][j][s[i][k].y]=;
}
scanf("%d",&p);
int x[],ans=;
for (int q=;q<=p;q++)
{
for (int i=;i<=;i++) scanf("%d",&x[i]);
for (int i=;i<=;i++) x[i]^=ans;
for (int i=;i<=;i++) now[i].reset();
for (int i=;i<=;i++)
{
int tmp=upper_bound(a[i]+,a[i]+n+,x[i])-a[i]-;
if (tmp==) continue;
now[i]=b[i][bel[tmp]-];
for (int j=l[bel[tmp]];j<=tmp;j++)
now[i][s[i][j].y]=;
}
now[]=now[]&now[]&now[]&now[]&now[];
ans=now[].count();
printf("%d\n",ans);
}
}
return ;
}

Score

Hiho coder 1236 2015 北京网络赛 Score的更多相关文章

  1. hihocoder 1236(2015北京网络赛 J题) 分块bitset乱搞题

    题目大意: 每个人有五门课成绩,初始给定一部分学生的成绩,然后每次询问给出一个学生的成绩,希望知道在给定的一堆学生的成绩比这个学生每门都低或者相等的人数 因为强行要求在线查询,所以题目要求,每次当前给 ...

  2. 2015北京网络赛 D-The Celebration of Rabbits 动归+FWT

    2015北京网络赛 D-The Celebration of Rabbits 题意: 给定四个正整数n, m, L, R (1≤n,m,L,R≤1000). 设a为一个长度为2n+1的序列. 设f(x ...

  3. 2015北京网络赛 J Scores bitset+分块

    2015北京网络赛 J Scores 题意:50000组5维数据,50000个询问,问有多少组每一维都不大于询问的数据 思路:赛时没有思路,后来看解题报告也因为智商太低看了半天看不懂.bitset之前 ...

  4. 2015北京网络赛 Couple Trees 倍增算法

    2015北京网络赛 Couple Trees 题意:两棵树,求不同树上两个节点的最近公共祖先 思路:比赛时看过的队伍不是很多,没有仔细想.今天补题才发现有个 倍增算法,自己竟然不知道.  解法来自 q ...

  5. 2015北京网络赛 J Clarke and puzzle 求五维偏序 分块+bitset

    Clarke and puzzle Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://hihocoder.com/contest/acmicpc20 ...

  6. 2015北京网络赛B题 Mission Impossible 6

    借用大牛的一张图片:模拟 #include<cstdio> #include<cmath> #include<cstring> #include<algori ...

  7. 2015北京网络赛A题The Cats' Feeding Spots

    题意:给你一百个点,找个以这些点为中心的最小的圆,使得这个圆恰好包含了n个点,而且这个圆的边界上并没有点 解题思路:暴力枚举每个点,求出每个点到其他点的距离,取第n大的点,判断一下. #include ...

  8. 2015北京网络赛 F Couple Trees 暴力倍增

    Couple Trees Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://hihocoder.com/problemset/problem/123 ...

  9. 2015北京网络赛 G题 Boxes bfs

    Boxes Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://hihocoder.com/contest/acmicpc2015beijingonl ...

随机推荐

  1. Android自定义控件----RadioGroup实现APP首页底部Tab的切换

    ​[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/ ...

  2. Java实现MySQL数据库备份(二)

    权声明:本文为博主原创文章,未经博主允许不得转载. 博客<Java实现MySQL数据库备份(一)>使用I/O流的方式实现了MySQL数据库的备份,这种方法比较繁杂,下面介绍另一种备份MyS ...

  3. nodejs如何储存一个GBK编码的文件

    思路:utf-8 -> decode(to buffer) -> convert to gbk(buffer also) -> write buffer to file. var f ...

  4. 阿里云服务器Linux CentOS安装配置(三)yum安装mysql

    阿里云服务器Linux CentOS安装配置(三)yum安装mysql 1.执行yum安装mysql命令:yum -y install mysql-server mysql-devel 2.启动mys ...

  5. SQL TOP 子句、SQL LIKE 操作符、SQL 通配符

    TOP 子句 TOP 子句用于规定要返回的记录的数目. 对于拥有数千条记录的大型表来说,TOP 子句是非常有用的. 注释:并非所有的数据库系统都支持 TOP 子句. SQL Server 的语法: S ...

  6. ssh 文件权限影响登录

    进入/etc/ssh目录 需要保证文件访问控制权限如下: ssh_host_dsa_key 600 ssh_host_ras_key 600

  7. 学习Python的ABC模块(转)

    http://yansu.org/2013/06/09/learn-Python-abc-module.html 1.abc模块作用 Python本身不提供抽象类和接口机制,要想实现抽象类,可以借助a ...

  8. JPA 2.1 Coverter 注解

    @Converter(autoApply = true) public class VehicleConverter implements AttributeConverter<Vehicle, ...

  9. 最全的jQuery知识汇总

    本帖最后由 断天涯大虾 于 2016-12-26 10:22 编辑<ignore_js_op> jQuery是什么? jQuery是javascript编写一个可重用的JavaScript ...

  10. matlab备忘录

    1.使用运算符‘:’将矩阵的所有列拼成一列 2..'与'操作差别在复数运算时,'是复共轭转置,.'是转置 3.读取文件夹下的某类型文件 img_dir = dir('*.tif'); img_dir ...