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,为什么你必须掌握 对于程序员来说,数据结构是必修的一门课.从查找到排序,从链表到二叉树,几乎所有的算法和原理都需要理解,理解不了也要死记硬背下来.幸运的是这些理论都已经比较成熟,算 ...
随机推荐
- PHP 归并排序
在我们日常的程序开发时候,有时候需要对一个已知的集合按照一定的规则进行排序,其实当数据的规模不太大时或者数据的有序特征比较明显,其实我们可以采用其它的排序算法例如:Bubble Sort, Inser ...
- Java语法糖
1.创建数组:String[] s = new String[]{"1","2","3"};//这种方法可以在不指定数组元素数量的情况下生成 ...
- dapper 写查询sql 时,多条件参数操作方法
var args = new DynamicParameters(new {}); if (obj.orderId != null) { sb.Append(" AND OrderId = ...
- java 中的匿名内部类
转自http://www.cnblogs.com/nerxious/archive/2013/01/25/2876489.html 匿名内部类也就是没有名字的内部类 正因为没有名字,所以匿名内部类只能 ...
- 关于location
---恢复内容开始--- window.location跳转+替换+刷新 一.最外层top跳转页面,适合用于iframe框架集 top.window.location.href("${pag ...
- N皇后问题2
Description Examine the checkerboard below and note that the six checkers are arranged on the board ...
- Oracle RAC集群安装之:Grid软件安装过程蓝屏
前几天在安装一套RAC服务器的过程中,遇到了蓝屏事件,折腾了蛮久(在排查是否存在硬件问题上花费了相当多一部分时间),整个过程大概说明如下: 1.两台华为的PC SERVER,操作系统为WIN SERV ...
- Oracle的spool命令
在控制台上使用spool 路径+文件名 命令可以将整个过程写入指定的文件中, 结束使用spool off 命令, 当执行spool off后文件中的内容才能看见; ed命令修改当前缓冲区的上一条命令;
- ExtJs 4.2.1 点击按钮弹出表单的窗口
初学ExtJs,做项目的时候想做一个这样的效果:点击按钮弹出对话框,之前一直是使用EasyUi来做的, EasyUi里有Dialog,用起来很方便,但是现在转移到ExtJs上后,发现没有Dialog这 ...
- 使用Yeoman搭建 AngularJS 应用 (12) —— 让我们搭建一个网页应用
原文地址:http://yeoman.io/codelab/local-storage.html 安装Bower程序包 我们使用另一个Angular模块,"angular-local-sto ...