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,为什么你必须掌握 对于程序员来说,数据结构是必修的一门课.从查找到排序,从链表到二叉树,几乎所有的算法和原理都需要理解,理解不了也要死记硬背下来.幸运的是这些理论都已经比较成熟,算 ...
随机推荐
- 中科红旗倒下,谁来挑战windows
中科红旗解散 国产操作系统从此梦断 2月10日,关门上锁的中科红旗北京总部大门上粘贴了一张最新公告,这张公告彻底击破了那些仍然坚守公司工作的员工“拯救中国红旗”的希望.该公告称:因北京中科红旗软件技术 ...
- 提取图像(tif)中水体的矢量数据(shp)研究
方法一:1、利用envi打开tif数据,原投影信息为beijing54.envi中没有这个投影。这里选择投影信息(WGS-84)选取水体roi——进行监督分类。这里可以对分类后进行处理(消除文字等干扰 ...
- js截取所需字符串长度
//title :字符串 :interceptLength:所需的长度 function TitleThumbnail(title, interceptLength, thumbnailCharac ...
- mvc简单execl导出
直接上代码: public static byte[] GetExecl(DataTable dt, List<string> list) { var sbHtml = new Strin ...
- Js 处理将时间转换 “年-月-日”
将时间 \/Date(1432828800000+0800)\/" 转换成:“年-月-日” //时间转换function ChangeDateFormat(val) { if (v ...
- EXTJS 3.0 资料 控件之 html 潜入label用法
这是在Extjs 中插入html 控件label! html: "<div><label id='howMany'>您共选中了</label><br ...
- 如何在Linux中关闭apache服务(转)
??? 最近在写一个简单的http服务器,调试的时候发现apache服务器也在机器上跑着,所以得先把apache关掉.当时装apache的时候就是用了普通的sudo get,也不知道装到哪儿了.到网上 ...
- 微软职位内部推荐-Principal Dev Manager for Windows Phone Shell
微软近期Open的职位: Location: China, BeijingDivision: Operations System Group Engineering Group OverviewOSG ...
- Deferred Shading(延迟渲染)
1.简介 在计算机图形学的词典里,Shading表示“对受光物体的渲染”,这个渲染过程包括下面几步[1]: 1) 计算几何多边形(也就是Mesh). 2) 决定表面材质特性,例如法 ...
- Searching in a rotated and sorted array
Given a sorted array that has been rotated serveral times. Write code to find an element in this arr ...