BZOJ 2083: [Poi2010]Intelligence test
Description
问一个序列是不是起始序列的子序列.
Sol
二分.
直接维护每个数出现的位置,二分一个最小的就行.
Code
/**************************************************************
Problem: 2083
User: BeiYu
Language: C++
Result: Accepted
Time:7024 ms
Memory:34132 kb
****************************************************************/ #include <bits/stdc++.h>
using namespace std; #define debug(a) cout<<#a<<"="<<a<<" "
const int N = 1e6+50; int n;
vector< int > a[N]; inline int in(int x=0,char ch=getchar()) { while(ch>'9' || ch<'0') ch=getchar();
while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();return x; }
int main() {
n=in();
for(int i=1,x;i<=n;i++) x=in(),a[x].push_back(i);
for(int i=1;i<N;i++) a[i].push_back(n+1);
for(int T=in();T--;) {
int m=in(),pos=0,f=0;vector< int > :: iterator it;
for(int i=1,x;i<=m;i++) {
x=in();
if(f) continue;
it=upper_bound(a[x].begin(),a[x].end(),pos);
if(*it!=n+1) pos=*it;
else f=1;
// debug(pos),debug(f)<<endl;
}
if(f) puts("NIE");
else puts("TAK");
}
return 0;
}
BZOJ 2083: [Poi2010]Intelligence test的更多相关文章
- 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——思路+vector/链表
		题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2083 给每个值开一个vector.每个询问挂在其第一个值上:然后枚举给定序列,遇到一个值就访 ... 
- bzoj 2083: [Poi2010]Intelligence test——vecto+二分
		Description 霸中智力测试机构的一项工作就是按照一定的规则删除一个序列的数字,得到一个确定的数列.Lyx很渴望成为霸中智力测试机构的主管,但是他在这个工作上做的并不好,俗话说熟能生巧,他打算 ... 
- BZOJ2083: [Poi2010]Intelligence test
		2083: [Poi2010]Intelligence test Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 241 Solved: 96[Sub ... 
- BZOJ 2083 vector的巧用+二分
		2083: [Poi2010]Intelligence test Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 469 Solved: 227[Su ... 
- 【BZOJ2083】[Poi2010]Intelligence test 二分
		[BZOJ2083][Poi2010]Intelligence test Description 霸中智力测试机构的一项工作就是按照一定的规则删除一个序列的数字,得到一个确定的数列.Lyx很渴望成为霸 ... 
- bzoj 2083 Intelligence test —— 思路+vector
		题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2083 先把所有子序列都存下来,总长度应该有限制,所以用 vector 存: 要做到 O(n) ... 
- BZOJ 2083 Intelligence test
		用vector,二分. #include<iostream> #include<cstdio> #include<cstring> #include<algo ... 
- [BZOJ 2083] [POI 2010] Intelligence test
		Description 霸中智力测试机构的一项工作就是按照一定的规则删除一个序列的数字,得到一个确定的数列.Lyx很渴望成为霸中智力测试机构的主管,但是他在这个工作上做的并不好,俗话说熟能生巧,他打算 ... 
随机推荐
- [LeetCode] Repeated Substring Pattern 重复子字符串模式
			Given a non-empty string check if it can be constructed by taking a substring of it and appending mu ... 
- 2016第三届C++大会参会感悟(上)
			继05年第一届C++大会,09年第二届,2016年10月28日-29日,在上海举行第三届C++大会.讲师主要有C++之父 / Bjarne Stroustrup,前Facebook研究科学家 / An ... 
- mysqld初探
			一.简介 deamon是守护神的意思,表示守护进程.mysqld就是mysql的服务器端,就是基于socket的一个服务器端程序,它始终监听3306端口(默认端口).mysql是客户端程序. 安装my ... 
- 【笔记】jstree插件的基本使用
			官网地址:https://www.jstree.com/ json返回参数格式:推荐第二种方式 不需要在重新拼接返回格式 不刷新页面重新初始化 jstree时使用:$.jstree.destroy() ... 
- cocos初认识
			一直知道cocos是做游戏的,想学习一下,结果去官网一看就懵逼了.Cocos Creator,Cocos2d-x,cocos studio,Cocos2d-js,Cocos2d-x-lua,那一种才是 ... 
- javascript判断数字是integer还是float
			function isFloat(n) { return n === +n && n !== (n|0); } function isInteger(n) { // 仅能检查32位的数 ... 
- Ubuntu安装RobotFramework
			安装Python Ubuntu默认已安装 安装pip wget https://bootstrap.pypa.io/get-pip.py python get-pip.py 安装RobotFramew ... 
- C#基础练习
			1.冒泡排序 namespace _0 { class Program { public static int[] BubbleSort(int[] arr) { ; i < arr.Lengt ... 
- Dell R730 配置完RAID后装系统找不到硬盘。
			1. 各硬盘只是灯都正常.硬件无故障. 2. 8个600G硬盘做的RAID0和RAID5后都在装系统选盘处找不到硬盘.(注意: 第一次做raid 时,没有进行初始化init.后补做也无效,一直复现这个 ... 
- bootstrapvalidator+bootstrap-select     select无法校验问题解决方法
			$("#form_user_input") .bootstrapValidator( { message : 'This value is not valid', excluded ... 
