国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

uva 11991 Easy Problem from Rujia Liu?

2019-11-14 11:25:21
字體:
來源:轉載
供稿:網友

原題: Given an array, your task is to find the k-th occurrence (from left to right) of an integer v. To make the PRoblem more difficult (and interesting!), you’ll have to answer m such queries. Input There are several test cases. The first line of each test case contains two integers n, m (1 ≤ n,m ≤ 100,000), the number of elements in the array, and the number of queries. The next line contains n positive integers not larger than 1,000,000. Each of the following m lines contains two integer k and v (1 ≤ k ≤ n, 1 ≤ v ≤ 1,000,000). The input is terminated by end-of-file (EOF). Output For each query, print the 1-based location of the occurrence. If there is no such element, output ‘0’instead. Sample Input 8 4 1 3 2 2 4 3 2 1 1 3 2 4 3 2 4 2 Sample Output 2 0 7 0

中文: 給你n個數,然后給你m個查詢,每個查詢包含兩個數k和v問你第k個v的小標是多少?

#include <bits/stdc++.h>using namespace std;unordered_map<int,vector<int>> miv;int n,m;int main(){ ios::sync_with_stdio(false); while(cin>>n>>m) { miv.clear(); for(int i=1;i<=n;i++) { int res; cin>>res; miv[res].push_back(i); } for(int i=1;i<=m;i++) { int k,v; cin>>k>>v; if(miv.find(v)==miv.end()||miv[v].size()<k) cout<<0<<endl; else { cout<<miv[v][k-1]<<endl; } } } return 0;}

思路: 這題的名起的,不秒殺都不好意思~~ 思路見下面的圖 這里寫圖片描述 長方格里面的數是輸入的所有數,每個方格里面的數下面的鏈是按順序存儲的下標值。


上一篇:日期組件

下一篇:P1068 分數線劃定

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 滦平县| 汝南县| 合肥市| 秦安县| 临西县| 女性| 西昌市| 信宜市| 麻栗坡县| 富阳市| 沾化县| 始兴县| 上高县| 芜湖县| 丹凤县| 桃源县| 宁阳县| 柳河县| 延长县| 通榆县| 义马市| 麻栗坡县| 贵溪市| 赤壁市| 桃源县| 两当县| 靖州| 巫溪县| 上饶县| 西丰县| 龙州县| 萨嘎县| 凤凰县| 金乡县| 康保县| 澳门| 常宁市| 昌乐县| 阳曲县| 公安县| 长岛县|