Submission #1674974
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(); } int ans = 0; for(int i = 0 ; i < n ; i++) { if(i == a[a[i] - 1] - 1) { ans++; } } System.out.println(ans / 2); } }
Submission Info
Submission Time | |
---|---|
Task | B - Friendly Rabbits |
User | kouta1612 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 200 |
Code Size | 390 Byte |
Status | AC |
Exec Time | 451 ms |
Memory | 50924 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 | 115 ms | 19284 KB |
0_01.txt | AC | 98 ms | 21716 KB |
0_02.txt | AC | 96 ms | 21844 KB |
1_00.txt | AC | 97 ms | 17492 KB |
1_01.txt | AC | 441 ms | 50776 KB |
1_02.txt | AC | 421 ms | 47008 KB |
1_03.txt | AC | 451 ms | 50248 KB |
1_04.txt | AC | 418 ms | 47940 KB |
1_05.txt | AC | 409 ms | 47976 KB |
1_06.txt | AC | 423 ms | 45424 KB |
1_07.txt | AC | 417 ms | 50268 KB |
1_08.txt | AC | 322 ms | 43800 KB |
1_09.txt | AC | 428 ms | 49128 KB |
1_10.txt | AC | 380 ms | 50924 KB |
1_11.txt | AC | 228 ms | 37200 KB |