0
已解决
有多少人做出来了
我开O2过了,不过**场上这题淦了2.5小时,总分190,多半是废了
我的代码
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<stack>
#include<vector>
#include<map>
#include<iostream>
#include<cstring>
#pragma GCC optimize(2)
#define N 1000000
using namespace std;
struct kx{
int yid,w;
}a[100001];
int c[100001];
int n,q;
int main()
{
cin>>n>>q;
for(int i=1;i<=n;i++){
cin>>a[i].w;
a[i].yid=i;
}
for (int i = 1; i <= n; i++)
for (int j = i; j >= 2; j--)
if (a[j].w < a[j-1].w) {
kx t = a[j-1];
a[j-1] = a[j];
a[j] = t;
}
for(int i=1;i<=n;i++){
c[a[i].yid]=i;
}
for(int i=1;i<=q;i++){
int x;
cin>>x;
if(x==1){
int u,v;
cin>>u>>v;
int l;
for(int j=1;j<=n;j++){
if(a[j].yid==u) {
l=j;
a[j].w=v;
break;
}
}
for (int j = l; j >= 2; j--)
if (a[j].w < a[j-1].w) {
kx t = a[j-1];
a[j-1] = a[j];
a[j] = t;
}
else if(a[j].w==a[j-1].w){
if(a[j].yid<a[j-1].yid){
kx t = a[j-1];
a[j-1] = a[j];
a[j] = t;
}
}
for (int j = l; j < n; j++)
if (a[j].w > a[j+1].w) {
kx t = a[j+1];
a[j+1] = a[j];
a[j] = t;
}
else if(a[j].w==a[j+1].w){
if(a[j].yid>a[j+1].yid){
kx t = a[j+1];
a[j+1] = a[j];
a[j] = t;
}
}
for(int j=1;j<=n;j++){
c[a[j].yid]=j;
}
}else{
int y;
cin>>y;
cout<<c[y]<<endl;
}
}
return 0;
}