Submission #893463


Source Code Expand

Copy
n = gets.to_i
rabbits = gets.split(/\s/).collect{|x| x.to_i}
count = 0
(1..n).each do |i|
  x = rabbits[i-1]
  count += 1 if x > i and rabbits[x-1] == i
end
puts count

Submission Info

Submission Time
Task B - 仲良しうさぎ / Friendly Rabbits
User rmtsukuru
Language Ruby (2.3.3)
Score 200
Code Size 174 Byte
Status
Exec Time 84 ms
Memory 8068 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_00.txt, 0_01.txt, 0_02.txt
All 200 / 200 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt
Case Name Status Exec Time Memory
0_00.txt 11 ms 1788 KB
0_01.txt 11 ms 1788 KB
0_02.txt 10 ms 1788 KB
1_00.txt 10 ms 1788 KB
1_01.txt 82 ms 8068 KB
1_02.txt 82 ms 8068 KB
1_03.txt 82 ms 8068 KB
1_04.txt 82 ms 8068 KB
1_05.txt 82 ms 8068 KB
1_06.txt 82 ms 8068 KB
1_07.txt 84 ms 8068 KB
1_08.txt 37 ms 3964 KB
1_09.txt 69 ms 7044 KB
1_10.txt 61 ms 6276 KB
1_11.txt 23 ms 2684 KB