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 ...
随机推荐
- 敏捷开发与xp实践 实验报告
20162315 敏捷开发与xp实践 实验报告 实验任务 1.在IDEA中使用工具(Code->Reformate Code)把下面代码重新格式化,再研究一下Code菜单,找出一项让自己感觉最好 ...
- java调试器
javac.exe是编译.java文件 java.exe是执行编译好的.class文件 javadoc.exe是生成Java说明文档 jdb.exe是Java调试器 javaprof.exe是剖析工具 ...
- 测试bug
模板在运行时出现了以下 1 个错误:---------------------------Controller.tt(-1,-1) : error : 获取 AppDomain 以便从主机运行转换时出 ...
- playbook详解—YAML格式的文本
在playbook中有一些核心的指令 hosts:指明命令运行在哪个node之上 remote_user:在远端的node之上以什么用户的身份运行命令 var:给模板传递变量值 tasks:指明需要执 ...
- (转)关于ActiveMQ的配置
目前常用的消息队列组建无非就是MSMQ和ActiveMQ,至于他们的异同,这里不想做过多的比较.简单来说,MSMQ内置于微软操作系统之中,在部署上包含一个隐性条件:Server需要是微软操作系统.(对 ...
- 在MySQL中如何使用覆盖索引优化limit分页查询
背景 今年3月份时候,线上发生一次大事故.公司主要后端服务器发生宕机,所有接口超时.宕机半小时后,又自动恢复正常.但是过了2小时,又再次发生宕机. 通过接口日志,发现MySQL数据库无法响应服务器.在 ...
- 解决Qt creator无法输入中文
详细的方法来自以下网址: http://my.oschina.net/lieefu/blog/505363?p={{currentPage+1}} 需要说明的几点: 设置qmake 的路径使用自身的路 ...
- Arrays.toString 如果传入的是对象 那么调用的是此对象的toString
Arrays.toString(Object[] obj) 如果传入参数的是对象 那么调用的是此对象的toString
- android面试(5)---SQL数据库
SQL基础: 1.如何查询table1从20到30条记录: select * from table1 limit 19,11 2.替换id=1,name =deman的记录? replace into ...
- 【数据库_Mysql】查询当前年份的sql
1.本年份 SELECT DATE_FORMAT(NOW(), '%Y'); 2.本月份(显示数字) SELECT DATE_FORMAT(NOW(), '%m'); 3.本月份(显示英文) SELE ...