Hiho coder 1236 2015 北京网络赛 Score
五维偏序。。一开始被吓到了,后来知道了一种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的更多相关文章
- hihocoder 1236(2015北京网络赛 J题) 分块bitset乱搞题
题目大意: 每个人有五门课成绩,初始给定一部分学生的成绩,然后每次询问给出一个学生的成绩,希望知道在给定的一堆学生的成绩比这个学生每门都低或者相等的人数 因为强行要求在线查询,所以题目要求,每次当前给 ...
- 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 ...
- 2015北京网络赛 J Scores bitset+分块
2015北京网络赛 J Scores 题意:50000组5维数据,50000个询问,问有多少组每一维都不大于询问的数据 思路:赛时没有思路,后来看解题报告也因为智商太低看了半天看不懂.bitset之前 ...
- 2015北京网络赛 Couple Trees 倍增算法
2015北京网络赛 Couple Trees 题意:两棵树,求不同树上两个节点的最近公共祖先 思路:比赛时看过的队伍不是很多,没有仔细想.今天补题才发现有个 倍增算法,自己竟然不知道. 解法来自 q ...
- 2015北京网络赛 J Clarke and puzzle 求五维偏序 分块+bitset
Clarke and puzzle Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://hihocoder.com/contest/acmicpc20 ...
- 2015北京网络赛B题 Mission Impossible 6
借用大牛的一张图片:模拟 #include<cstdio> #include<cmath> #include<cstring> #include<algori ...
- 2015北京网络赛A题The Cats' Feeding Spots
题意:给你一百个点,找个以这些点为中心的最小的圆,使得这个圆恰好包含了n个点,而且这个圆的边界上并没有点 解题思路:暴力枚举每个点,求出每个点到其他点的距离,取第n大的点,判断一下. #include ...
- 2015北京网络赛 F Couple Trees 暴力倍增
Couple Trees Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://hihocoder.com/problemset/problem/123 ...
- 2015北京网络赛 G题 Boxes bfs
Boxes Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://hihocoder.com/contest/acmicpc2015beijingonl ...
随机推荐
- mysql数据库封装
<?php /** * name: sql操作封装,可扩展 . * User: 张云山 * Date: 2016/9/4 * Time: 22:02 */ //php文件编码设置header(' ...
- thinkphp1
命名空间 含义:从广义上来说,命名空间是一种封装事物的方法. 用途:用来解决命名冲突 namespace xxx\xxx; 使用: use xxx\xx\yy; new\xx\xx\yy; // 单一 ...
- iOS开发之CocoaLumberjack
Cocoa LumberJack是一个功能强大的NSlog,是通用的Cocoa日志框架之一.它可以提供更高级的log功能,比如记录log至文件或网络,并可根据log的级别(info.debug.war ...
- PSI and index do not match: PSI and index do not match
解决来自:http://blog.csdn.net/huberjobs/article/details/50829603
- Mysql 数据库之常用命令[更新中...]
连接命令:mysql -h[主机地址] -u[用户名] -p[用户密码] 创建数据库:create database [库名] 例如:create database jtest; 显示所有数据库: s ...
- Mybatis缓存处理机制
一.MyBatis缓存介绍 正如大多数持久层框架一样,MyBatis 同样提供了一级缓存和二级缓存的支持 一级缓存: 基于PerpetualCache 的 HashMap本地缓存,其存储作用域为 Se ...
- Codeforces554B:Ohana Cleans Up
B. Ohana Cleans Up Time Limit: 2000ms Memory Limit: 262144KB 64-bit integer IO format: %I64d Ja ...
- python学习道路(day3note)(元组,字典 ,集合,字符编码,文件操作)
1.元组()元组跟列表一样,但是不能增删改,能查.元组又叫只读列表2个方法 一个 count 一个 index2.字典{}字典是通过key来寻找value因为这里功能比较多,所以写入了一个Code里面 ...
- .NET对象与Windows句柄(一):句柄的基本概念
在.NET编程中,得益于有效的内存管理机制,对象的创建和使用比较方便,大多数情况下我们无须关心对象创建和分配内存的细节,也可以放心的把对象的清理交给自动垃圾回收来完成.由于.NET类库对系统底层对象进 ...
- TweenMax学习一
TweenMaxjs是一个性能很高的js动画框架,它与css3动画具有时间轴的概念.你可以很方便的把动画添加到一个时间轴队列里面去按照你需要的顺序去执行. 官网地址: http://greensock ...