'commit'
This commit is contained in:
43
TangDou/CSP-J/J2-2021/2_STL.cpp
Normal file
43
TangDou/CSP-J/J2-2021/2_STL.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
const int N = 8010;
|
||||
|
||||
struct Node {
|
||||
int id, value;
|
||||
bool operator<(const Node &t) const {
|
||||
if (value == t.value) return id < t.id;
|
||||
return value < t.value;
|
||||
}
|
||||
} a[N];
|
||||
|
||||
vector<Node> f;
|
||||
|
||||
int n, q;
|
||||
|
||||
int main() {
|
||||
freopen("sort.in","r",stdin);
|
||||
freopen("sort.out","w",stdout);
|
||||
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;
|
||||
f.insert(lower_bound(f.begin(), f.end(), a[i]), a[i]);
|
||||
}
|
||||
|
||||
int op, x, v;
|
||||
while (q--) {
|
||||
cin >> op;
|
||||
if (op == 1) {
|
||||
cin >> x >> v;
|
||||
f.erase(lower_bound(f.begin(), f.end(), a[x]));
|
||||
a[x].value = v;
|
||||
f.insert(lower_bound(f.begin(), f.end(), a[x]), a[x]);
|
||||
} else {
|
||||
cin >> x;
|
||||
printf("%d\n", lower_bound(f.begin(), f.end(), a[x]) - f.begin() + 1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user