fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int maxn=1e6+14;
  4. int n,m;
  5. map < int , int > mp;
  6. void solve(){
  7. cin >> n >> m;
  8. for (int i = 1; i <= n; i++) {
  9. int x;
  10. cin >> x;
  11. mp[x] = i;
  12. }
  13.  
  14. for (int i = 1; i <= m; i++){
  15. int x;
  16. cin >> x;
  17. if (!mp[x]) {
  18. cout << -1 << '\n';
  19. }
  20. else cout << mp[x] << '\n';
  21. }
  22. }
  23. int main(){
  24. ios_base::sync_with_stdio(0);
  25. cin.tie(0); cout.tie(0);
  26. if (fopen("input.txt","r")){
  27. freopen("input.txt","r",stdin);
  28. freopen("output.txt","w",stdout);
  29. }
  30. solve();
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty