提交时间:2021-12-13 13:41:30
运行 ID: 35111
#include <bits/stdc++.h> using namespace std; pair<int,int>b[8005]; int n,q,a[8005]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin>>n>>q; for (int i=1; i<=n; ++i) { cin>>a[i]; b[i]= {a[i],i}; } stable_sort(b+1,b+n+1); for (int i=1,o,x,v; i<=q; ++i) { cin>>o; if (o==1) { cin>>x>>v; a[x]=lower_bound(b+1,b+n+1,make_pair(a[x],x))->first=v; stable_sort(b+1,b+n+1); } else { cin>>x; cout<<lower_bound(b+1,b+n+1,make_pair(a[x],x))-&b[0]<<'\n'; } } return 0; }