ACM-ICPC国际大学生程序设计竞赛北京赛区(2015)网络赛 Scores
#1236 : Scores
描述
Kyle is a student of Programming Monkey Elementary School. Just as others, he is deeply concerned with his grades.
Last month, the school held an examination including five subjects, without any doubt, Kyle got a perfect score in every single subject.
There are n students took part in this examination(not including Kyle), and everyone got an integer between 1 to m as the score of one subject.
Now, looking at the grade table of these n students, Kyle wants to know how many students still did no better than him even if his scores are something else – Here, “no better” means there is no subject in which the student got strictly greater score than Kyle.
输入
There are multiple test cases.
The first line of the input contains an integer T (T <= 3) which means the number of test cases.
The first line of each test case contains two integers, n, m(n, m≤ 50,000), which are the number of students and the perfect score of each subject.
In the next n lines, each line consists of five integers, indicating a student’s scores.
Then one line follows. This line contains an integer q(q≤ 50,000) indicating the number of queries.
In the next q lines, each line contains five integers as well, representing a query. Each query indicates a set of scores, and for each query, you should figure out that if Kyle's grade is this set of scores, how many students still did no better than him. But for the sake of security, only the first query is in its original form, and other queries are encrypted. To decrypt a query, you must let each integer in the query do xor operation with the answer of last query. It's guaranteed that all the decrypted queries contain integers between 1 and 50000.
输出
For each test case, you should output q lines as the answer for all queries.
提示
In case 1, there are two students with different scores and the scores of the first student (1, 1, 1, 1, 1) are not larger than the first query (1 1 1 1 1) in every subject, so the answer for this query is 1.
After having xor operation with the last answer 1, the second query (3,3,3,3,3) will be decrypted into (2, 2, 2, 2, 2). Because both students’ scores are no better than (2, 2, 2, 2, 2), so the answer for query 2 is 2.
- 样例输入
-
2
2 3
1 1 1 1 1
2 2 2 2 2
2
1 1 1 1 1
3 3 3 3 3
3 5
1 1 1 1 1
1 1 1 1 1
1 2 3 4 5
2
1 1 1 1 1
1 1 1 1 1 - 样例输出
-
1
2
2
2
分析:在线求五维偏序点对数;
考虑bitset存编号,预处理前缀bitset并且分块;
对于每次询问,每一维可以直接二分得到位置,把当前bitset和剩下的或起来就是当前这一维的;
最后把五维或起来求count即可;
代码:#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <cassert>
#include <ctime>
#define rep(i,m,n) for(i=m;i<=(int)n;i++)
#define inf 0x3f3f3f3f
#define mod 998244353
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
#define ls (rt<<1)
#define rs (rt<<1|1)
#define all(x) x.begin(),x.end()
const int maxn=5e4+;
const int N=4e5+;
using namespace std;
ll gcd(ll p,ll q){return q==?p:gcd(q,p%q);}
ll qmul(ll p,ll q,ll mo){ll f=;while(q){if(q&)f=(f+p)%mo;p=(p+p)%mo;q>>=;}return f;}
ll qpow(ll p,ll q){ll f=;while(q){if(q&)f=f*p%mod;p=p*p%mod;q>>=;}return f;}
int n,m,k,t,bl[maxn];
struct node
{
int id,v;
bool operator<(const node&p)const
{
return v<p.v;
}
}a[][maxn];
bitset<maxn>dp[][],ans[];
int main(){
int i,j;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
rep(i,,)rep(j,,)dp[i][j].reset();
rep(i,,n)rep(j,,)
{
scanf("%d",&k);
a[j][i]=node{i,k};
}
rep(i,,)sort(a[i]+,a[i]+n+);
int sz=(int)round(sqrt(n));
rep(i,,n)bl[i]=(i-)/sz+;
rep(i,,)
{
int pos=,go=;
while(++go<=n)
{
pos++;
dp[i][pos]|=dp[i][pos-];
dp[i][pos][a[i][go].id]=;
while(go+<=n&&bl[go+]==bl[go])
{
dp[i][pos][a[i][++go].id]=;
}
}
}
int q,lst=;
scanf("%d",&q);
while(q--)
{
int qu[];
rep(i,,)
{
ans[i].reset();
scanf("%d",&qu[i]);
qu[i]^=lst;
int l=,r=n,ret=;
while(l<=r)
{
int mid=l+r>>;
if(qu[i]>=a[i][mid].v)ret=mid,l=mid+;
else r=mid-;
}
if(!ret)continue;
else
{
ans[i]|=dp[i][bl[ret]-];
for(j=(bl[ret]-)*sz+;j<=ret;j++)ans[i][a[i][j].id]=;
}
}
lst=(ans[]&ans[]&ans[]&ans[]&ans[]).count();
printf("%d\n",lst);
}
}
return ;
}
ACM-ICPC国际大学生程序设计竞赛北京赛区(2015)网络赛 Scores的更多相关文章
- ACM-ICPC国际大学生程序设计竞赛北京赛区(2015)网络赛 B Mission Impossible 6
#1228 : Mission Impossible 6 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 You must have seen the very famou ...
- ACM-ICPC国际大学生程序设计竞赛北京赛区(2015)网络赛
#1235 : New Teaching Buildings 时间限制:2000ms 单点时限:2000ms 内存限制:256MB 描述 Thanks to the generous finance ...
- hihoCoder 1578 Visiting Peking University 【贪心】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛)
#1578 : Visiting Peking University 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 Ming is going to travel for ...
- ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛 A Simple Job
描述 Institute of Computational Linguistics (ICL), Peking University is an interdisciplinary institute ...
- ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛 The Book List
描述 The history of Peking University Library is as long as the history of Peking University. It was b ...
- hihoCoder 1389 Sewage Treatment 【二分+网络流+优化】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛)
#1389 : Sewage Treatment 时间限制:2000ms 单点时限:2000ms 内存限制:256MB 描述 After years of suffering, people coul ...
- hihoCoder 1391 Countries 【预处理+排序+堆】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛)
#1391 : Countries 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 There are two antagonistic countries, countr ...
- hihoCoder 1392 War Chess 【模拟】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛)
#1392 : War Chess 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 Rainbow loves to play kinds of War Chess gam ...
- ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛 题目9 : Minimum
时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 You are given a list of integers a0, a1, …, a2^k-1. You need t ...
随机推荐
- 【Learning】多项式的一些东西
FFT 坑 NTT 将\(FFT\)中的单位复数根改成原根即可. 卡常版NTT模版 struct Mul { int Len; int wn[N], Lim; int rev[N]; inline v ...
- bzoj 1623: [Usaco2008 Open]Cow Cars 奶牛飞车【排序+贪心】
从小到大排个序,然后能选就选 #include<iostream> #include<cstdio> #include<algorithm> using names ...
- Akka源码分析-Cluster-Metrics
一个应用软件维护的后期一定是要做监控,akka也不例外,它提供了集群模式下的度量扩展插件. 其实如果读者读过前面的系列文章的话,应该是能够自己写一个这样的监控工具的.简单来说就是创建一个actor,它 ...
- Rabbitmq笔记一
几个基本概念 Producer 生产者,发送消息的一方,图中左侧的client. Consumer 消费者,接收消息的一方,图中后侧的client. Broker 消息中间件的服务节点,一般一个Rab ...
- StackOverflow 创始人关于如何高效编程的清单
这是 StackOverflow 联合创始人 Jeff Atwood 注释的十戒.程序员普遍有很强的自尊心,都应该看看本文,打印下来时刻提醒自己. “无我编程”发生在开发阶段,表现为技术团队经常通过同 ...
- [W3School]JavaScript教程学习
JavaScript 简介 JavaScript 是世界上最流行的编程语言.这门语言可用于 HTML 和 web,更可广泛用于服务器.PC.笔记本电脑.平板电脑和智能手机等设备. JavaScript ...
- [Qt Creator 快速入门] 第9章 国际化、帮助系统和Qt插件
一.国际化 国际化的英文表述为Internationalization,通常简写为I18N(首尾字母加中间的字符数),一个应用程序的国际化就是使该应用程序可以让其他国家的用户使用的过程. Qt支持现在 ...
- POJ 2187 凸包+旋转卡壳
思路: 求个凸包 旋转卡壳一下 就求出来最远点对了 注意共线情况 也就是说 凸包如果有一堆点共线保留端点即可 //By SiriusRen #include <cmath> #incl ...
- 初窥Android Studio
Android Studio 是一个Android集成开发工具,基于IntelliJ IDEA. 类似 Eclipse ADT,Android Studio 提供了集成的 Android 开发工具用于 ...
- 6.12---bug