Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  int Q, N, aux;
  5.  map<int,int> position;
  6.  set<int> exists;
  7.  int main(){
  8.      cin.tie(0);
  9.      ios::sync_with_stdio(0);
  10.      cin>>Q>>N;
  11.      for(int i = 0; i<Q;i++){
  12.          cin>>aux;
  13.          exists.insert(aux);
  14.          if(i != 0){
  15.              if(position[aux]==0){
  16.               position[aux] = i;
  17.              }
  18.          }
  19.      }
  20.      for(int i = 0; i<N;i++){
  21.          cin>>aux;
  22.          if(exists.count(aux)){
  23.              cout<<position[aux]<<"\n";
  24.          }else{
  25.              cout<<"-1\n";
  26.          }
  27.      }
  28.      return 0;
  29.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement