/ 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 7ms 256.0 KiB
#7 Accepted 9ms 384.0 KiB
#8 Accepted 14ms 416.0 KiB
#9 Accepted 9ms 480.0 KiB
#10 Accepted 17ms 632.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 14:27:08
评测时间
2017-08-22 14:27:08
评测机
分数
100
总耗时
68ms
峰值内存
632.0 KiB