蒟蒻40分代码帮忙看一看,信息小白求助

P2434 [SDOI2005] 区间

不好意思,格式炸了 ```pascal uses math; var a,b,k,g:array[1..100001]of int64; n,bl,al:int64; i,j:longint; procedure qsort(l,r:longint); var s,t,i,j:longint; begin if l>=r then exit; s:=l; t:=r; for i:=l to r do if a[i]>a[l] then begin k[t]:=a[i]; g[t]:=b[i]; dec(t); end else if a[l]>a[i] then begin k[s]:=a[i]; g[s]:=b[i]; inc(s); end; k[s]:=a[l]; g[s]:=b[l]; a:=k; b:=g; qsort(l,s-1); qsort(s+1,r); end; begin read(n); for i:=1 to n do read(a[i],b[i]); qsort(1,n); // for i:=1 to n do writeln(a[i],' ',b[i]); //writeln; al:=a[1]; bl:=b[1]; for i:=2 to n do if a[i]>bl then begin write(al,' ',bl); writeln; al:=a[i]; bl:=b[i]; end else bl:=max(bl,b[i]); write(al,' ',bl); end. ```
by vacation @ 2018-07-17 19:39:02


```pascal uses math; var a,b,k,g:array[1..100001]of int64; n,bl,al:int64; i,j:longint; procedure qsort(l,r:longint); var s,t,i,j:longint; begin if l>=r then exit; s:=l; t:=r; for i:=l to r do if a[i]>a[l] then begin k[t]:=a[i]; g[t]:=b[i]; dec(t); end else if a[l]>a[i] then begin k[s]:=a[i]; g[s]:=b[i]; inc(s); end; k[s]:=a[l]; g[s]:=b[l]; a:=k; b:=g; qsort(l,s-1); qsort(s+1,r); end; begin read(n); for i:=1 to n do read(a[i],b[i]); qsort(1,n); // for i:=1 to n do writeln(a[i],' ',b[i]); //writeln; al:=a[1]; bl:=b[1]; for i:=2 to n do if a[i]>bl then begin write(al,' ',bl); writeln; al:=a[i]; bl:=b[i]; end else bl:=max(bl,b[i]); write(al,' ',bl); end. ``` ~~好歹标明Pascal语言啊(逃)~~
by 勇敢的我 @ 2018-07-17 19:47:31


尴尬——为啥洛谷的Markdown Pascal语言没有高亮?
by 勇敢的我 @ 2018-07-17 19:48:38


现已懂AC 附上代码 ```pascal // luogu-judger-enable-o2 uses math; var a,b,k,g:array[1..100001]of int64; n,bl,al:int64; i,j:longint; procedure qsort(l,r: qword); var i,j,x,y:qword; begin i:=l; j:=r; x:=a[(l+r)div 2]; repeat while a[i]<x do inc(i); while x<a[j] do dec(j); if not(i>j) then begin y:=a[i]; a[i]:=a[j]; a[j]:=y; y:=b[i]; b[i]:=b[j]; b[j]:=y; inc(i); j:=j-1; end; until i>j; if l<j then qsort(l,j); if i<r then qsort(i,r); end; begin read(n); for i:=1 to n do read(a[i],b[i]); qsort(1,n); // for i:=1 to n do writeln(a[i],' ',b[i]); //writeln; al:=a[1]; bl:=b[1]; for i:=2 to n do if a[i]>bl then begin write(al,' ',bl); writeln; al:=a[i]; bl:=b[i]; end else bl:=max(bl,b[i]); write(al,' ',bl); end. ```
by vacation @ 2018-07-17 20:05:15


|