/ SB域 /

记录详情

Accepted

/usr/bin/ld.bfd: warning: /out/link.res contains output sections; did you forget -T?
# 状态 耗时 内存占用
#1 Accepted 1ms 256.0 KiB
#2 Accepted 1ms 256.0 KiB
#3 Accepted 1ms 256.0 KiB
#4 Accepted 1ms 256.0 KiB
#5 Accepted 3ms 256.0 KiB
#6 Accepted 8ms 256.0 KiB
#7 Accepted 14ms 484.0 KiB
#8 Accepted 9ms 512.0 KiB
#9 Accepted 16ms 476.0 KiB
#10 Accepted 13ms 600.0 KiB

代码

var n,i,j,s,cnt,sum,ans,next,b:longint;
    a:array[1..100000]of longint;
    u:array[1..100000]of boolean;
procedure swap(var a,c:longint);
var t:longint;
begin
t:=a; a:=c; c:=t;
end;

begin
 readln(n);
 for i:=1 to n do read(a[i]);
 for i:=1 to n do begin
  b:=i;
  while a[b]<>b do begin
   inc(cnt);
   swap(a[b],a[a[b]]);
   inc(ans);
  end;
 end;
 writeln(ans);
close(input);
close(output);
end.

信息

递交者
类型
递交
题目
【模板】排序的环
题目数据
下载
语言
Pascal
递交时间
2017-08-22 15:29:08
评测时间
2017-08-22 15:29:08
评测机
分数
100
总耗时
71ms
峰值内存
600.0 KiB