24WA求助
查看原帖
24WA求助
723171
fqEason楼主2023/1/5 21:39

RT,评测记录

#include<bits/stdc++.h>
using namespace std;
int n,m;
struct node{
	int x,y,z;
}a[100001];
int l;
bool cmp(int a, int b) {
	return a>b;
}
vector<int>v;
int now=0;
int main(){
	cin >> n >> m;
	for (int i=1;i<=n;i++) {
		v.push_back(i);
	}
	for (int i=1;i<=m;i++) {
		int opt;
		cin >> opt;
		a[i].x=opt;
		if (opt==3) {
			int u,v;
			cin >> u >> v;
			a[i].y=u;
			a[i].z=v;
		}
		if (opt==1||opt==2) l=i;
	}
	for (int i=l;i<=m;i++) {
		if (a[i].x==2) sort(v.begin(),v.end(),cmp);
		else if (a[i].x==3) {
			if (now) swap(v[n-a[i].y],v[n-a[i].z]);
			else swap(v[a[i].y-1],v[a[i].z-1]);
		}
		else if (a[i].x==4) now=1-now;
		else sort(v.begin(),v.end());
	}
	if (now) reverse(v.begin(),v.end());
	for (auto i:v) cout << i << ' ';
    return 0;
}
2023/1/5 21:39
加载中...