第十二届蓝桥杯省赛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

未完待续 ╯︿╰

相关推荐
Yhame.9 分钟前
【使用层次序列构建二叉树(数据结构C)】
c语言·开发语言·数据结构
OpenC++1 小时前
【C++QT】Buttons 按钮控件详解
c++·经验分享·qt·leetcode·microsoft
杜小暑2 小时前
动态内存管理
c语言·开发语言·动态内存管理
YuforiaCode2 小时前
第十二届蓝桥杯 2021 C/C++组 直线
c语言·c++·蓝桥杯
阿让啊2 小时前
C语言中操作字节的某一位
c语言·开发语言·数据结构·单片机·算法
拾忆-eleven3 小时前
C语言实战:用Pygame打造高难度水果消消乐游戏
c语言·python·pygame
草莓啵啵~3 小时前
搜索二叉树-key的搜索模型
数据结构·c++
共享家95273 小时前
深入理解C++ 中的list容器
c++
孞㐑¥3 小时前
C++11介绍
开发语言·c++·经验分享·笔记
云小逸3 小时前
【QQMusic项目界面开发复习笔记】第二章
c++·qt