Submission #891785
Source Code Expand
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt() - 1; } int c = 0; for (int i = 0; i < n; i++) { if (a[a[i]] == i) { c++; } } System.out.println(c / 2); } }
Submission Info
Submission Time | |
---|---|
Task | B - Friendly Rabbits |
User | elzup |
Language | Java8 (OpenJDK 1.8.0) |
Score | 200 |
Code Size | 478 Byte |
Status | AC |
Exec Time | 480 ms |
Memory | 33300 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 | 139 ms | 10196 KB |
0_01.txt | AC | 125 ms | 9556 KB |
0_02.txt | AC | 145 ms | 9680 KB |
1_00.txt | AC | 127 ms | 9680 KB |
1_01.txt | AC | 448 ms | 33300 KB |
1_02.txt | AC | 466 ms | 31912 KB |
1_03.txt | AC | 473 ms | 31076 KB |
1_04.txt | AC | 476 ms | 31964 KB |
1_05.txt | AC | 471 ms | 31180 KB |
1_06.txt | AC | 480 ms | 32812 KB |
1_07.txt | AC | 473 ms | 31484 KB |
1_08.txt | AC | 346 ms | 29588 KB |
1_09.txt | AC | 434 ms | 31432 KB |
1_10.txt | AC | 423 ms | 31624 KB |
1_11.txt | AC | 296 ms | 26888 KB |