第十二届蓝桥杯省赛C&C++ 研究生组-双向排序


solution1(通过60%)

cpp 复制代码
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 100010;
int a[maxn];

bool cmp(int a, int b){
	return a > b;
}

int main(){
	int n, m, p, q;
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++){
		a[i] = i;
	}
	while(m--){
		scanf("%d%d", &p, &q);
		if(p) sort(a + q, a + n + 1);
		else sort(a + 1, a + q + 1, cmp);
	}
	for(int i = 1; i <= n; i++){
		printf("%d ", a[i]);		
	}
	return 0;
}

solution2

未完待续 ╯︿╰

相关推荐
apocelipes10 分钟前
记一次ADL导致的C++代码编译错误
c++·开发工具和环境
Code Warrior1 小时前
【每日算法】专题五_位运算
开发语言·c++
OneQ6666 小时前
C++讲解---创建日期类
开发语言·c++·算法
码农不惑6 小时前
2025.06.27-14.44 C语言开发:Onvif(二)
c语言·开发语言
Coding小公仔8 小时前
C++ bitset 模板类
开发语言·c++
凌肖战8 小时前
力扣网C语言编程题:在数组中查找目标值位置之二分查找法
c语言·算法·leetcode
菜鸟看点8 小时前
自定义Cereal XML输出容器节点
c++·qt
BreezeJuvenile8 小时前
数据结构与算法分析课设:一元多项式求值
c语言·课程设计·数据结构与算法分析·一元多项式计算
悲伤小伞10 小时前
linux_git的使用
linux·c语言·c++·git
ysa05103010 小时前
数论基础知识和模板
数据结构·c++·笔记·算法