RE???
查看原帖
RE???
346510
sparrowbot楼主2021/10/24 09:02
#include<bits/stdc++.h>
using namespace std;
int n,q;
struct node {
	int num,Id;
	bool operator < (const node x) const {
		return num<x.num;
	}
} A[8010],B[8010];
int read() {
	int num=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') num=num*10+ch-'0',ch=getchar();
	return num;
}
void work(){
	for (int i = 1; i <= n; i++)
	for (int j = i; j >= 2; j--)
		if (B[j].num < B[j-1].num) {
			swap(B[j],B[j-1]);
		}
}
int main() {
//	freopen("sort.in","r",stdin);
//	freopen("sort.out","w",stdout);
	n=read(),q=read();
	for(int i=1; i<=n; i++) A[i].num=read(),A[i].Id=i;
	int last_q=-1;
	while(q--) {
		int que=read();
		if(que==1) {
			A[read()].num=read();
		} else if(que==2) {
			if(last_q!=2){
				memcpy(B,A,sizeof(B));
				work();
			}
			int id=read();
			for(int i=1; i<=n; i++) {
				if(B[i].Id==id) {
					cout<<i<<endl;
					printf("%d\n",i);
					break;
				}
			}
		}
		last_q=que;
	}
}
/*
10 10
877332633 234569527 229171089 600324455 1458624 887548760 574229391 234569527 202374341 849045846
2 7
1 2 234569527
1 4 600324455
2 6
2 9
2 6
2 3
1 5 246345024
1 6 856960762
2 7

6
10
2
10
3
6

*/
2021/10/24 09:02
加载中...