BZOJ 2083: [Poi2010]Intelligence test [vector+二分]
2083: [Poi2010]Intelligence test
Time Limit: 10 Sec Memory Limit: 259 MB
Submit: 469 Solved: 227
[Submit][Status][Discuss]
Description
Input
Output
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
//
// main.cpp
// bzoj29083
//
// Created by Candy on 2017/1/13.
// Copyright © 2017年 Candy. All rights reserved.
// #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N=2e6+,S=1e5+;
typedef long long ll;
inline int read(){
char c=getchar();int x=,f=;
while(c<''||c>''){if(c=='-')f=-;c=getchar();}
while(c>=''&&c<=''){x=x*+c-'';c=getchar();}
return x*f;
}
int m,a[N],n,l[N],b;
struct edge{
int v,pos,ne;
}e[N];
int cnt,h[N];
inline void ins(int u,int v,int pos){
cnt++;
e[cnt].v=v;e[cnt].pos=pos;e[cnt].ne=h[u];h[u]=cnt;
}
int now[N];
void solve(){
for(int j=;j<=m;j++)
for(int i=h[S+a[j]];i;i=e[i].ne)
if(now[e[i].v]==e[i].pos-) now[e[i].v]=e[i].pos;
for(int i=;i<=n;i++){
if(now[i]==l[i]) puts("TAK");
else puts("NIE");
}
}
int main(int argc, const char * argv[]) {
m=read();
for(int i=;i<=m;i++) a[i]=read();
n=read();
for(int i=;i<=n;i++){
l[i]=read();
for(int j=;j<=l[i];j++) b=read(),ins(S+b,i,j);
}
solve();
return ;
}
链表TLE
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int N=1e6+;
typedef long long ll;
inline int read(){
char c=getchar();int x=,f=;
while(c<''||c>''){if(c=='-')f=-;c=getchar();}
while(c>=''&&c<=''){x=x*+c-'';c=getchar();}
return x*f;
}
int m,a[N],n,l,b;
vector<int> h[N];
vector<int>::iterator it;
int main(int argc, const char * argv[]) {
m=read();
for(int i=;i<=m;i++) a[i]=read(),h[a[i]].push_back(i);
n=read();
for(int i=;i<=n;i++){
l=read();
int now=,flag=;
for(int j=;j<=l;j++){
b=read();
if(!flag) continue;
it=upper_bound(h[b].begin(),h[b].end(),now);
if(it==h[b].end()) flag=;
else now=*it;
}
if(!flag) puts("NIE");
else puts("TAK");
}
return ;
}
BZOJ 2083: [Poi2010]Intelligence test [vector+二分]的更多相关文章
- bzoj 2083: [Poi2010]Intelligence test——vecto+二分
Description 霸中智力测试机构的一项工作就是按照一定的规则删除一个序列的数字,得到一个确定的数列.Lyx很渴望成为霸中智力测试机构的主管,但是他在这个工作上做的并不好,俗话说熟能生巧,他打算 ...
- bzoj 2083 [Poi2010]Intelligence test——思路+vector/链表
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2083 给每个值开一个vector.每个询问挂在其第一个值上:然后枚举给定序列,遇到一个值就访 ...
- BZOJ 2083: [Poi2010]Intelligence test
Description 问一个序列是不是起始序列的子序列. Sol 二分. 直接维护每个数出现的位置,二分一个最小的就行. Code /******************************** ...
- 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 STL-vector+二分查找
题目描述 霸中智力测试机构的一项工作就是按照一定的规则删除一个序列的数字,得到一个确定的数列.Lyx很渴望成为霸中智力测试机构的主管,但是他在这个工作上做的并不好,俗话说熟能生巧,他打算做很多练习,所 ...
- BZOJ 2083 vector的巧用+二分
2083: [Poi2010]Intelligence test Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 469 Solved: 227[Su ...
- 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: ...
随机推荐
- Spring框架学习笔记(8)——AspectJ实现AOP
使用代理对象实现AOP虽然可以满足需求,但是较为复杂,而Spring提供一种简单的实现AOP的方法AspectJ 同样的计算器的DEMO 首先配置applicationContext.xml < ...
- 前端通信:SSE设计方案(二)--- 服务器推送技术的实践以及一些应用场景的demo(包括在线及时聊天系统以及线上缓存更新,代码热修复案例)
距离上一篇博客,这篇文章的发布大概过了整整三个月.我也从饿了么度过了试用期,成为了正式员工.刚进来恰好遇到项目底层改造和迁移,将项目从angular全部迁移到vue上,所以适应这边的节奏和业务的开发任 ...
- IntelliJ IDEA 2017.3下载与安装
大约在2017年暑假的时候知道了IntelliJ IDEA,但是那个时候一心认为有Eclipse就足够用了,然而今天在网上冲浪的时候发现,IntelliJ IDEA是java语言开发的集成环境,这款开 ...
- error: Failed dependencies:解决
error: Failed dependencies:解决 使用rpma安装安装包时,会出现 error: Failed dependencies: 意思是 失败的依赖 解决方法: 在安装包后面加两个 ...
- Spark算子--map和flatMap
map和flatMap--Transformation类算子 代码示例 result
- 修改nopCommerce中的实体
对已有实体增加一个属性(对Category增加一个SomeNewProperty) 最近在研究nopcommerce,这里是对官网上文档的学习 ...
- mysql之repair table 修复表札记
REPAIR [LOCAL | NO_WRITE_TO_BINLOG] TABLE tbl_name[,tbl_name] ... [QUICK] [EXTENDED] [USE_FRM] REP ...
- 怎么使用linux命令重启服务器
一下的命令都可以重启Linux服务器: 1.shutdown -r now 2.reboot 3.startx
- 【开发技术】web.xml vs struts.xml
web.xml用来配置servlet,监听器(Listener),过滤器(filter),还有404错误跳转页面,500,等还配置欢迎页面等,总之一句话,就是系统总配置方案写在web.xml中 str ...
- CCF系列之有趣的数(201312-4)
题目链接: http://115.28.138.223:81/view.page?opid=4 试题名称: 有趣的数 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 我们把一个 ...