【NOIP2016提高A组模拟9.14】排序
2016-09-22 16:45
323 查看
//我就是来水点积分的
很任性~
tj
不想说~~~很任性~
贴代码
var a,b:array[0..100005]of longint; i,j,k,l,n:longint; procedure qsort(l,r:longint); var i,j,mid:longint; begin i:=l; j:=r; mid:=a[(i+j) div 2]; repeat while a[i]<mid do inc(i); while a[j]>mid do dec(j); if i<=j then begin a[0]:=a[i]; a[i]:=a[j]; a[j]:=a[0]; inc(i); dec(j); end; until i>j; if i<r then qsort(i,r); if l<j then qsort(l,j); end; begin readln(n); for i:=1 to n do read(a[i]); readln; b:=a; qsort(1,n); k:=0; for i:=1 to n do if a[i]<>b[i] then inc(k); if k>2 then writeln('NO') else writeln('YES'); end.
相关文章推荐
- JZOJsenior4777.【NOIP2016提高A组模拟9.14】灌水
- 数列编辑器 【NOIP2016提高A组模拟9.14】
- 【NOIP2016提高A组模拟9.14】灌水
- JZOJ 4777. 【NOIP2016提高A组模拟9.14】灌水
- 【NOIP2016提高A组模拟9.14】数列编辑器
- JZOJ 4778. 【NOIP2016提高A组模拟9.14】数列编辑器
- 【NOIP2016提高A组模拟9.14】数列编辑器
- JZOJ.4778. 【NOIP2016提高A组模拟9.14】数列编辑器
- {题解}[jzoj4778]【NOIP2016提高A组模拟9.14】数列编辑器
- 【NOIP2016提高A组模拟9.9】闭门造车
- 【NOIP2016提高A组模拟9.15】Osu
- 【NOIP2016提高A组模拟9.15】Map
- JZOJ.4701【NOIP2016提高A组模拟8.15】Throw
- 【NOIP2016提高A组模拟9.21】整除
- JZOJ 4786. 【NOIP2016提高A组模拟9.17】小a的强迫症
- 就是乘法【NOIP2016提高A组模拟9.24】
- 【NOIP2016提高A组模拟8.17】Matrix
- 【JZOJ4803】【NOIP2016提高A组模拟9.28】求导
- 【JZOJ4744】【NOIP2016提高A组模拟9.2】同余
- 【NOIP2016提高A组模拟10.15】打膈膜