白皮书393页面。
乱搞了原始数组中。其实用另一种阵列块记录。
你不能改变原始数组。
请注意,与原来的阵列和阵列块的良好关系,稍微细心处理边境。这是不难。
#include#include #include #include #define maxn 300005#define SIZE 600using namespace std;int a[maxn];int block[maxn];int b[maxn];void work(int p,int x){ int old=b[p]; b[p]=x; int BLOCK=p/SIZE; int pos=p; for(int i=BLOCK*SIZE;i =0 && block[pos-1]==block[p] && a[pos-1]>a[pos]) { swap(a[pos-1],a[pos]); pos--; }}int main(){ int n,m,u; while(scanf("%d%d%d",&n,&m,&u)!=EOF) { memset(a,0x3f,sizeof a); memset(block,0x3f,sizeof block); for(int i=0;i
版权声明:本文博客原创文章,博客,未经同意,不得转载。