#include <bits/stdc++.h> using namespace std; int n, m, val, a, b; vector<int> v[500500]; int t[500500]; bool compare(int a, int b) { return (v[a] < v[b]); } int main() { scanf("%d%d", &n, &m); t[1] = 1; for(int i = 1; i <= n; i++) { scanf("%d", &val); v[1].push_back(val); } for(int i = 2; i <= m; i++) { t[i] = i; v[i] = v[i-1]; scanf("%d%d", &a, &b); v[i][a-1] = b; } sort(t + 1, t + m + 1, compare); for(int i = 1; i <= m; i++) { printf("%d ", t[i]); } 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 32 33 34 | #include <bits/stdc++.h> using namespace std; int n, m, val, a, b; vector<int> v[500500]; int t[500500]; bool compare(int a, int b) { return (v[a] < v[b]); } int main() { scanf("%d%d", &n, &m); t[1] = 1; for(int i = 1; i <= n; i++) { scanf("%d", &val); v[1].push_back(val); } for(int i = 2; i <= m; i++) { t[i] = i; v[i] = v[i-1]; scanf("%d%d", &a, &b); v[i][a-1] = b; } sort(t + 1, t + m + 1, compare); for(int i = 1; i <= m; i++) { printf("%d ", t[i]); } printf("\n"); } |