首页 > 其他 > 详细

UVA 11991 Easy Problem from Rujia Liu?

时间:2014-03-12 22:28:25      阅读:618      评论:0      收藏:0      [点我收藏+]
/**
*   做这题主要是根据演算法笔记里面的数据这边来做的,
*   同时复习下vector,本题采用vector,时间复杂度为O(1)
*
**/

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <map>

using namespace std;

int main()
{
	int n, m, tmp, v;
	unsigned k;
	while(scanf("%d%d", &n, &m) != EOF)
	{
		map<int, vector<int>> mymap;
		for(int i = 0; i < n; i ++)
		{
			scanf("%d", &tmp);
			if(!mymap.count(tmp))
                mymap[tmp] = vector<int>();
            mymap[tmp].push_back(i);
        }

        for(int i = 0; i < m; i ++)
        {
            scanf("%d%d", &k, &v);
            if(!mymap.count(v) || k > mymap[v].size())
                printf("0\n");
            else printf("%d\n", mymap[v].at(k-1) + 1);
        }
        mymap.clear();
	}
	return 0;
}



UVA 11991 Easy Problem from Rujia Liu?,布布扣,bubuko.com

UVA 11991 Easy Problem from Rujia Liu?

原文:http://blog.csdn.net/zone_programming/article/details/21116679

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!