SHARE
TWEET

Untitled

a guest Feb 19th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top