提出 #894563
ソースコード 拡げる
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int total = sc.nextInt();
int count = 0;
Rabbit[] rab = new Rabbit[100000];
int j = 1;
for (int i = 0; i < total; i++) {
rab[i] = new Rabbit(sc.nextInt(), j);
j++;
}
for (int i = 0; i < total; i++) {
int tempIdx = rab[i].number;
int tempNum = rab[i].index;
if (rab[i].number == rab[tempIdx-1].index && rab[i].index == rab[tempIdx-1].number && rab[i].index < rab[tempIdx-1].index)
count++;
}
System.out.println(count);
}
}
class Rabbit {
int number;
int index;
public Rabbit(int num, int idx) {
this.number = num;
this.index = idx;
}
public int getNumber() {
return number;
}
public int getIndex() {
return index;
}
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | B - 仲良しうさぎ |
| ユーザ | tanwei0319 |
| 言語 | Java7 (OpenJDK 1.7.0) |
| 得点 | 200 |
| コード長 | 847 Byte |
| 結果 | AC |
| 実行時間 | 495 ms |
| メモリ | 49800 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 200 / 200 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| 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 |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 0_00.txt | AC | 135 ms | 9556 KiB |
| 0_01.txt | AC | 128 ms | 9428 KiB |
| 0_02.txt | AC | 127 ms | 9428 KiB |
| 1_00.txt | AC | 128 ms | 9428 KiB |
| 1_01.txt | AC | 472 ms | 35884 KiB |
| 1_02.txt | AC | 484 ms | 35596 KiB |
| 1_03.txt | AC | 480 ms | 35496 KiB |
| 1_04.txt | AC | 492 ms | 49648 KiB |
| 1_05.txt | AC | 476 ms | 35780 KiB |
| 1_06.txt | AC | 493 ms | 49800 KiB |
| 1_07.txt | AC | 495 ms | 49568 KiB |
| 1_08.txt | AC | 419 ms | 30468 KiB |
| 1_09.txt | AC | 447 ms | 32984 KiB |
| 1_10.txt | AC | 448 ms | 33128 KiB |
| 1_11.txt | AC | 388 ms | 26812 KiB |