跳到正文

个人记录

怠马

l6l5约 1 分钟
原文
文章信息与版本

文章信息

发布
2026年9月14日
收录
2026年9月14日
更新
2026年11月3日
篇幅
约 1 分钟

版本

  1. v1当前
C++
#include<bits/stdc++.h>
// #define int long long
using namespace std;
int n,m;
map<int,vector<int>> mp;
signed main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
        mp[x].push_back(i);
	}
	for(int i=1;i<=m;i++){
		int q,w;
		cin>>q>>w;
        if(mp.count(q)==0 || mp[q][w-1]==0){
            cout<<"-1\n";
            continue;
        }
        cout<<mp[q][w-1]<<'\n';
	}
	return 0;
}
原文