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.

55 lines
1.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
const int N = 8010;
struct Node {
int id;
int value;
bool operator<(const Node &t) const {
if (value == t.value) return id < t.id;
return value < t.value;
}
} a[N];
int n, q;
/*
测试结果:
1、不加cin优化有时3个点TLE,有时1个点TLE有时AC
2、加了cin优化每次AC
结论cin优化有必要的
*/
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);
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);
} else {
cin >> x;
for (int i = 1; i <= n; i++)
if (a[i].id == x) {
printf("%d\n", i);
break;
}
}
}
return 0;
}