Submission #895091
Source Code Expand
import java.util.Scanner;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
ArrayList<Integer> list = new ArrayList<Integer>();
for(int i = 0; i < N; i++) {
list.add(sc.nextInt());
}
int count = 0;
for(int i=0; i<list.size(); i++) {
int love = list.get(i);
if((i + 1) == (list.get(love - 1))) count++;
}
System.out.println(count/2);
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Friendly Rabbits |
| User | rinkou |
| Language | Java8 (OpenJDK 1.8.0) |
| Score | 200 |
| Code Size | 490 Byte |
| Status | AC |
| Exec Time | 513 ms |
| Memory | 48280 KiB |
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 | 129 ms | 9544 KiB |
| 0_01.txt | AC | 128 ms | 9556 KiB |
| 0_02.txt | AC | 138 ms | 9676 KiB |
| 1_00.txt | AC | 125 ms | 9808 KiB |
| 1_01.txt | AC | 513 ms | 33680 KiB |
| 1_02.txt | AC | 503 ms | 48280 KiB |
| 1_03.txt | AC | 496 ms | 33696 KiB |
| 1_04.txt | AC | 499 ms | 34016 KiB |
| 1_05.txt | AC | 506 ms | 33464 KiB |
| 1_06.txt | AC | 495 ms | 34672 KiB |
| 1_07.txt | AC | 498 ms | 33732 KiB |
| 1_08.txt | AC | 369 ms | 29236 KiB |
| 1_09.txt | AC | 483 ms | 33500 KiB |
| 1_10.txt | AC | 447 ms | 32316 KiB |
| 1_11.txt | AC | 325 ms | 27036 KiB |