#54848: c++ 解


yp11452086@yphs.tp.edu.tw (705-07張巧妮)


#include <iostream>
#include <vector>
using namespace std;

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    vector<int>live;
    live.push_back(-1);
    vector<pair<int, int>>v;
    pair<int, int> a;
    a.first = -1;
    a.second = -1;
    v.push_back(a);
    for (int i = 1; i<=N; i++) {
        pair<int, int>tmp;
        tmp.first = i-1;
        tmp.second = i+1;
        if (i == 1) tmp.first = -1;
        if (i == N) tmp.second = -1;
        v.push_back(tmp);
        live.push_back(0);
    }
    for (int i = 0; i<M; i++) {
        int tmp;
        cin >> tmp;
        if (live[tmp] == -1) {
            cout << "0u0 ...... ?\n";
            continue;
        }
        const int next = v[tmp].second;
        if (next == -1) {
            cout << "0u0 ...... ?\n";
            continue;
        }
        cout << next << "\n";
        live[next] = -1;
        v[tmp].second = v[next].second;
    }
}