zoukankan      html  css  js  c++  java
  • 莫队模板

    function check(x1,y1,x2,y2:longint):boolean;
    begin
      if (trunc(x1/sqrt(n))>trunc(y1/sqrt(n)))or(trunc(x1/sqrt(n))=trunc(y1/sqrt(n)))and(x2>y2) then
      exit(true)
      else
      exit(false);
    end;
    procedure sort(ll,rr:longint);
    var i,j,x,y,z:longint;
    begin
      i:=ll;
      j:=rr;
      x:=l[(ll+rr) div 2];
      z:=r[(ll+rr) div 2];
      repeat
      while check(l[i],x,r[i],z) do
      inc(i);
      while check(x,l[j],z,r[j]) do
      dec(j);
      if not(i>j) then
      begin
        y:=l[i];
        l[i]:=l[j];
        l[j]:=y;
        y:=r[i];
        r[i]:=r[j];
        r[j]:=y;
        y:=num[i];
        num[i]:=num[j];
        num[j]:=y;
        inc(i);
        dec(j);
      end;
      until i>j;
      if ll<j then
      sort(ll,j);
      if i<rr then
      sort(i,rr);
    end;
  • 相关阅读:
    堆排序算法
    基数排序
    快速排序
    OpenSSL加密证书
    jobs后台任务
    at,crontab例行性任务
    dns
    ftp
    ssh
    iptables
  • 原文地址:https://www.cnblogs.com/qbwhtc/p/8413331.html
Copyright © 2011-2022 走看看