Untitled
user_9000366
plain_text
2 months ago
697 B
7
Indexable
#include <bits/stdc++.h> #define IOF ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); #define ll long long using namespace std; const int N = 3e5 + 1; int arrq[N]; int main() { IOF ll e, q; deque<int> de; cin >> e >> q; for (int i = 0; i < e; i++) { int x; cin >> x; de.push_back(x); } for (int i = 0; i < q; i++) { cin >> arrq[i]; for (int j = 0; j < e; j++) { if (arrq[i] == de[j]) { cout << j + 1 << " "; de.push_front(de[j]); de.erase(de.begin() + j + 1); break; } } } return 0; }
Editor is loading...
Leave a Comment