五维偏序。。一开始被吓到了,后来知道了一种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. Unity -- EventSystem完全掌握

    Event System 组成 系统生成的Event System里面主要有两个Components,分别是Event System和Standalone Input Module. 其中Standa ...

  2. C语言中static的作用

    (1)在函数体内,局部的static变量.生存周期为程序的整个生命周期:作用域却在定义了的函数体内.一个被声明为静态的变量在这个函数被调用过程中维持其值不变.因为它分配在静态存储区域,函数调用结束以后 ...

  3. SQL SERVER 查询表或字段在哪里使用过

    select b.name from dbo.syscomments a, dbo.sysobjects b where a.id=b.id and b.xtype='p' and a.text li ...

  4. 响应式Web设计 - 布局

    可扩展的布局 有一种流体布局的概念在早起web兴起的时,就开始盛行了.它的概念是说页面会根据浏览器窗口的变化进行更改,网站可以通过维护一套代码,保质一致性的设计.我这里强调的可扩展的布局也是基于这个概 ...

  5. mysql performance_schema 和information_schema.tables了解

    这个是关于mysql的系统表,性能表,核心表操作的一些介绍,深入算不上 我们一般很少去动 mysql  information_schema 信息相关  performance_schema 性能相关 ...

  6. C指针-数组和指针的归一

    int bArr[] = {1,2,3}; int *iarr = bArr; *iarr = 6; printf("%d\n",*iarr); printf("%d\n ...

  7. jackson-mapper使用工具类

    import com.google.common.collect.Lists;import org.codehaus.jackson.annotate.JsonMethod;import org.co ...

  8. 奥迪--A3

    -型号:A3 -价格:18-28W -动力:1.4T/1.8T -变速箱:7挡双离合 -长宽高:4.32,1.79,1.43(Limousine:4.46,1.80,1.42) -油箱:50L -发动 ...

  9. c# TimeSpan

    转自:http://blog.163.com/y_p_xu/blog/static/17085710220116472030543/ /// <summary>        /// 将时 ...

  10. poj1753

    #include <stdio.h> char s[100][100]; int s1[100][100]; int ax[5]={0,-1,0,1,0}; int ay[5]={0,0, ...