fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. long long a[100000],x,dem[10000000],n,m;
  4. int main() {
  5. cin>>n>>m;
  6. for(int i=1; i<=n; i++)
  7. cin>>a[i];
  8. for(int i=n; i>=1; i--)
  9. dem[a[i]]=i;
  10. for(int i=1; i<=m; i++){
  11. cin>>x;
  12. cout<<dem[x]<<" ";
  13. }
  14. return 0;
  15. }
Success #stdin #stdout 0.01s 5548KB
stdin
7 5
6 4 7 2 4 1 3
3 1 5 4 8
stdout
7 6 0 2 0