Submission #891293
Source Code Expand
import java.util.Scanner; public class Main { void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; int[] b = new int[n]; for (int i = 0; i < n; i++) { int k = sc.nextInt() - 1; a[i] = k; b[k] = i; } int cnt = 0; for (int i = 0; i < n; i++) { int k = a[i]; if (a[k] == i) { cnt++; } } System.out.println(cnt/2); } public static void main(String[] args) { new Main().run(); } }
Submission Info
Submission Time | |
---|---|
Task | B - Friendly Rabbits |
User | fujisu |
Language | Java7 (OpenJDK 1.7.0) |
Score | 200 |
Code Size | 496 Byte |
Status | AC |
Exec Time | 474 ms |
Memory | 32552 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 | 131 ms | 9040 KB |
0_01.txt | AC | 127 ms | 9044 KB |
0_02.txt | AC | 125 ms | 8916 KB |
1_00.txt | AC | 126 ms | 9040 KB |
1_01.txt | AC | 474 ms | 32004 KB |
1_02.txt | AC | 461 ms | 32340 KB |
1_03.txt | AC | 455 ms | 32396 KB |
1_04.txt | AC | 459 ms | 32524 KB |
1_05.txt | AC | 457 ms | 32244 KB |
1_06.txt | AC | 461 ms | 32248 KB |
1_07.txt | AC | 463 ms | 32552 KB |
1_08.txt | AC | 419 ms | 29736 KB |
1_09.txt | AC | 431 ms | 31056 KB |
1_10.txt | AC | 440 ms | 30140 KB |
1_11.txt | AC | 388 ms | 25832 KB |