AOJ 0011

Drawing Lots | Aizu Online Judge

#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main() {
    int w, n;
    cin >> w;
    cin >> n;

    vector<int> lots(w);
    iota(lots.begin(), lots.end(), 1);

    for (int i = 0; i < n; ++i) {
        pair<int, int> p;
        cin >> p.first;
        cin.ignore();
        cin >> p.second;
        iter_swap(lots.begin() + p.first - 1, lots.begin() + p.second - 1);
    }

    for (auto l : lots) {
        cout << l << endl;
    }

    return 0;
}