当前位置:编程学习 > C/C++ >>

UVA 11991

[cpp] 
#include <iostream> 
#include <vector> 
#include <map> 
#include <cstdio> 
using namespace std; 
 
map<int, vector<int> > a; 
     
 
int main(){ 
    int n, m, x, y; www.zzzyk.com
    while(scanf("%d%d", &n, &m)) { 
        a.clear(); 
        for(int i = 0; i < n; i++) { 
            scanf("%d", &x); 
            if(!a.count(x)) { 
                a[x] = vector<int>(); 
            } 
            a[x].push_back(i+1); 
        } 
        while(m--) { 
            scanf("%d%d", &x, &y); 
            if(!a.count(y) || a[y].size() < x){ 
                printf("0\n"); 
            } 
            else{ 
                printf("%d\n", a[y][x-1]); 
            } 
        } 
    } 
补充:软件开发 , C++ ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,