Submission #890896
Source Code Expand
import java.util.*; import java.io.*; import java.awt.geom.*; import java.math.*; public class Main { static final Scanner in = new Scanner(System.in); static final PrintWriter out = new PrintWriter(System.out,false); static boolean debug = false; static void solve() { int n = in.nextInt(); int[] a = new int[n]; for (int i=0; i<n; i++) { a[i] = in.nextInt() - 1; } int cnt = 0; for (int i=0; i<n; i++) { if (a[a[i]] == i) { cnt++; } } out.println(cnt/2); } public static void main(String[] args) { debug = args.length > 0; long start = System.nanoTime(); solve(); out.flush(); long end = System.nanoTime(); dump((end - start) / 1000000 + " ms"); in.close(); out.close(); } static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); } }
Submission Info
Submission Time | |
---|---|
Task | B - Friendly Rabbits |
User | t8m8 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 200 |
Code Size | 865 Byte |
Status | AC |
Exec Time | 484 ms |
Memory | 32344 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 | 146 ms | 10320 KB |
0_01.txt | AC | 132 ms | 9680 KB |
0_02.txt | AC | 130 ms | 9808 KB |
1_00.txt | AC | 128 ms | 9800 KB |
1_01.txt | AC | 469 ms | 31972 KB |
1_02.txt | AC | 479 ms | 32344 KB |
1_03.txt | AC | 484 ms | 31932 KB |
1_04.txt | AC | 477 ms | 32260 KB |
1_05.txt | AC | 479 ms | 32236 KB |
1_06.txt | AC | 470 ms | 32324 KB |
1_07.txt | AC | 450 ms | 31844 KB |
1_08.txt | AC | 364 ms | 29568 KB |
1_09.txt | AC | 443 ms | 31696 KB |
1_10.txt | AC | 443 ms | 31600 KB |
1_11.txt | AC | 299 ms | 27448 KB |