又wa又T,那位大佬能指点迷津qwq
查看原帖
又wa又T,那位大佬能指点迷津qwq
478080
ysydreamer楼主2021/10/25 13:27
#include <bits/stdc++.h>
using namespace std;

long long n,q,x[4],num=0;
string str;
struct node {
	long long yl,ns;
}a[8005];
bool cmp(node i,node j){return i.ns<j.ns;
} 
bool cc(node i,node j){return i.yl<j.yl;
}
int main()
{
//	freopen("sort.in","r",stdin);
//	freopen("sort.out","w",stdout);
	cin >> n >> q;
	for(int i=0;i<n;i++)
	{
		cin >> a[i].ns;a[i].yl=i+1;
	}	sort(a,a+n,cmp); 
	for(int i=0;i<q;i++)
	{
		//to get
		num=0;
		x[0]=x[1]=x[2]=x[3]=0;
		getline(cin,str);
		if(str[0]==0)
		{
			i--;
			continue;
		}
		for(int j=0;j<str.length();j++)
		{
			if(!(str[j]>='0'&&str[j]<='9'))
				num++;
			else
				x[num]=x[num]*10+str[j]-'0';
		}

		
		if(x[0]==1)
		{
			sort(a,a+n,cc);
			a[x[1]-1].ns=x[2];
			sort(a,a+n,cmp);
		}
		else
		{
			
			for(int j=0;j<n;j++)
			{
				if(a[j].yl==x[1]) cout << j+1 << endl;
			}
			
		}
	}
}
2021/10/25 13:27
加载中...