bzoj2083: [Poi2010]Intelligence test(二分+vector)
只是记录一下vector的用法
v.push_back(x)加入x
v.pop_back()弹出最后一个元素
v[x]=v.back(),v.pop_back()删除x,但是会打乱vector顺序
vector的第i个元素可以直接用v[i]
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
const int maxn=,inf=1e9;
int n,m,L;
int a[maxn],b[maxn];
vector<int>v[maxn];
inline void read(int &k)
{
int f=;k=;char c=getchar();
while(c<''||c>'')c=='-'&&(f=-),c=getchar();
while(c<=''&&c>='')k=k*+c-'',c=getchar();
k*=f;
}
int main()
{
read(n);
for(int i=;i<=n;i++)read(a[i]),v[a[i]].push_back(i);
read(m);
for(int i=;i<=m;i++)
{
read(L);
for(int j=;j<=L;j++)read(b[j]);
int now=,flag=;
for(int j=;j<=L;j++)
{
int l=,r=v[b[j]].size()-;
if(r<){puts("NIE");flag=;break;}
while(l<r)
{
int mid=(l+r)>>;
if(v[b[j]][mid]>now)r=mid;
else l=mid+;
}
if(v[b[j]][l]>now)now=v[b[j]][l];
else {puts("NIE");flag=;break;}
}
if(!flag)puts("TAK");
}
}
bzoj2083: [Poi2010]Intelligence test(二分+vector)的更多相关文章
- 【BZOJ2083】[Poi2010]Intelligence test 二分
[BZOJ2083][Poi2010]Intelligence test Description 霸中智力测试机构的一项工作就是按照一定的规则删除一个序列的数字,得到一个确定的数列.Lyx很渴望成为霸 ...
- BZOJ2083: [Poi2010]Intelligence test
2083: [Poi2010]Intelligence test Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 241 Solved: 96[Sub ...
- 【二分】bzoj2083 [Poi2010]Intelligence test
v[x]记录了x值的出现位置序列. 对每个b中的元素,每次在v[b[i]]中二分. 因此要记录上一次二分到了a数组的哪个位置. #include<cstdio> #include<v ...
- bzoj 2083 [Poi2010]Intelligence test——思路+vector/链表
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2083 给每个值开一个vector.每个询问挂在其第一个值上:然后枚举给定序列,遇到一个值就访 ...
- BZOJ 2083: [Poi2010]Intelligence test [vector+二分]
2083: [Poi2010]Intelligence test Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 469 Solved: 227[Su ...
- 【bzoj2083】[Poi2010]Intelligence test STL-vector+二分查找
题目描述 霸中智力测试机构的一项工作就是按照一定的规则删除一个序列的数字,得到一个确定的数列.Lyx很渴望成为霸中智力测试机构的主管,但是他在这个工作上做的并不好,俗话说熟能生巧,他打算做很多练习,所 ...
- bzoj 2083: [Poi2010]Intelligence test——vecto+二分
Description 霸中智力测试机构的一项工作就是按照一定的规则删除一个序列的数字,得到一个确定的数列.Lyx很渴望成为霸中智力测试机构的主管,但是他在这个工作上做的并不好,俗话说熟能生巧,他打算 ...
- BZOJ2095 POI2010 Bridges 【二分+混合图欧拉回路】
BZOJ2095 POI2010 Bridges Description YYD为了减肥,他来到了瘦海,这是一个巨大的海,海中有n个小岛,小岛之间有m座桥连接,两个小岛之间不会有两座桥,并且从一个小岛 ...
- [POI2010] Intelligence test
yyl说是用链表O(n)做 但是并脑补不出来. 发现可以用个vector记录一下每个数出现的位置,然后对于每个新序列就二分一下,找下一个数出现的离当前位置最近的位置,更新一下当前位置即可. 时间复杂度 ...
随机推荐
- Java: Replace a string from multiple replaced strings to multiple substitutes
Provide helper methods to replace a string from multiple replaced strings to multiple substitutes im ...
- 180615-精度计算BigDecimal
文章链接:https://liuyueyi.github.io/hexblog/2018/06/15/180615-精度计算BigDecimal/ 180615-精度计算BigDecimal 目前接触 ...
- JDBC中使用Properties类及配置文件的操作
同时发布于:https://blog.csdn.net/Activity_Time/article/details/81149710 一.properties配置文件 开发中获得连接的4个参数(驱动. ...
- 实现Bidirectional LSTM Classifier----深度学习RNN
双向循环神经网络(Bidirectional Recurrent Neural Networks,Bi-RNN),Schuster.Paliwal,1997年首次提出,和LSTM同年.Bi-RNN,增 ...
- SpringBoot日志配置(详解) 涉及控制台输出日志、生成日志文件、日志级别修改、hibernate日志不输出
写在前面 本篇主要讲述日志配置,看完本篇可以解决下述问题, 控制台输出日志.生成日志文件.日志级别修改.hibernate日志不输出 Git Demo Path:https://github.com/ ...
- JAVA集合类(大公司面试喜欢问的)
分类: 核心JAVA(11) 版权声明:本文为博主原创文章,未经博主允许不得转载. 看了一些所谓大公司的Java面试问题,发现对于JAVA集合类的使用都比较看重似的,而自己在这方面还真的是所真甚少 ...
- 重装win10后ubuntu引导项修复
问题描述:原来是在win7下装了ubuntu14的双系统,后台win7换win10,然后使用EasyBCD进行引导项修复时,不好使,报 error file: /boot/grub/i386-pc/n ...
- nodejs在linux环境下安装更新方式
#检查是否已经安装 rpm -qa | grep python #查版本 python #最好是重新安装 Python推荐版本( >= v2.5.0 & < 3.0.0 ),否则影 ...
- default & delete
一.使用“=default” 1. 显式生成拷贝控制成员的合成版本 class A { public: A() = default; A(const A &) = default; A& ...
- StrBlobPtr类——weak_ptr访问vector元素
#include <iostream> #include <memory> #include <string> #include <initializer_l ...