#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int n,m;
scanf("%d %d", &n, &m);
vector<vector<int>> tos;
vector<int> first;
for(int i=0; i<n; i++){
int x;
scanf("%d", &x);
first.push_back(x);
}
first.push_back(0);
tos.push_back(first);
for(int i=1; i<m; i++){
int p, x;
scanf("%d %d", &p, &x);
tos.push_back(tos.back());
tos.back()[p-1] = x;
tos.back().back() = i;
}
sort(tos.begin(), tos.end());
for(auto& t: tos){
printf("%d ", t.back() + 1);
}
printf("\n");
}
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 | #include <cstdio> #include <vector> #include <algorithm> using namespace std; int main(){ int n,m; scanf("%d %d", &n, &m); vector<vector<int>> tos; vector<int> first; for(int i=0; i<n; i++){ int x; scanf("%d", &x); first.push_back(x); } first.push_back(0); tos.push_back(first); for(int i=1; i<m; i++){ int p, x; scanf("%d %d", &p, &x); tos.push_back(tos.back()); tos.back()[p-1] = x; tos.back().back() = i; } sort(tos.begin(), tos.end()); for(auto& t: tos){ printf("%d ", t.back() + 1); } printf("\n"); } |
English