题目链接:

option=com_onlinejudge&Itemid=8&page=show_problem&problem=3142">https://uva.onlinejudge.org/index.php?

option=com_onlinejudge&Itemid=8&page=show_problem&problem=3142

题意:

给一个长度n的序列。有m询问,每一个询问会问第k个出现的数字的下标是多少

用map记录

代码:

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <queue>
#include <stack>
#include <map> using namespace std; int n, m;
map<int ,vector<int> > mp; int c[1001000]; int main()
{
while (~scanf("%d%d", &n, &m))
{
mp.clear();
memset(c, 0, sizeof(c)); int tmp;
for (int i = 1; i <= n; i++)
{
scanf("%d", &tmp);
mp[tmp].push_back(i);
}
int a, b;
while (m--)
{
scanf("%d%d", &a, &b);
if (mp[b].size() < a) printf("0\n");
else printf("%d\n", mp[b][a - 1]);
}
}
return 0;
}

UVA 11991 Easy Problem from Rujia Liu?【STL】的更多相关文章

  1. 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, ...

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

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

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

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

  4. [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 ...

  5. 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, ...

  6. STL UVA 11991 Easy Problem from Rujia Liu?

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

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

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

  8. 11991 - Easy Problem from Rujia Liu?(的基础数据结构)

    UVA 11991 - Easy Problem from Rujia Liu? 题目链接 题意:给一个长度n的序列,有m询问,每一个询问会问第k个出现的数字的下标是多少 思路:用map和vector ...

  9. uva--11991 - Easy Problem from Rujia Liu?(sort+二分 map+vector vector)

    11991 - Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for e ...

随机推荐

  1. 常用类Object,String类详解

    -------------------- String -----------------------1.求字符串长度 public int length()//返回该字符串的长度 String st ...

  2. How Javascript works (Javascript工作原理) (九) 网页消息推送通知机制

    个人总结: 1.介绍了网页消息推送通知机制 全文地址:https://github.com/Troland/how-javascript-works 这是 JavaScript 工作原理的第九章. 现 ...

  3. 《Craking the Coding interview》python实现---01

    ###题目:给定一个字符串,判断其中是否有重复字母###思路:将重复的字符放入到list中,并进行计数统计###实现:伪代码.函数.类实现###伪代码:string=s #给定的字符串list=[] ...

  4. Mysql学习总结(29)——MySQL中CHAR和VARCHAR

    MySQL数据库的字符(串)类不要以为字符类型就是CHAR,CHAR和VARCHAR的区别在于CHAR是固定长度,只要你定义一个字段是CHAR(10),那么不论你存储的数据是否达到了10个字节,它都要 ...

  5. LeetCode——Longest Common Prefix

    Write a function to find the longest common prefix string amongst an array of strings. 写一个函数找出字符串数组中 ...

  6. LeetCode 232: Implement Queue using Stacks

    Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of ...

  7. sql server management studio 快速折叠object explorer中的instance

    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/6e20fa7a-c0a9-496b-89b2-19c6bd996ffc/how-to ...

  8. Func委托和Action委托

    http://stackoverflow.com/questions/4317479/func-vs-action-vs-predicate The difference between Func a ...

  9. 陈-朱-兴- js写法【案例】:

    ajax请求: 一.从服务器端请求数据: var url = '';url = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid='+ ...

  10. BZOJ 1174: [Balkan2007]Toponyms

    Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 735  Solved: 102[Submit][Status][Discuss] Descriptio ...