BZOJ 2083 Intelligence test
用vector,二分。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define maxn 1005000
using namespace std;
int n,a[maxn],t,m,b[maxn];
vector <int> v[maxn];
int read()
{
char ch;int data=;
while (ch<'' || ch>'') ch=getchar();
while (ch>='' && ch<='')
{
data=data*+ch-'';
ch=getchar();
}
return data;
}
int find(int x,int y)
{
int l=,r=v[x].size()-,ans=-;
while (l<=r)
{
int mid=l+r>>;
if (v[x][mid]>y) {ans=v[x][mid];r=mid-;}
else l=mid+;
}
return ans;
}
void work()
{
m=read();int ret=;
for (int i=;i<=m;i++) b[i]=read();
for (int i=;i<=m;i++)
{
ret=find(b[i],ret);
if (ret==-) {printf("NIE\n");return;}
}
printf("TAK\n");
}
int main()
{
n=read();
for (int i=;i<=n;i++)
{
a[i]=read();
v[a[i]].push_back(i);
}
t=read();
for (int i=;i<=t;i++)
work();
return ;
}
BZOJ 2083 Intelligence test的更多相关文章
- bzoj 2083 Intelligence test —— 思路+vector
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2083 先把所有子序列都存下来,总长度应该有限制,所以用 vector 存: 要做到 O(n) ...
- 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] [POI 2010] Intelligence test
Description 霸中智力测试机构的一项工作就是按照一定的规则删除一个序列的数字,得到一个确定的数列.Lyx很渴望成为霸中智力测试机构的主管,但是他在这个工作上做的并不好,俗话说熟能生巧,他打算 ...
- bzoj 2083: [Poi2010]Intelligence test——vecto+二分
Description 霸中智力测试机构的一项工作就是按照一定的规则删除一个序列的数字,得到一个确定的数列.Lyx很渴望成为霸中智力测试机构的主管,但是他在这个工作上做的并不好,俗话说熟能生巧,他打算 ...
- BZOJ 2083 vector的巧用+二分
2083: [Poi2010]Intelligence test Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 469 Solved: 227[Su ...
- [LOJ 2083][UOJ 219][BZOJ 4650][NOI 2016]优秀的拆分
[LOJ 2083][UOJ 219][BZOJ 4650][NOI 2016]优秀的拆分 题意 给定一个字符串 \(S\), 求有多少种将 \(S\) 的子串拆分为形如 AABB 的拆分方案 \(| ...
- BZOJ2083: [Poi2010]Intelligence test
2083: [Poi2010]Intelligence test Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 241 Solved: 96[Sub ...
随机推荐
- [redis] Jedis 与 ShardedJedis 设计
Jedis设计 Jedis作为推荐的java语言redis客户端,其抽象封装为三部分: 对象池设计:Pool,JedisPool,GenericObjectPool,BasePoolableObjec ...
- Maven基础知识和环境搭建
基本概念和生命周期 Maven是现在流行的构建自动化工具,提供了软件构建过程中全生命周期的管理. 基础目录结构 基础目录结构如下: 根目录:存放pom.xml 和所有的子目录 ${basedir}/s ...
- Linux基础: 系统加载过程和运行级别含义
BIOS 有固化代码指向mbr,mbr指向grub(/boot/grub/下有很多引导配置信息),grub里可以配置多种linux内核vmlinux文件. 启动内核以后就开始加载各种驱动模块并进行系统 ...
- iOS 开发 – 均衡代码职责
前言 文章的标题有点绕口,不过想了半天,想不到更好的标题了.本文的诞生有一部分功劳要归于iOS应用现状分析,标题也是来源于原文中的"能把代码职责均衡的划分到不同的功能类里".如果你 ...
- ios基础篇(三)——UIButton的详细介绍
按钮UIButton是ios开发中最常见的控件之一,下面来介绍UIButton的详细内容: 一.UIButton的定义 UIButton *button=[[UIButton buttonWithTy ...
- routeProvider
In a previous post about testing I mentioned that route resolves can make authoring unit tests for a ...
- NodeJs编写小爬虫
一,爬虫及Robots协议 爬虫,是一种自动获取网页内容的程序.是搜索引擎的重要组成部分,因此搜索引擎优化很大程度上就是针对爬虫而做出的优化. robots.txt是一个文本文件,robots是一个协 ...
- C- printf的使用
ASC C之后引入的一个特性是,相邻的字符可以被自动连接 /* printf.cc * 2014/09/02 update */ #include <iostream> using nam ...
- iOS9/iOS8界面对比 XCode7
Xcde7 bate 无需开发这账号(99¥)可以调试程序 目前是测试版 iOS9/iOS8界面对比 (注:左边为iOS8界面,右边为iOS9界面.) 1.新字体 苹果在 iOS9 中使用旧金山字体取 ...
- CodeForces 546B-Soldier and Badges
题意: 给出一些数字,要求每个数字都不一样需要增加几 思路: 先排序,然后一个个增加,最后求总和差 代码如下: #include <iostream> #include <cstdi ...