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. 【原】web页面登陆验证

    using Itcast.Mall.Model; using System; using System.Collections.Generic; using System.Linq; using Sy ...

  2. 图片延迟加载库Layzr

    <!DOCTYPE html> <html> <head> <title>Layzr Demo</title> <script src ...

  3. mysql 拷贝表插入新的表

    insert into table1 select * from table; insert into talble set name  = value;

  4. VB6-AppendToLog 通过API写入日志

    工作中免不了需要为自己的程序添加日志,我也从网上扒拉了一个老外写的模块,修改修改了下,凑合用吧. Option Explicit '********************************** ...

  5. python装饰器总结

    一.装饰器是什么 python的装饰器本质上是一个Python函数,它可以让其他函数在不需要做任何代码变动的前提下增加额外功能,装饰器的返回值也是一个函数对象.简单的说装饰器就是一个用来返回函数的函数 ...

  6. 1054. The Dominant Color (20)

    时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Behind the scenes in the compute ...

  7. MySQL的alter的使用

    ALTER TABLE 语句用于在已有的表中添加.修改或删除列 1.ADD [COLUMN] column name (column definitions) [FIRST or AFTER colu ...

  8. vim中编写python代码使用python-mode和syntastic插件时警告(Warning)的消除

    问题: 在Vim使用了syntastic后,编写代码时,可以对代码错误和警告进行相对实时的了解,对编写代码有很大的帮助.同时这个插件和python-mode一起工作时,可以对python代码的编写提供 ...

  9. ios9新特性概述

    1.iPad的分屏功能很重要. 开发者对iPad的分屏功能感到兴奋,并认为其对苹果未来非常重要.电子邮件信息应用Hop创始人艾瑞兹·皮洛索夫(Erez Pilosof)认为,如果苹果如传闻中那样决定推 ...

  10. ExtJs 4.2.1 点击按钮弹出表单的窗口

    初学ExtJs,做项目的时候想做一个这样的效果:点击按钮弹出对话框,之前一直是使用EasyUi来做的, EasyUi里有Dialog,用起来很方便,但是现在转移到ExtJs上后,发现没有Dialog这 ...