You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.0 KiB

#include <bits/stdc++.h>
using namespace std;
const int N = 8010;
struct Node {
int value;
int id;
} a[N];
bool cmp(Node &a, Node &b) {
if (a.value == b.value) return a.id < b.id;
return a.value < b.value;
}
int n;
int q;
int main() {
//加快读入
cin.tie(0), ios::sync_with_stdio(false);
cin >> n >> q;
for (int i = 1; i <= n; i++) {
cin >> a[i].value;
a[i].id = i;
}
sort(a + 1, a + 1 + n, cmp);
while (q--) {
int op, x, v;
cin >> op;
if (op == 1) {
cin >> x >> v;
for (int i = 1; i <= n; i++)
if (a[i].id == x) {
a[i].value = v;
break;
}
sort(a + 1, a + 1 + n, cmp);
} else {
cin >> x;
for (int i = 1; i <= n; i++)
if (a[i].id == x) {
cout << i << endl;
break;
}
}
}
return 0;
}