結果

問題 No.100 直列あみだくじ
ユーザー ぴろずぴろず
提出日時 2014-12-11 23:38:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 764 bytes
コンパイル時間 2,152 ms
コンパイル使用メモリ 71,692 KB
実行使用メモリ 56,124 KB
最終ジャッジ日時 2023-08-15 17:35:52
合計ジャッジ時間 9,776 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,556 KB
testcase_01 AC 125 ms
56,124 KB
testcase_02 AC 120 ms
55,732 KB
testcase_03 AC 126 ms
55,768 KB
testcase_04 AC 129 ms
55,620 KB
testcase_05 AC 124 ms
55,576 KB
testcase_06 AC 124 ms
55,768 KB
testcase_07 AC 124 ms
55,876 KB
testcase_08 AC 125 ms
55,808 KB
testcase_09 AC 126 ms
55,604 KB
testcase_10 AC 126 ms
53,724 KB
testcase_11 AC 125 ms
55,992 KB
testcase_12 AC 125 ms
55,572 KB
testcase_13 AC 123 ms
55,800 KB
testcase_14 AC 125 ms
55,704 KB
testcase_15 AC 125 ms
55,276 KB
testcase_16 AC 124 ms
56,020 KB
testcase_17 AC 125 ms
55,640 KB
testcase_18 AC 126 ms
55,524 KB
testcase_19 AC 126 ms
55,888 KB
testcase_20 AC 126 ms
55,876 KB
testcase_21 AC 129 ms
53,980 KB
testcase_22 AC 125 ms
55,632 KB
testcase_23 AC 125 ms
55,276 KB
testcase_24 AC 124 ms
55,376 KB
testcase_25 AC 124 ms
55,680 KB
testcase_26 AC 126 ms
55,604 KB
testcase_27 AC 124 ms
55,788 KB
testcase_28 AC 125 ms
55,676 KB
testcase_29 AC 127 ms
55,684 KB
testcase_30 AC 131 ms
55,696 KB
testcase_31 AC 124 ms
55,664 KB
testcase_32 AC 131 ms
55,372 KB
testcase_33 AC 125 ms
55,864 KB
testcase_34 AC 124 ms
55,684 KB
testcase_35 AC 131 ms
55,552 KB
testcase_36 AC 132 ms
55,872 KB
testcase_37 AC 131 ms
55,476 KB
testcase_38 AC 132 ms
55,820 KB
testcase_39 AC 133 ms
55,608 KB
testcase_40 AC 135 ms
55,788 KB
testcase_41 AC 131 ms
55,352 KB
testcase_42 AC 132 ms
55,580 KB
testcase_43 AC 130 ms
55,276 KB
testcase_44 AC 130 ms
55,676 KB
testcase_45 AC 131 ms
55,732 KB
testcase_46 AC 131 ms
55,964 KB
testcase_47 AC 131 ms
55,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no100;

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();
		}
		boolean[] used = new boolean[n];
		int[] count = new int[51];
		for(int i=0;i<n;i++) {
			if (used[i]) {
				continue;
			}
			int length = 0;
			int now = i;
			while(true) {
				if (used[now]) {
					break;
				}
				used[now] = true;
				length++;
				now = a[now] - 1;
			}
			count[length]++;
		}
		for(int i=2;i<=50;i++) {
			if (i % 2 == 0) {
				if (count[i] % 2 == 1) {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}

}
0