Submission #898771
Source Code Expand
import java.io.IOException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
Scanner scanner = new Scanner(System.in);
int num = scanner.nextInt();
int[] array = new int[num];
int count = 0;
for (int i = 1; i < num + 1; i++) {
if (scanner.hasNextInt()) {
int a = scanner.nextInt();
array[i - 1] = a;
if (i > a) {
if (array[a - 1] == i) count++;
}
}
}
scanner.close();
System.out.println(count);
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Friendly Rabbits |
| User | notxyz |
| Language | Java7 (OpenJDK 1.7.0) |
| Score | 200 |
| Code Size | 524 Byte |
| Status | AC |
| Exec Time | 483 ms |
| Memory | 31748 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 | 125 ms | 8916 KiB |
| 0_01.txt | AC | 126 ms | 9044 KiB |
| 0_02.txt | AC | 126 ms | 8916 KiB |
| 1_00.txt | AC | 125 ms | 9044 KiB |
| 1_01.txt | AC | 466 ms | 31316 KiB |
| 1_02.txt | AC | 483 ms | 31584 KiB |
| 1_03.txt | AC | 472 ms | 31364 KiB |
| 1_04.txt | AC | 471 ms | 31748 KiB |
| 1_05.txt | AC | 452 ms | 31436 KiB |
| 1_06.txt | AC | 479 ms | 31180 KiB |
| 1_07.txt | AC | 473 ms | 31552 KiB |
| 1_08.txt | AC | 428 ms | 29800 KiB |
| 1_09.txt | AC | 452 ms | 31336 KiB |
| 1_10.txt | AC | 451 ms | 30708 KiB |
| 1_11.txt | AC | 386 ms | 27284 KiB |