1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct temperature_with_bool {
    vector<int> temperature;
    int number = 1;
};

bool cmpByFirst(temperature_with_bool const &lhs, temperature_with_bool const &rhs) {

    for (int count = 0; count < lhs.temperature.size(); count++) {
        if (lhs.temperature[count] != rhs.temperature[count]) {
            return lhs.temperature[count] < rhs.temperature[count];
        }
    }
    return lhs.number < rhs.number;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int m, n;
    cin >> m >> n;
    temperature_with_bool first_person;
    vector<int> first_person_temp;
    vector<temperature_with_bool> temperature;
    for (int count = 0; count < m; count++) {
        int temp;
        cin >> temp;
        first_person_temp.push_back(temp);
    }
    first_person.temperature = first_person_temp;
    temperature.push_back(first_person);
    for (int count = 1; count < n; count++) {
        int p, x;
        cin >> p >> x;
        vector<int> temp = temperature[count - 1].temperature;
        temperature_with_bool temp2;
        temp[p - 1] = x;
        temp2.temperature = temp;
        temp2.number = count + 1;
        temperature.push_back(temp2);
    }

    sort(temperature.begin(), temperature.end(), cmpByFirst);
    for (int count = 0; count < temperature.size(); count++) {
        cout << temperature[count].number << " ";
        /*for (int count2 = 0; count2 < m; count2++) {
            cout << temperature[count].temperature[count2] << ' ';
        }
        cout << '\n';
        //cout << temperature[count].number << " ";
        */
    }

    cout << '\n';
    return 0;
}