bzoj 2083: [Poi2010]Intelligence test——vecto+二分
Description
霸中智力测试机构的一项工作就是按照一定的规则删除一个序列的数字,得到一个确定的数列。Lyx很渴望成为霸中智力测试机构的主管,但是他在这个工作上做的并不好,俗话说熟能生巧,他打算做很多练习,所以他希望你写一个程序来快速判断他的答案是否正确。
Input
第一行为一个整数m(1<=m<=1000000)第二行包括m个用空格分开的整数ai(1<=ai<=1000000),组成了最初的序列,第三行为一个整数n(1<=n<=1000000),表示n个Lyx经过一系列删除得到的序列,每个序列两行,第一行给出长度L(1<=L<=m),然后下一行为L个由空格分开的整数bi(1<=bi<=1000000)。
Output
共n行,如果Lyx的序列确实是由最初的序列删除一些数得到,就输出TAK,否则输出NIE。
Sample Input
1 5 4 5 7 8 6
4
5
1 5 5 8 6
3
2 2 2
3
5 7 8
4
1 5 7 4
Sample Output
NIE
TAK
NIE
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using std::lower_bound;
std::vector<int>::iterator ly;
const int M=2e6+;
int read(){
int ans=,f=,c=getchar();
while(c<''||c>''){if(c=='-') f=-; c=getchar();}
while(c>=''&&c<=''){ans=ans*+(c-''); c=getchar();}
return ans*f;
}
std::vector<int>q[M];
int n,m,k,p;
int main(){
n=read();
for(int i=;i<=n;i++) k=read(),q[k].push_back(i);
m=read();
for(int i=;i<=m;i++){
int now=;
bool flag=true;
k=read();
for(int j=;j<=k;j++){
p=read();
if(!flag) continue;
if(q[p].empty()){flag=false; continue;}
ly=upper_bound(q[p].begin(),q[p].end(),now);
if(ly==q[p].end()) flag=false;
else now=*ly;
}
if(flag) printf("TAK\n");
else printf("NIE\n");
}
return ;
}
bzoj 2083: [Poi2010]Intelligence test——vecto+二分的更多相关文章
- BZOJ 2083: [Poi2010]Intelligence test [vector+二分]
2083: [Poi2010]Intelligence test Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 469 Solved: 227[Su ...
- BZOJ 2083: [Poi2010]Intelligence test
Description 问一个序列是不是起始序列的子序列. Sol 二分. 直接维护每个数出现的位置,二分一个最小的就行. Code /******************************** ...
- bzoj 2083 [Poi2010]Intelligence test——思路+vector/链表
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2083 给每个值开一个vector.每个询问挂在其第一个值上:然后枚举给定序列,遇到一个值就访 ...
- BZOJ 2083 vector的巧用+二分
2083: [Poi2010]Intelligence test Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 469 Solved: 227[Su ...
- 【bzoj2083】[Poi2010]Intelligence test STL-vector+二分查找
题目描述 霸中智力测试机构的一项工作就是按照一定的规则删除一个序列的数字,得到一个确定的数列.Lyx很渴望成为霸中智力测试机构的主管,但是他在这个工作上做的并不好,俗话说熟能生巧,他打算做很多练习,所 ...
- bzoj2083: [Poi2010]Intelligence test(二分+vector)
只是记录一下vector的用法 v.push_back(x)加入x v.pop_back()弹出最后一个元素 v[x]=v.back(),v.pop_back()删除x,但是会打乱vector顺序 v ...
- BZOJ2083: [Poi2010]Intelligence test
2083: [Poi2010]Intelligence test Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 241 Solved: 96[Sub ...
- 【BZOJ2083】[Poi2010]Intelligence test 二分
[BZOJ2083][Poi2010]Intelligence test Description 霸中智力测试机构的一项工作就是按照一定的规则删除一个序列的数字,得到一个确定的数列.Lyx很渴望成为霸 ...
- BZOJ 3343: 教主的魔法(分块+二分查找)
BZOJ 3343: 教主的魔法(分块+二分查找) 3343: 教主的魔法 Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 1172 Solved: ...
随机推荐
- Android开发随笔5
昨天: 对界面的进一步设计补充 可以在界面之间的跳转 研究了对图标等的操作 今天: 实现对库的相关操作 学习视视频内容‘ 复习java的一些知识.
- lintcode-15-全排列
全排列 给定一个数字列表,返回其所有可能的排列. 注意事项 你可以假设没有重复数字. 样例 给出一个列表[1,2,3],其全排列为: [ [1,2,3], [1,3,2], [2,1,3], [2,3 ...
- erlang+thrift配合开发
I think, thrift is a tcp/ip based Client-Server architecture multi-languages supported RPC framewo ...
- C#通过SC命令和静态公共类来操作Windows服务
调用的Windows服务应用程序网址:http://www.cnblogs.com/pingming/p/5115304.html 一.引用 二.公共静态类:可以单独放到类库里 using Syste ...
- Spring MVC架构浅析
阅读目录 Spring MVC概述 Spring MVC框架的特点 Spring MVC工作原理 Spring MVC概述 Spring的web框架围绕DispatcherServlet设计,Disp ...
- veeValidate
网站 http://vee-validate.logaretm.com/index.html#about 自定义为空时候的提示 Field-specific Custom Messages You m ...
- 使用oledb读取excel表
string path = "C:\\Users\\aaa\\Desktop\\aa.xls"; string conn = "Provider = Microsoft. ...
- Lucene笔记一
Lucene就是一个全文检索的工具,建立索引用的,类似于新华字典的目录 这里使用的是lucene-4.4.0版本,入门代码所需jar包如下图所示(解压lucene-4.4.0后的目录): 入门代码: ...
- 只有父类的init方法才有创建servletConfig与servletContext的能力
如果重写了父类的init方法 但又没有显示调用父类的init方法 那么子类无法使用servletContext 因为 子类方法没有创建出 servletConfig
- 同步锁(synchronized)使用三要素
1.代码被多个线程访问 2.代码中有共享的数据 3.共享数据被多个语句操作