本来想敲个TLE36走人,但是WA 0pts
查看原帖
本来想敲个TLE36走人,但是WA 0pts
1347790
zjck2楼主2024/8/9 16:12
#include<bits/stdc++.h>
using namespace std;
int a[8005],b[8005];
int do_2(long long x,long long n){
	for (int i = 1; i <= n; i++){
		for (int j = i; j >= 2; j--){
			if (a[j] < a[j-1]) {
				swap(a[j],a[j-1]);
				if(j==x) x=j-1;
				else if(x==j-1) x=j;
			}
		}	
	}
	return x;	
}
int main(){
	long long n,q,d,x,v;
	scanf("%ld %ld",&n,&q);
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	while(q--){
		scanf("%ld",&d);
		if(d==1){
			scanf("%ld %ld",&x,&v);
			a[x]=v;
		}
		else{
			scanf("%ld",&x);
			for(int i=1;i<=n;i++){
				b[i]=a[i];
			}
			cout<<do_2(x,n)<<endl;
			//stable_sort(b+1,b+n+1);
		}
	}
	/*
	for (int i = 1; i <= n; i++)
		for (int j = i; j >= 2; j--)
			if (a[j] < a[j-1]) {
				int t = a[j-1];
				a[j-1] = a[j];
				a[j] = t;
			}
	*/
	return 0;
}
2024/8/9 16:12
加载中...