题目链接:

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. 不实例化一个 class 的时候使用它的property

    class A: @property def name(self): " print(A.name) # <property object at 0x10d54cf98> cla ...

  2. 浏览器 滚动条 占据 y轴宽度的解决方案

    html { overflow-y: scroll; } :root { overflow-y: auto; overflow-x: hidden; } :root body { position: ...

  3. 本地yum源安装docker

    Directory listing for / audit-libs-python-2.7.6-3.el7.x86_64.rpm checkpolicy-2.5-4.el7.x86_64.rpm co ...

  4. win10 64位下VirtualBox安装CentOS6.9

    第一步:安装VritualBox 百度“VritualBox”下载安装即可: 第二步:下载Linux镜像系统并安装 这里写出我参照的博客,很详细,我就不累赘了! 原文地址:http://blog.cs ...

  5. Obfuscating computer code to prevent an attack

    A method and system for obfuscating computer code of a program to protect it from the adverse effect ...

  6. SQL的四种语言:DDL、DML、DCL、TCL

    1. DDL(Data Definition Language) 数据库定义语言statements are used to define the database structure or sche ...

  7. 黑马程序猿-----Java之你不得不知道的排序

    ------<a href="http://www.itheima.com" target="blank">Java培训.Android培训.iOS ...

  8. Xshell高级后门完整分析报告

    Xshell高级后门完整分析报告 from:https://security.tencent.com/index.php/blog/msg/120 1. 前言 近日,Xshell官方发布公告称其软件中 ...

  9. Mysql-in查询问题

    Mysql-in查询问题 标签(空格分隔): mysql 问题:mysql用in语法查询出来的数据少了好多! 我的实际情况: 数据表: content字段记录着一些选项的id,多个选项用逗号隔开,比如 ...

  10. ui5 call view or method from another view

    // call view or method from another view //# view call // var view2=sap.ui.jsview("ui5d.popup01 ...