Created
June 12, 2015 18:32
-
-
Save s25g5d4/b40a83d1bce2d989bd56 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <cstring> | |
int main() | |
{ | |
using namespace std; | |
while (true) { | |
int n, m; | |
cin >> n >> m; | |
if (cin.eof()) | |
break; | |
static int vtable[1000000]; | |
int vcount = 0; | |
vector< vector<int> > occurence; | |
memset(vtable, 0, sizeof (vtable)); | |
int i = 0; | |
while (n--) { | |
int u; | |
cin >> u; | |
--u; | |
if (vtable[u] == 0) { | |
vtable[u] = ++vcount; | |
occurence.push_back({++i}); | |
} | |
else | |
occurence[vtable[u] - 1].push_back(++i); | |
} | |
while (m--) { | |
unsigned int k, v; | |
cin >> k >> v; | |
--k; | |
--v; | |
if (vtable[v] == 0 || occurence[vtable[v] - 1].size() <= k) | |
cout << '0' << endl; | |
else | |
cout << occurence[vtable[v] - 1][k] << endl; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment