Though Rujia Liu usually sets hard problems for contests (for example, regional contests like
Xi’an 2006, Beijing 2007 and Wuhan 2009, or UVa OJ contests like Rujia Liu’s Presents 1
and 2), he occasionally sets easy problem (for example, ‘the Coco-Cola Store’ in UVa OJ),
to encourage more people to solve his problems :D
Given an array, your task is to find the k-th occurrence (from left to right) of an integer v. To make the problem more difficult (and interesting!), you’ll have to answer m such queries.
Input There are several test cases. The first line of each test case contains two integers n, m (1 ≤ n,m ≤ 100,000), the number of elements in the array, and the number of queries. The next line contains n positive integers not larger than 1,000,000. Each of the following m lines contains two integer k and v (1 ≤ k ≤ n, 1 ≤ v ≤ 1,000,000). The input is terminated by end-of-file (EOF).
Output
For each query, print the 1-based location of the occurrence. If there is no such element, output ‘0’ instead.
Sample Input
8 4

1 3 2 2 4 3 2 1

1 3

2 4

3 2

4 2
Sample Output
2

0

7

0

题意: 给你一个长度为n的序列 m组询问 第k个v在序列中的位置

题解:水 vector 处理

 #include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
using namespace std;
int n,m;
int exm;
vector<int> ve[];
int k,v;
int main()
{
while(scanf("%d %d",&n,&m)!=EOF)
{
for(int i=;i<=;i++)
ve[i].clear();
for(int i=;i<=n;i++)
{
scanf("%d",&exm);
ve[exm].push_back(i);
}
for(int j=;j<=m;j++)
{
scanf("%d %d",&k,&v);
if(ve[v].size()<k||ve[v].size()==)
cout<<""<<endl;
else
cout<<ve[v][k-]<<endl;
}
}
return ;
}

UVA 11991 vector的更多相关文章

  1. uva 11991 - Easy Problem from Rujia Liu?(STL)

    option=com_onlinejudge&Itemid=8&page=show_problem&problem=3142" target="_blank ...

  2. CJOJ 2485 UVa 11991 生日礼物 / UVa 11991 Easy Problem from Rujia Liu?

    CJOJ 2485 UVa 11991 生日礼物 / UVa 11991 Easy Problem from Rujia Liu? Description (原题来自刘汝佳<训练指南>Pa ...

  3. UVa 11991:Easy Problem from Rujia Liu?(STL练习,map+vector)

    Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for example, ...

  4. UVA 11991 Easy Problem from Rujia Liu?(vector map)

    Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for example, ...

  5. uva 11991 Easy Problem from Rujia Liu? vector+map

    水题 学习一下数据的存储方法. #include<iostream> #include<cstdio> #include<cstdlib> #include< ...

  6. [UVA] 11991 - Easy Problem from Rujia Liu? [STL应用]

    11991 - Easy Problem from Rujia Liu? Time limit: 1.000 seconds Problem E Easy Problem from Rujia Liu ...

  7. UVA 11991 Easy Problem from Rujia Liu?【STL】

    题目链接: option=com_onlinejudge&Itemid=8&page=show_problem&problem=3142">https://uv ...

  8. STL UVA 11991 Easy Problem from Rujia Liu?

    题目传送门 题意:训练指南P187 分析:用vector存id下标,可以用map,也可以离散化用数组存(发现不用离散化也可以) map #include <bits/stdc++.h> u ...

  9. uva 11991

    STL 使用,,由于数据范围没有 超越极限数据  依旧可以用 vector 搞定: #include<iostream> #include<stdio.h> #include& ...

随机推荐

  1. 【转】C++ 值传递、指针传递、引用传递详解

    而关于值传递,指针传递,引用传递这几个方面还会存在误区, 所有我觉的有必要在这里也说明一下~ 下文会通过例子详细说明哦 值传递: 形参是实参的拷贝,改变形参的值并不会影响外部实参的值.从被调用函数的角 ...

  2. SummerVocation_Learning--java的线程同步

    public class Test_XCTB implements Runnable{ Timer timer = new Timer(); public static void main(Strin ...

  3. 10分钟了解 react 引入的 Hooks

    "大家好,我是谷阿莫,今天要将的是一个...",哈哈哈,看到这个题我就想到这个开头.最近react 官方在 2018 ReactConf 大会上宣布 React v16.7.0-a ...

  4. POJ 2299 Ultra-QuickSort 简单题解

    Ultra-QuickSort Time Limit: 7000MS   Memory Limit: 65536K Total Submissions: 68874   Accepted: 25813 ...

  5. JS如何判断是否为ie浏览器的方法(包括IE10、IE11在内)

    判断是否IE浏览器用的是window.navigator.userAgent,跟踪这个信息,发现在开发环境,识别为IE10,但访问服务器则识别为IE11,但IE11的userAgent里是没有MSIE ...

  6. ubuntu怎样打开终端

    1.首先在桌面任意空白处,按CTRL+ALT+T 2.方法二

  7. Memory loss【记忆缺失】

    Memory Loss Losing your ability to think and remember is pretty scary. We know the risk of dementia ...

  8. The DOM in JavaScript

    DOM : Document Object Model   D is for document :  The DOM cant work without a document . When you c ...

  9. appcompat_v7\res\values-v21\themes_base.xml:158: error: Error: No resource

    C:\DevelopSoft\workspace\appcompat_v7\res\values-v21\themes_base.xml:158: error: Error: No resource ...

  10. 网络安全巧设置 Win2008 R2 防火墙详解(1)

    针对一般中小企业型来说,如果希望对企业网络进行安全管理,不一定非得花高价钱购买专业的防火墙设置,直接借助操作系统本身自带的防火墙功能即可以满足一般企业的应用,今天我们就一起来探究一下Windows S ...