用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的更多相关文章

  1. bzoj 2083 Intelligence test —— 思路+vector

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2083 先把所有子序列都存下来,总长度应该有限制,所以用 vector 存: 要做到 O(n) ...

  2. BZOJ 2083: [Poi2010]Intelligence test [vector+二分]

    2083: [Poi2010]Intelligence test Time Limit: 10 Sec  Memory Limit: 259 MBSubmit: 469  Solved: 227[Su ...

  3. BZOJ 2083: [Poi2010]Intelligence test

    Description 问一个序列是不是起始序列的子序列. Sol 二分. 直接维护每个数出现的位置,二分一个最小的就行. Code /******************************** ...

  4. bzoj 2083 [Poi2010]Intelligence test——思路+vector/链表

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2083 给每个值开一个vector.每个询问挂在其第一个值上:然后枚举给定序列,遇到一个值就访 ...

  5. [BZOJ 2083] [POI 2010] Intelligence test

    Description 霸中智力测试机构的一项工作就是按照一定的规则删除一个序列的数字,得到一个确定的数列.Lyx很渴望成为霸中智力测试机构的主管,但是他在这个工作上做的并不好,俗话说熟能生巧,他打算 ...

  6. bzoj 2083: [Poi2010]Intelligence test——vecto+二分

    Description 霸中智力测试机构的一项工作就是按照一定的规则删除一个序列的数字,得到一个确定的数列.Lyx很渴望成为霸中智力测试机构的主管,但是他在这个工作上做的并不好,俗话说熟能生巧,他打算 ...

  7. BZOJ 2083 vector的巧用+二分

    2083: [Poi2010]Intelligence test Time Limit: 10 Sec  Memory Limit: 259 MBSubmit: 469  Solved: 227[Su ...

  8. [LOJ 2083][UOJ 219][BZOJ 4650][NOI 2016]优秀的拆分

    [LOJ 2083][UOJ 219][BZOJ 4650][NOI 2016]优秀的拆分 题意 给定一个字符串 \(S\), 求有多少种将 \(S\) 的子串拆分为形如 AABB 的拆分方案 \(| ...

  9. BZOJ2083: [Poi2010]Intelligence test

    2083: [Poi2010]Intelligence test Time Limit: 10 Sec  Memory Limit: 259 MBSubmit: 241  Solved: 96[Sub ...

随机推荐

  1. GitHub学习资料

    GitHub账户注册注册了有一年多了(Joined on 13 Apr 2015),一直以来都是本地命令行上传到内网的Git服务器Gitlab.最近正好在学习新的编程语言,所以当初荒废的GitHub想 ...

  2. 在excel单元格中提取信息

    平时在excel中处理数据的时候,肯定会遇到在单元格提取信息的情况,比如在地址中提取省.市.地区等,如果数据源内容规整的话,可以直接使用left().right().mid()等函数直接提取,但是大多 ...

  3. Python3学习笔记(urllib模块的使用)转http://www.cnblogs.com/Lands-ljk/p/5447127.html

    Python3学习笔记(urllib模块的使用)   1.基本方法 urllib.request.urlopen(url, data=None, [timeout, ]*, cafile=None,  ...

  4. Simplify Path [LeetCode]

    Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", ...

  5. Redis(7)Creating and Using Cluster Mode

    1. DocumentsCluster will not support SELECT, it only contains database 0.All the nodes use TCP bus a ...

  6. ios基础篇(六)——UITextView的常用方法及技巧

    上篇说到了UITextField,我们先来说说UITextView和UITextField的不同: UITextView支持多行输入; UITextFiled只支持单行; UITextView没有pl ...

  7. MySql查找几个字段的值一样的记录

    ),name,class,charge_start,charge_end ) ; 注意:having在这里起到很大的作用,只有在having中,才可以对类似sum(),count()等等复合函数的结果 ...

  8. Asp.Net 导出Excel数据文件

    表格例子如下: <table id="tableExcel" width="100%" border="1" cellspacing= ...

  9. BZOJ1937 [Shoi2004]Mst 最小生成树

    首先由贪心的想法知道,树边只减不加,非树边只加不减,令$w_i$表示i号边原来的边权,$d_i$表示i号边的改变量 对于一条非树边$j$连接着两个点$x$.$y$,则对于$xy$这条路径上的所有树边$ ...

  10. Linux 远程桌面控制

    我现在知道有两种方式: 1.直接使用Gnome桌面的远程控制功能.在服务器端登录到gnome桌面,然后在系统菜单中打开远程桌面配置,勾选允许远程即可.这种方式客户端和服务器的两种操作将保持同步,也就是 ...