1613

高端的东西

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)的更多相关文章

  1. ural 1613 For Fans of Statistics

    #include <cstdio> #include <cstring> #include <map> #include <vector> #inclu ...

  2. STL--G - For Fans of Statistics(两个推断条件-二分)

    G - For Fans of Statistics Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & ...

  3. ural1613 For Fans of Statistics

    For Fans of Statistics Time limit: 1.0 secondMemory limit: 64 MB Have you ever thought about how man ...

  4. A过的题目

    1.TreeMap和TreeSet类:A - Language of FatMouse ZOJ1109B - For Fans of Statistics URAL 1613 C - Hardwood ...

  5. AC题目简解-数据结构

    A - Japan  POJ 3067 要两条路有交叉,(x1,y1)(x2,y2)那么需要满足:(x1-x2)*(y1-y2)<0判断出这是求逆序的问题 树状数组求逆序,先通过自定义的比较器实 ...

  6. STL deque详解

    英文原文:http://www.codeproject.com/Articles/5425/An-In-Depth-Study-of-the-STL-Deque-Container 绪言 这篇文章深入 ...

  7. 时序分解算法:STL

    1. 详解 STL (Seasonal-Trend decomposition procedure based on Loess) [1] 为时序分解中一种常见的算法,将某时刻的数据\(Y_v\)分解 ...

  8. 时间序列分解算法:STL

    1. 详解 STL (Seasonal-Trend decomposition procedure based on Loess) [1] 为时序分解中一种常见的算法,基于LOESS将某时刻的数据\( ...

  9. 详细解说 STL 排序(Sort)

    0 前言: STL,为什么你必须掌握 对于程序员来说,数据结构是必修的一门课.从查找到排序,从链表到二叉树,几乎所有的算法和原理都需要理解,理解不了也要死记硬背下来.幸运的是这些理论都已经比较成熟,算 ...

随机推荐

  1. c#的协变和逆变

    关于协变和逆变要从面向对象继承说起.继承关系是指子类和父类之间的关系:子类从父类继承,所以子类的实例也就是父类的实例.比如说Animal是父类,Dog是从Animal继承的子类:如果一个对象的类型是D ...

  2. ARC forbids explicit message send of release

    http://blog.sina.com.cn/s/blog_7b9d64af01019rqt.html

  3. Unity学习笔记(2):注册映射

    在上一篇文章中(认识Unity)中概要介绍了Unity和Ioc,本节主要介绍IoC中的注册映射,并使用代码和配置文件两种方式进行说明. 定义依赖注入相关信息 定义ILogger接口 public in ...

  4. spring-cloud-hystrix熔断

    依赖pom <dependencyManagement> <dependencies> <dependency> <groupId>org.spring ...

  5. 3.12php

    这是我的第一个博客  纪念一下  反正都是自己看 第一个问题 出现错误 当图片超过1M时就可能出现以下错误  当然这个也跟你php.ini设置有关 如果你php设置里 memory_limit 16M ...

  6. jQuery回车事件

    有网就是好. 全局事件: document.onkeydown=function(e){ var ev=document.all?window.evevt:e; if(ev.keyCode==13){ ...

  7. android.support.v7.app.AppCompatActivity

    1.Android Studio (api 23) 新建项目的时候 Activity public class MainActivity extends AppCompatActivity 2.系统默 ...

  8. Linux下vsftp服务器—上传、下载

    一.  FTP 说明 Linux下常用的FTP Server是vsftp(Very Security File Transfer Protocol),及profpt(Professtional ftp ...

  9. Button控件

    1.通过设置AutoSize(bool)属性来控制按钮的大小以适应文本的长度 btn_One.AutoSize = true;//设置按钮基于内容自动调整大小 2.当按钮得到焦点是自动放大,失去焦点时 ...

  10. jquer ajax

    function SetValue() { var strCodeName = $("#MainContent_ddlFullNameAndFullName").val(); ) ...