Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main() {
- int n, q;
- cin >> n >> q;
- int niza[n], b[q];
- for(int i = 0; i < n; i++) {
- cin >> niza[i];
- }
- for(int i = 0; i < q; i++) {
- cin >> b[i];
- }
- int idx[55];
- for(int i = 1; i <= 50; i++) {
- idx[i] = 0;
- }
- for(int i = 0; i < n; i++) {
- if(idx[niza[i]] == 0) {
- idx[niza[i]] = i + 1;
- }
- }
- for(int i = 0; i < q; i++) {
- int x = b[i];
- cout << idx[x] << " ";
- for(int j = 1; j <= 50; j++) {
- if(idx[j] != 0 and idx[j] < idx[x]) {
- idx[j]++;
- }
- }
- idx[x] = 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement