BZOJ 2083 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
//看看会不会爆int!数组会不会少了一维!
//取物问题一定要小心先手胜利的条件
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker,"/STACK:102400000,102400000")
#define LL long long
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define haha printf("haha\n")
const int maxn = 2e6 + ;
int n, m;
vector<int> ve[maxn];
vector<int>::iterator it;
int main(){
scanf("%d", &m);
int a;
for (int i = ; i <= m; i++){
scanf("%d", &a);
ve[a].push_back(i);
}
scanf("%d", &n);
for (int i = ; i <= n; i++){
int k; scanf("%d", &k);
bool flag = true;
int pos = ;
for (int j = ; j <= k; j++){
int b; scanf("%d", &b);
if (flag){
it = upper_bound(ve[b].begin(), ve[b].end(), pos);
if (it == ve[b].end()) flag = false;
else pos = *it;
}
}
if (flag) puts("TAK");
else puts("NIE");
}
return ;
}
BZOJ 2083 vector的巧用+二分的更多相关文章
- bzoj 2083: [Poi2010]Intelligence test——vecto+二分
Description 霸中智力测试机构的一项工作就是按照一定的规则删除一个序列的数字,得到一个确定的数列.Lyx很渴望成为霸中智力测试机构的主管,但是他在这个工作上做的并不好,俗话说熟能生巧,他打算 ...
- BZOJ 3343: 教主的魔法(分块+二分查找)
BZOJ 3343: 教主的魔法(分块+二分查找) 3343: 教主的魔法 Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 1172 Solved: ...
- 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 Intelligence test —— 思路+vector
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2083 先把所有子序列都存下来,总长度应该有限制,所以用 vector 存: 要做到 O(n) ...
- BZOJ 2083: [Poi2010]Intelligence test
Description 问一个序列是不是起始序列的子序列. Sol 二分. 直接维护每个数出现的位置,二分一个最小的就行. Code /******************************** ...
- BZOJ 2440 [中山市选2011]完全平方数 (二分 + 莫比乌斯函数)
2440: [中山市选2011]完全平方数 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 4805 Solved: 2325[Submit][Sta ...
- BZOJ 1901 Zju2112 Dynamic Rankings ——整体二分
[题目分析] 上次用树状数组套主席树做的,这次用整体二分去水. 把所有的查询的结果一起进行二分,思路很好. [代码] #include <cstdio> #include <cstr ...
- BZOJ 2083 Intelligence test
用vector,二分. #include<iostream> #include<cstdio> #include<cstring> #include<algo ...
随机推荐
- 软工实践-Alpha 冲刺 (6/10)
队名:起床一起肝活队 组长博客:博客链接 作业博客:班级博客本次作业的链接 组员情况 组员1(队长):白晨曦 过去两天完成了哪些任务 描述: 已经解决登录注册等基本功能的界面. 完成了主界面的基本布局 ...
- HDU 4747 Mex 递推/线段树
题目链接: acm.hdu.edu.cn/showproblem.php?pid=4747 Mex Time Limit: 15000/5000 MS (Java/Others)Memory Limi ...
- psp 第二周
11号 12号 类别c 内容c 开始时间s 结 ...
- tomcat下部署了多个项目启动报错java web error:Choose unique values for the 'webAppRootKey' context-param in your web.xml files
应该是tomcat下部署了多个项目且都使用log4j. <!--如果不定义webAppRootKey参数,那么webAppRootKey就是缺省的"webapp.root". ...
- 关于command 'gcc' failed with exit status 1 解决方法
Python踩坑之路 Setup script exited with error: command 'gcc' failed with exit status 1 由于没有正确安装Python开发环 ...
- 使用python操作Memcache、Redis、RabbitMQ、
Memcache 简述: Memcache是一套分布式的高速缓存系统,由LiveJournal的Brad Fitzpatrick开发,但目前被许多网站使用以提升网站的访问速度,尤其对于一些大型的.需要 ...
- Delphi实现ERP单据列表栏目设置
什么都不用说了,ERP你懂的.一张报表,不同的客户都可以调死你.直接上图 通过这个设置界面,直接生成参数调整报表所用的DBGridEh.对,是DBGridEh,不是DBGrid,也不是CXGrid. ...
- 【C++】C++函数重载的总结
函数重载: 出现在相同作用域中的两个函数,如果具有相同的名字而形参表不同,则称为重载函数(overloaded function).一定要注意函数重载的两个关键词:形参列表和作用域. 任何程序有且仅有 ...
- 一些兼容性的meta标签
<!-- 仅针对IOS的Safari顶端状态条的样式(可选default/black/black-translucent )--> <meta name="apple-mo ...
- OI队测题解:
Test 17 T1: 题目大意: 喵星系有n个星球,标号为1到n,星球以及星球间的航线形成一棵树. 所有星球间的双向航线的长度都为1.小昕要在若干个星球建矿石仓库,设立每个仓库的费用为K.对于未 ...