CODE FESTIVAL 2016 qual A

Submission #1752791

Source codeソースコード

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

Task問題 B - 仲良しうさぎ / Friendly Rabbits
User nameユーザ名 橋本尚儒
Created time投稿日時
Language言語 Java8 (OpenJDK 1.8.0)
Status状態 AC
Score得点 200
Source lengthソースコード長 566 Byte
File nameファイル名
Exec time実行時間 420 ms
Memory usageメモリ使用量 50660 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - 0_00.txt,0_01.txt,0_02.txt
All 200 / 200 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
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