[POI2010]TES-Intelligence Test 洛谷3500 二分
来源:互联网 发布:淘宝怎么好友代付 编辑:程序博客网 时间:2024/05/01 12:28
Description
One of the tasks in the Byteotian Intelligence Test (BIT) is to cross out numbers from an initial sequence in such a way that leaves as a result certain given sequences.
Byteasar longs to become the IQ Master of Byteotia, but he is no good in this kind of tasks.
But since practice makes perfect, he intends to practise a lot.
So much in fact that he asks you to write a program that will facilitate the training by verifying his answers quickly.
给定一个数串,和m个小数串,问这些小串都是不是大数字串的子序列
Solution
首先考试的时候题目都看错了(汗
用vector记录每个数字在原序列中出现的位置,每次在出现的数字里面二分一个大于当前位置的最小位置就可以了
数据只有100,辣鸡出题人
Code
#include <stdio.h>#include <vector>#include <algorithm>#define rep(i, st, ed) for (int i = st; i <= ed; i += 1)#define pb push_back#define N 1000001inline int read(){ char ch = getchar(); int x = 0; while (ch < '0' || ch > '9'){ ch = getchar(); } while (ch <= '9' && ch >= '0'){ x = (x << 1) + (x << 3) + ch - '0'; ch = getchar(); } return x;}using std:: vector;vector<int> pos[N];int main(void){ int n = read(); rep(i, 1, n){ pos[read()].pb(i); } int T = read(); while (T --){ int l = read(); int now = 0; bool flag = true; rep(i, 1, l){ int tmp = read(); vector<int>:: iterator p = std:: lower_bound(pos[tmp].begin(), pos[tmp].end(), now + 1); int tar = p - pos[tmp].begin(); if (tar == pos[tmp].size()){ puts("NIE"); rep(j, i + 1, l){ read(); } flag = false; break; }// printf("%d\n", tar); now = pos[tmp][tar]; } if (flag){ puts("TAK"); } } return 0;}
1 0
- [POI2010]TES-Intelligence Test 洛谷3500 二分
- 【BZOJ】【P2083】【Poi2010】【Intelligence test】【题解】【二分】
- BZOJ 2083 [Poi2010]Intelligence test 二分查找
- bzoj 2083: [Poi2010]Intelligence test (二分)
- [BZOJ2083][Poi2010]Intelligence test(sort+二分)
- [bzoj2083][Poi2010]Intelligence test(二分)
- BZOJ2083:[POI] TES-Intelligence Test
- BZOJ2083: [Poi2010]Intelligence test
- BZOJ2083: [Poi2010]Intelligence test
- POI2010 Intelligence Test
- 2083: [Poi2010]Intelligence test
- bzoj2083 POI2010 Intelligence Test
- 【bzoj2083】[Poi2010]Intelligence test
- BZOJ 2083 [Poi2010]Intelligence test
- BZOJ 2083 Poi2010 Intelligence test 链表
- [BZOJ 2083] Poi 2010 Intelligence test · 二分
- Intelligence test(test)题解
- tes
- 《java学习笔记》MD5加密算法
- mysql-按天或者按月统计数据
- SSM框架整合(三)
- ORA-12519: TNS:no appropriate service handler found 解决
- ubuntu下安装lua的时候出现 lua.c:80:31: fatal error: readline/readline.h: 没有那个文件或目录 这样的报错
- [POI2010]TES-Intelligence Test 洛谷3500 二分
- 安卓目录res/menu中showAsAction用法
- gradle下载更新依赖库失败的解决办法
- 理解Javascript的状态容器Redux
- Hibernate学习-03:入门案例(CRUD(增删改查)操作之添加记录)
- 题目1135:字符串排序
- 质数的计算算法
- Netty线程模型
- JVM 初探(二)