【vector】【bzoj 2083】Intelligence test
来源:互联网 发布:linux和windows传文件 编辑:程序博客网 时间:2024/05/17 02:24
2083: [Poi2010]Intelligence test
Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 294 Solved: 130
Description
霸中智力测试机构的一项工作就是按照一定的规则删除一个序列的数字,得到一个确定的数列。Lyx很渴望成为霸中智力测试机构的主管,但是他在这个工作上做的并不好,俗话说熟能生巧,他打算做很多练习,所以他希望你写一个程序来快速判断他的答案是否正确。
Input
第一行为一个整数m(1<=m<=1000000)第二行包括m个用空格分开的整数ai(1<=ai<=1000000),组成了最初的序列,第三行为一个整数n(1<=n<=1000000),表示n个Lyx经过一系列删除得到的序列,每个序列两行,第一行给出长度L(1<=L<=m),然后下一行为L个由空格分开的整数bi(1<=bi<=1000000)。
Output
共n行,如果Lyx的序列确实是由最初的序列删除一些数得到,就输出TAK,否则输出NIE。
Sample Input
71 5 4 5 7 8 6451 5 5 8 632 2 235 7 841 5 7 4
Sample Output
TAKNIETAKNIEHINT
Source
by poi
题解:
vector。
STL就是棒!
对每个权值开一个vector,然后每次对一个序列二分一下位置就好了,显然每个位置越靠前越好。
Code:
#include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<cmath>#include<vector>#include<algorithm>using namespace std;vector<int> a[1001000];int n,m,b[1001000];int in(){ int x=0; char ch=getchar(); while (ch<'0' || ch>'9') ch=getchar(); while (ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar(); return x;}bool work(int l){ int last=-1; for (int i=1; i<=l; i++){ vector<int>::iterator it=upper_bound(a[b[i]].begin(),a[b[i]].end(),last); if (it==a[b[i]].end()) return false; last=*it; } return true;}int main(){ n=in(); for (int i=1; i<=n; i++){ int x=in(); a[x].push_back(i); } m=in(); for (int i=1; i<=m; i++){ int l=in(); for (int j=1; j<=l; j++) b[j]=in(); if (work(l)) printf("TAK\n"); else printf("NIE\n"); } return 0;}
1 0
- 【vector】【bzoj 2083】Intelligence test
- bzoj-2083 Intelligence test
- BZOJ 2083 [Poi2010]Intelligence test
- BZOJ 2083 Poi2010 Intelligence test 链表
- BZOJ 2083 [Poi2010]Intelligence test 二分查找
- bzoj 2083: [Poi2010]Intelligence test (二分)
- [BZOJ 2083] Poi 2010 Intelligence test · 二分
- 题解 BZOJ-2083 || POI 2010 intelligence test 三种解法
- 2083: [Poi2010]Intelligence test
- 【BZOJ】【P2083】【Poi2010】【Intelligence test】【题解】【二分】
- Intelligence test(test)题解
- Threat Intelligence Quotient Test
- BZOJ2083: [Poi2010]Intelligence test
- BZOJ2083: [Poi2010]Intelligence test
- POI2010 Intelligence Test
- bzoj2083 POI2010 Intelligence Test
- 【bzoj2083】[Poi2010]Intelligence test
- BZOJ2083:[POI] TES-Intelligence Test
- BLHeli
- hdu 1272 小希的迷宫 (并查集)
- IOS--JSON数据解析成字典
- java之集合Collection详解之2
- hdu 5365+hdu 5355
- 【vector】【bzoj 2083】Intelligence test
- 多路复用/多路分解
- POJ 3070 矩阵快速幂
- HDU - 1241 Oil Deposits
- 如何使用 Docker 部署一个基于 Play Framework 的 Scala Web 应用?
- 8月10日----数据库
- 【消息队列MQ】各类MQ比较
- JAVA 基础 (循环)
- VS2015 企业版不支持 JavaScript 语法高亮、智能提醒