样例过,但是16(玄关)
查看原帖
样例过,但是16(玄关)
799373
David_Ty楼主2024/9/17 18:07
#include <bits/stdc++.h>
using namespace std;

struct node{
	int value,id;
	bool flag=false;
};

const int N=8e3+9;
int n,q;
node a[N],b[N];

bool cmp(node a,node b){
	return a.value<b.value;
}

int main(){
	cin >>n>>q;
	for(int i=1;i<=n;i++){
		cin >>a[i].value;
	}
	for(int i=1;i<=q;i++){
		int opt;
		cin >>opt;
		if(opt==1){
			int x,v;
			cin >>x>>v;
			a[x].value=v;
		}
		if(opt==2){
			int x;
			cin >>x;
			for(int j=1;j<=n;j++){
				b[j].value=a[j].value;
				b[j].id=j;
				b[j].flag=false;
				if(j==x) b[j].flag=true;
			}
			sort(b+1,b+n+1,cmp);
			for(int j=1;j<=n;j++){
				if(b[j].flag==true) {
					cout <<j<<endl;
					//cout <<"b[j].value="<<b[j].value<<endl;
					//cout <<endl;
				}
			}
			
		}
	}
	return 0;
}
2024/9/17 18:07
加载中...