Submission #893423


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 A - CODEFESTIVAL 2016
User rmtsukuru
Language Ruby (2.3.3)
Score 0
Code Size 174 Byte
Status

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_00.txt, 0_01.txt, 0_02.txt
All 0 / 100 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt
Case Name Status Exec Time Memory
0_00.txt
0_01.txt
0_02.txt
1_00.txt
1_01.txt
1_02.txt