-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuva11991.cpp
More file actions
35 lines (30 loc) · 804 Bytes
/
uva11991.cpp
File metadata and controls
35 lines (30 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<vector>
#include<iostream>
#include<string>
#include<sstream>
#include<map>
using namespace std;
int main() {
string s;
istringstream iss;
while(getline(cin, s), s.length()) {
int n,m;
iss = istringstream(s);
iss >> n >> m;
map<int, vector<int>> positions;
getline(cin,s); iss = istringstream(s);
for(int i = 1; i <= n; i++) {
int t; iss >> t;
positions[t].push_back(i);
}
for (int i = 0; i < m; i++) {
getline(cin,s); iss = istringstream(s);
int num, pos; iss >> pos >> num;
if (pos > positions[num].size()) {
cout << 0 << endl;
} else {
cout << positions[num][pos-1] << endl;
}
}
}
}