Created
April 25, 2016 00:34
-
-
Save joaogui1/3b2732bcb40d23aac325963061d0a95d to your computer and use it in GitHub Desktop.
This file contains 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 <cstdio> | |
#include <cstdlib> | |
#include <vector> | |
#define MAXN 1000010 | |
using namespace std; | |
vector <int> G[MAXN]; | |
int main(){ | |
int n, m, k, v, a; | |
while(scanf("%d%d", &n, &m) != EOF){ | |
for(int i = 1; i<=MAXN; i++) | |
G[i].clear(); | |
for(int i = 1; i <= n; i++){ | |
scanf("%d", &a); | |
G[a].push_back(i); | |
} | |
for(int i = 1; i <= m; i++){ | |
scanf("%d%d", &k, &v); | |
k--; | |
if(k >= G[v].size()) | |
printf("0\n"); | |
else | |
printf("%d\n", G[v][k]); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment