2024-10-10 13:15:37 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2024-10-21 13:41:32 +00:00
|
|
|
const int N = 10005;
|
2024-10-10 13:15:37 +00:00
|
|
|
|
2024-10-21 13:41:32 +00:00
|
|
|
pair<int, int> arr[N];
|
2024-10-22 14:03:21 +00:00
|
|
|
int beta[N];
|
2024-10-21 13:41:32 +00:00
|
|
|
|
|
|
|
int main() {
|
|
|
|
int n, m;
|
|
|
|
scanf("%d%d", &n, &m);
|
2024-10-10 13:15:37 +00:00
|
|
|
for (int i = 1; i <= n; i++) {
|
2024-10-21 13:41:32 +00:00
|
|
|
scanf("%d", &arr[i].first);
|
|
|
|
arr[i].second = i;
|
2024-10-10 13:15:37 +00:00
|
|
|
}
|
2024-10-21 13:41:32 +00:00
|
|
|
sort(arr + 1, arr + n + 1);
|
2024-10-22 14:03:21 +00:00
|
|
|
for (int i = 1; i <= n; i++) beta[arr[i].second] = i;
|
2024-10-21 13:41:32 +00:00
|
|
|
while (m--) {
|
|
|
|
int op, x, y;
|
|
|
|
scanf("%d", &op);
|
2024-10-10 13:15:37 +00:00
|
|
|
if (op == 1) {
|
2024-10-21 13:41:32 +00:00
|
|
|
scanf("%d%d", &x, &y);
|
2024-10-22 14:03:21 +00:00
|
|
|
arr[beta[x]].first = y;
|
2024-10-21 13:41:32 +00:00
|
|
|
for (int i = 1; i < n; i++) {
|
|
|
|
if (arr[i] > arr[i + 1]) swap(arr[i], arr[i + 1]);
|
2024-10-10 13:15:37 +00:00
|
|
|
}
|
2024-10-21 13:41:32 +00:00
|
|
|
for (int i = n - 1; i >= 1; i--) {
|
|
|
|
if (arr[i] > arr[i + 1]) swap(arr[i], arr[i + 1]);
|
2024-10-10 13:15:37 +00:00
|
|
|
}
|
2024-10-22 14:03:21 +00:00
|
|
|
for (int i = 1; i <= n; i++) beta[arr[i].second] = i;
|
2024-10-21 13:41:32 +00:00
|
|
|
} else {
|
|
|
|
scanf("%d", &x);
|
2024-10-22 14:03:21 +00:00
|
|
|
printf("%d\n", beta[x]);
|
2024-10-10 13:15:37 +00:00
|
|
|
}
|
|
|
|
}
|
2024-10-21 13:41:32 +00:00
|
|
|
return 0;
|
2024-10-10 13:15:37 +00:00
|
|
|
}
|