Submission #2196330
Source Code Expand
using System; public class Hello { public static void Main() { var n = int.Parse(Console.ReadLine().Trim()); string[] line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, int.Parse); Console.WriteLine(getFriend(a)); } public static int getFriend(int[] a) { var n = a.Length; var chk = new bool[n]; var ret = 0; for (int i = 0; i < n; i++) { if (chk[i]) continue; var w = a[i] - 1; var w2 = a[w] - 1; if (w2 == i) { chk[w] = true; ret++; } } return ret; } }
Submission Info
Submission Time | |
---|---|
Task | B - Friendly Rabbits |
User | bluemegane |
Language | C# (Mono 4.6.2.0) |
Score | 200 |
Code Size | 665 Byte |
Status | AC |
Exec Time | 53 ms |
Memory | 18912 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
All | 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 | AC | 20 ms | 9044 KB |
0_01.txt | AC | 21 ms | 11092 KB |
0_02.txt | AC | 21 ms | 11092 KB |
1_00.txt | AC | 21 ms | 11092 KB |
1_01.txt | AC | 53 ms | 16992 KB |
1_02.txt | AC | 53 ms | 14944 KB |
1_03.txt | AC | 53 ms | 16992 KB |
1_04.txt | AC | 53 ms | 16992 KB |
1_05.txt | AC | 52 ms | 14944 KB |
1_06.txt | AC | 53 ms | 18912 KB |
1_07.txt | AC | 52 ms | 14944 KB |
1_08.txt | AC | 33 ms | 13024 KB |
1_09.txt | AC | 47 ms | 14176 KB |
1_10.txt | AC | 43 ms | 13664 KB |
1_11.txt | AC | 26 ms | 9696 KB |