当前位置:网站首页>Template_ Quick sort_ Double pointer
Template_ Quick sort_ Double pointer
2022-07-06 02:21:00 【This question AC sleep again】
//
#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]; // Left Da Fu right Kong
while( in[j]>=tt && i<j ) j--;
in[i]=in[j]; // Right small Fu left empty
}
in[i]=tt; // place
fastpow( x,i-1 );
fastpow( i+1,y ); // Divide and conquer
}
}
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;
}边栏推荐
- ftp上传文件时出现 550 Permission denied,不是用户权限问题
- SSM 程序集
- Leetcode3, implémenter strstr ()
- 【coppeliasim】高效传送带
- 更换gcc版本后,编译出现make[1]: cc: Command not found
- [solution] every time idea starts, it will build project
- 【社区人物志】专访马龙伟:轮子不好用,那就自己造!
- Campus second-hand transaction based on wechat applet
- 剑指 Offer 30. 包含min函数的栈
- HDU_p1237_简单计算器_stack
猜你喜欢
随机推荐
Know MySQL database
[robot library] awesome robots Libraries
Spark accumulator
500 lines of code to understand the principle of mecached cache client driver
Extracting key information from TrueType font files
2022 PMP project management examination agile knowledge points (8)
Prepare for the autumn face-to-face test questions
高数_向量代数_单位向量_向量与坐标轴的夹角
How to improve the level of pinduoduo store? Dianyingtong came to tell you
729. My schedule I / offer II 106 Bipartite graph
Ue4- how to make a simple TPS role (II) - realize the basic movement of the role
How does redis implement multiple zones?
SQL statement
Multi function event recorder of the 5th National Games of the Blue Bridge Cup
Redis list
Bigder:34/100 面试感觉挺好的,没有收到录取
一位博士在华为的22年
Leetcode3, implémenter strstr ()
[solution] add multiple directories in different parts of the same word document
HDU_p1237_简单计算器_stack








