uva 11991 Easy Problem from Rujia Liu? vector+map
水题 学习一下数据的存储方法。
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<vector>
#include<map>
using namespace std;
int n,m;
map<int,vector<int> >a; int main()
{
while(~scanf("%d%d",&n,&m))
{
for(int i=;i<n;i++)
{
int x;
scanf("%d",&x);
if(!a.count(x))
a[x]=vector<int>();
a[x].push_back(i+);
}
while(m--)
{
int x,y;
scanf("%d%d",&x,&y);
if(a[y].size()<x||!a.count(y))
printf("0\n");
else
printf("%d\n",a[y][x-]);
}
}
return ;
}
uva 11991 Easy Problem from Rujia Liu? vector+map的更多相关文章
- uva 11991 - Easy Problem from Rujia Liu?(STL)
option=com_onlinejudge&Itemid=8&page=show_problem&problem=3142" target="_blank ...
- CJOJ 2485 UVa 11991 生日礼物 / UVa 11991 Easy Problem from Rujia Liu?
CJOJ 2485 UVa 11991 生日礼物 / UVa 11991 Easy Problem from Rujia Liu? Description (原题来自刘汝佳<训练指南>Pa ...
- [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 ...
- 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, ...
- 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, ...
- UVA 11991 Easy Problem from Rujia Liu?【STL】
题目链接: option=com_onlinejudge&Itemid=8&page=show_problem&problem=3142">https://uv ...
- STL UVA 11991 Easy Problem from Rujia Liu?
题目传送门 题意:训练指南P187 分析:用vector存id下标,可以用map,也可以离散化用数组存(发现不用离散化也可以) map #include <bits/stdc++.h> u ...
- 11991 - Easy Problem from Rujia Liu?(的基础数据结构)
UVA 11991 - Easy Problem from Rujia Liu? 题目链接 题意:给一个长度n的序列,有m询问,每一个询问会问第k个出现的数字的下标是多少 思路:用map和vector ...
- 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 ...
随机推荐
- eclipse(Version: Neon Release (4.6.0))安装hibernate tools
这里需要说明的是,hibernate tools是jboss推出的. eclipse——>Eclipse Marketplace... 输入jboss-tools进行搜索 选择jboss too ...
- Matlab计算矩阵间距离
夜深人静时分,宿舍就我自己,只有蚊子陪伴着我,我慢慢码下这段文字............ 感觉知识结构不完善:上学期看论文,发现类间离散度矩阵和类内离散度矩阵,然后百度,找不到,现在学模式识别,见了, ...
- What is an eigenvector of a covariance matrix?
What is an eigenvector of a covariance matrix? One of the most intuitive explanations of eigenvector ...
- SQLite数据库简介(转)
大家好,今天来介绍一下SQLite的相关知识,并结合Java实现对SQLite数据库的操作. SQLite是D.Richard Hipp用C语言编写的开源嵌入式数据库引擎.它支持大多数的SQL92标准 ...
- Unity3d大会的部分总结
原地址:http://blog.csdn.net/sgnyyy/article/details/23775219 一.项目开发,管理和发布策略 1. 四大准则 a. 美术的资源 ...
- MySQL exist
http://www.cnblogs.com/glory-jzx/archive/2012/07/19/2599215.html http://www.w3school.com.cn/sql/func ...
- 一个简单的C#加密解密类
//DES默认密钥向量 private static byte[] Keys = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF }; /// < ...
- highcharts 切换
<!doctype html> <html lang="en"> <head> <script type="text/javas ...
- redis其他问题
如何解决redis高并发客户端频繁time out? 现在业务上每天有5亿+的请求,平时redis的操作在2K+每秒左右.到了高峰有3K+,这时候客户端就会频繁的报connect time out的异 ...
- UVA 10041 Vito's Family (中位数)
Problem C: Vito's family Background The world-known gangster Vito Deadstone is moving to New York ...