Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- //#include <bits/stdc++.h>
- using namespace std;
- int main() {
- int N, Q;
- cin>>N>>Q;
- vector<int> A;
- vector<int> B;
- for(int i = 0; i<N; i++) {
- int x;
- cin>>x;
- A.push_back(x);
- }
- for(int i = 0; i<Q; i++) {
- int x;
- cin>>x;
- B.push_back(x);
- }
- int indeksi[51];
- for(int i = 0; i<51; i++) {
- indeksi[i] = -1;
- }
- for(int i = 0; i<N; i++){
- if(indeksi[A[i]] == -1) {
- indeksi[A[i]] = i+1;
- }
- }
- for(int i = 0; i<Q; i++) {
- cout<<indeksi[B[i]] << " ";
- for(int j = 0; j<51; j++) {
- if(indeksi[j]<indeksi[B[i]] and indeksi[j]!=-1) {
- indeksi[j]++;
- }
- }
- indeksi[B[i]] = 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement