当前位置:网站首页>模板_快速排序_双指针
模板_快速排序_双指针
2022-07-06 02:06:00 【这题AC再睡.】
//
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+6;
int in[N];
void fastpow( int x,int y )
{
if( x<y )
{
int i=x,j=y,tt=in[y];
while( i<j )
{
while( in[i]<=tt && i<j ) i++;
in[j]=in[i]; // 左大赋右空
while( in[j]>=tt && i<j ) j--;
in[i]=in[j]; // 右小赋左空
}
in[i]=tt; // 归位
fastpow( x,i-1 );
fastpow( i+1,y ); // 分治
}
}
int main()
{
int n,i;
while( cin>>n )
{
for( i=0;i<n;i++ ) cin>>in[i];
fastpow( 0,n-1 );
for( i=0;i<n;i++ )
{
if( i ) cout<<" ";
cout<<in[i];
}
cout<<endl;
}
return 0;
}
边栏推荐
- 机器学习训练与参数优化的一般过程 (讨论)
- 2022年版图解网络PDF
- [solution] add multiple directories in different parts of the same word document
- Ali test open-ended questions
- 1. Introduction to basic functions of power query
- [coppeliasim] 6-DOF path planning
- Computer graduation design PHP enterprise staff training management system
- How to use C to copy files on UNIX- How can I copy a file on Unix using C?
- Shutter doctor: Xcode installation is incomplete
- Bidding promotion process
猜你喜欢
PHP campus movie website system for computer graduation design
vs code保存时 出现两次格式化
Minecraft 1.18.1, 1.18.2 module development 22 Sniper rifle
MySQL index
Know MySQL database
Extracting key information from TrueType font files
安装php-zbarcode扩展时报错,不知道有没有哪位大神帮我解决一下呀 php 环境用的7.3
Minecraft 1.16.5 生化8 模组 2.0版本 故事书+更多枪械
2 power view
Minecraft 1.16.5 biochemical 8 module version 2.0 storybook + more guns
随机推荐
Pangolin Library: subgraph
Using SA token to solve websocket handshake authentication
Adapter-a technology of adaptive pre training continuous learning
Ali test open-ended questions
Lecture 4 of Data Engineering Series: sample engineering of data centric AI
Selenium element positioning (2)
2022年PMP项目管理考试敏捷知识点(8)
Shutter doctor: Xcode installation is incomplete
NumPy 数组索引 切片
[depth first search notes] Abstract DFS
Executing two identical SQL statements in the same sqlsession will result in different total numbers
Know MySQL database
selenium 等待方式
Campus second-hand transaction based on wechat applet
SPI communication protocol
论文笔记: 图神经网络 GAT
Redis key operation
Get the relevant information of ID card through PHP, get the zodiac, get the constellation, get the age, and get the gender
[robot hand eye calibration] eye in hand
【机器人手眼标定】eye in hand