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.
52 lines
1.1 KiB
52 lines
1.1 KiB
2 years ago
|
#include <bits/stdc++.h>
|
||
|
using namespace std;
|
||
|
const int N = 8010;
|
||
|
struct Node {
|
||
|
int id;
|
||
|
int num;
|
||
|
} a[N];
|
||
|
int n, q;
|
||
|
|
||
|
bool cmp(Node &a, Node &b) {
|
||
|
if (a.num == b.num)
|
||
|
return a.id < b.id; // 值一样,号小的在前
|
||
|
else
|
||
|
return a.num < b.num; // 值不一样,小的在前
|
||
|
}
|
||
|
|
||
|
int main() {
|
||
|
scanf("%d%d", &n, &q);
|
||
|
for (int i = 1; i <= n; i++) {
|
||
|
scanf("%d", &a[i].num);
|
||
|
a[i].id = i;
|
||
|
}
|
||
|
|
||
|
sort(a + 1, a + n + 1, cmp);
|
||
|
|
||
|
while (q--) {
|
||
|
int op, x, v;
|
||
|
scanf("%d", &op);
|
||
|
if (op == 1) {
|
||
|
scanf("%d%d", &x, &v);
|
||
|
for (int i = 1; i <= n; i++) {
|
||
|
if (a[i].id == x) {
|
||
|
a[i].num = v;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
sort(a + 1, a + 1 + n, cmp);
|
||
|
}
|
||
|
if (op == 2) {
|
||
|
scanf("%d", &x);
|
||
|
for (int i = 1; i <= n; i++) {
|
||
|
if (a[i].id == x) {
|
||
|
printf("%d\n", i);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return 0;
|
||
|
}
|