Submission #1752791
Source Code Expand
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] r = new int[n]; boolean[] p = new boolean[n]; for(int i= 0; i < n; i++) { r[i] = in.nextInt() - 1; } int ans = 0; for(int i = 0; i < n; i++) { if(!p[i] && i == r[r[i]]) { p[i] = p[r[i]] = true; ans++; } } System.out.println(ans); } }
Submission Info
Submission Time | |
---|---|
Task | B - Friendly Rabbits |
User | unirita155 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 200 |
Code Size | 566 Byte |
Status | AC |
Exec Time | 420 ms |
Memory | 50660 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 | 93 ms | 21460 KB |
0_01.txt | AC | 95 ms | 20560 KB |
0_02.txt | AC | 94 ms | 21716 KB |
1_00.txt | AC | 92 ms | 21844 KB |
1_01.txt | AC | 419 ms | 50660 KB |
1_02.txt | AC | 412 ms | 50076 KB |
1_03.txt | AC | 420 ms | 48380 KB |
1_04.txt | AC | 411 ms | 47616 KB |
1_05.txt | AC | 412 ms | 46404 KB |
1_06.txt | AC | 414 ms | 46476 KB |
1_07.txt | AC | 398 ms | 49228 KB |
1_08.txt | AC | 279 ms | 41708 KB |
1_09.txt | AC | 393 ms | 49900 KB |
1_10.txt | AC | 360 ms | 46360 KB |
1_11.txt | AC | 218 ms | 36600 KB |