Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- //#include <bits/stdc++.h>
- #include <cmath>
- #include <fstream>
- #include <cstring>
- #include <algorithm>
- using namespace std;
- typedef long long ll;
- const ll maxn = 3e5 + 10;
- const ll logn = 18;
- const ll INF = 2e15;
- int main() {
- ios_base::sync_with_stdio(false);
- int n, q;
- cin >> n >> q;
- vector<int> v(n);
- vector<int> idx(55, -1);
- for(int i = 0; i < n; i++) {
- cin >> v[i];
- if(idx[v[i]] == -1) {
- idx[v[i]] = i;
- }
- }
- for(int i = 0; i < q; i++) {
- int x;
- cin >> x;
- cout << idx[x] + 1 << " ";
- for(int j = 1; j <= 50; j++){
- if(idx[j] != -1 and idx[j] < idx[x]) {
- idx[j]++;
- }
- }
- idx[x] = 0;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement