Advertisement
Josif_tepe

Untitled

Feb 29th, 2024
882
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. //#include <bits/stdc++.h>
  4. #include <cmath>
  5. #include <fstream>
  6. #include <cstring>
  7. #include <algorithm>
  8. using namespace std;
  9. typedef long long ll;
  10. const ll  maxn = 3e5 + 10;
  11. const ll  logn = 18;
  12. const ll  INF = 2e15;
  13.  
  14. int main() {
  15.     ios_base::sync_with_stdio(false);
  16.     int n, q;
  17.     cin >> n >> q;
  18.    
  19.     vector<int> v(n);
  20.     vector<int> idx(55, -1);
  21.     for(int i = 0; i < n; i++) {
  22.         cin >> v[i];
  23.         if(idx[v[i]] == -1) {
  24.             idx[v[i]] = i;
  25.         }
  26.     }
  27.    
  28.     for(int i = 0; i < q; i++) {
  29.         int x;
  30.         cin >> x;
  31.         cout << idx[x] + 1 << " ";
  32.         for(int j = 1; j <= 50; j++){
  33.             if(idx[j] != -1 and idx[j] < idx[x]) {
  34.                 idx[j]++;
  35.             }
  36.         }
  37.         idx[x] = 0;
  38.     }
  39.    
  40.     return 0;
  41. }
  42.  
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement