1613. For Fans of Statistics(STL)
高端的东西
lower_bounder
函数lower_bound()在first和last中的前闭后开区间进行二分查找,返回大于或等于val的第一个元素位置。如果所有元素都小于val,则返回last的位置,且last的位置是越界的
然后用map 把数映射成容器 可以简单查询到每个数出现的最前和最后位置 再与给出的L,R相比较
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<map>
using namespace std;
#define N 70010
map<int,vector<int> >t;
vector<int>::iterator it;
int main()
{
int i,k,n,a;
scanf("%d",&n);
for(i = ; i <= n ; i++)
{
scanf("%d",&a);
t[a].push_back(i);
}
scanf("%d",&k);
for(i = ; i <= k ;i++)
{
int l,r,x;
scanf("%d%d%d",&l,&r,&x);
it = lower_bound(t[x].begin(),t[x].end(),l);
if(it==t[x].end())
printf("");
else if((*it)<=r)
printf("");
else
printf("");
}
puts("");
return ;
}
1613. For Fans of Statistics(STL)的更多相关文章
- ural 1613 For Fans of Statistics
#include <cstdio> #include <cstring> #include <map> #include <vector> #inclu ...
- STL--G - For Fans of Statistics(两个推断条件-二分)
G - For Fans of Statistics Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & ...
- ural1613 For Fans of Statistics
For Fans of Statistics Time limit: 1.0 secondMemory limit: 64 MB Have you ever thought about how man ...
- A过的题目
1.TreeMap和TreeSet类:A - Language of FatMouse ZOJ1109B - For Fans of Statistics URAL 1613 C - Hardwood ...
- AC题目简解-数据结构
A - Japan POJ 3067 要两条路有交叉,(x1,y1)(x2,y2)那么需要满足:(x1-x2)*(y1-y2)<0判断出这是求逆序的问题 树状数组求逆序,先通过自定义的比较器实 ...
- STL deque详解
英文原文:http://www.codeproject.com/Articles/5425/An-In-Depth-Study-of-the-STL-Deque-Container 绪言 这篇文章深入 ...
- 时序分解算法:STL
1. 详解 STL (Seasonal-Trend decomposition procedure based on Loess) [1] 为时序分解中一种常见的算法,将某时刻的数据\(Y_v\)分解 ...
- 时间序列分解算法:STL
1. 详解 STL (Seasonal-Trend decomposition procedure based on Loess) [1] 为时序分解中一种常见的算法,基于LOESS将某时刻的数据\( ...
- 详细解说 STL 排序(Sort)
0 前言: STL,为什么你必须掌握 对于程序员来说,数据结构是必修的一门课.从查找到排序,从链表到二叉树,几乎所有的算法和原理都需要理解,理解不了也要死记硬背下来.幸运的是这些理论都已经比较成熟,算 ...
随机推荐
- Couchbase上发布的关于NoSQL的技术论文
Couchbase是CouchDB与Membase两个NoSQL数据库相结合的产物,本文推荐的是Couchbase官方发表的一篇论文,命名为<NoSQL Database Technology& ...
- php计算时间差的方法
一个简单的例子:计算借书的天数,根据每天的日期进行计算. (1) 有数据库的情况 MSSQL可以使用触发器!用专门计算日期差的函数datediff()便可. MYSQL那就用两个日期字 ...
- [Git]代码管理工具简单使用
1 Git简介 Git是分布式的版本控制系统,是Linux内核开发者林纳斯·托瓦兹(Linus Torvalds)为更好地管理Linux内核开发而设计.与CVS.Subversion一类的集中式版本控 ...
- 如何在eclipse中配置Selenium
1, Install python 33.(Python 27也可以) 2, Setup Selenium If you did not install Easy_install module, yo ...
- c语言指针说解
一. 指针定义 1指针的意义 2指针的赋值 指针变量同普通变量一样,使用之前不仅要定义说明, 而且必须赋予具体的值.未经赋值的指针变量不能使用, 否则将造成系统混乱. #include <std ...
- SharedPreference.Editor的apply与commit方法不同之处
定义: void apply boolean commit; 相同:二者都是提交修改的数据 手机里的文件存放在/data/data/<package_name>/shared_prefs ...
- 关于count(1) 和 count(*)
Q:What is the difference between count(1) and count(*) in a sql queryeg.select count(1) from emp; an ...
- html template
https://wrapbootstrap.com/tag/single-page http://themeforest.net/ https://wrapbootstrap.com/themes h ...
- hdu 4740 The Donkey of Gui Zhou(暴力搜索)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4740 [题意]: 森林里有一只驴和一只老虎,驴和老虎互相从来都没有见过,各自自己走过的地方不能走第二次 ...
- 通过android.provider包查看android系统定义的provider.
原先的2.2的android源码已经不是那么容易找到了,我稍稍搜索了下找到了一两个没速度的死链就失去了兴趣.不过还好忽然发现在android.provider包下包含了常见的provider的使用方法 ...