#54157: C++可以用 unordered_map


hch980506@gmail.com (申有娜我老婆)


#include <iostream>
#include <unordered_map>
#include <vector>

using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> num(n);
    unordered_map<int, int> pos;
    for (int i = 0; i < n; i++) {
        cin >> num[i];
        pos[num[i]] = i + 1;
    }
    while (k--) {
        int temp;
        cin >> temp;
        if (pos.count(temp)) {
            cout << pos[temp] << '\n';
        } else {
            cout << "0\n";
        }
    }
}