結果

問題 No.2267 群の公理
ユーザー ks2mks2m
提出日時 2023-04-14 21:45:43
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,291 bytes
コンパイル時間 3,044 ms
コンパイル使用メモリ 77,260 KB
実行使用メモリ 54,056 KB
最終ジャッジ日時 2024-04-18 19:06:59
合計ジャッジ時間 12,066 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
41,736 KB
testcase_01 AC 128 ms
41,660 KB
testcase_02 AC 127 ms
41,704 KB
testcase_03 AC 127 ms
41,384 KB
testcase_04 AC 129 ms
41,532 KB
testcase_05 AC 128 ms
41,304 KB
testcase_06 AC 131 ms
41,316 KB
testcase_07 AC 127 ms
41,152 KB
testcase_08 AC 130 ms
41,320 KB
testcase_09 AC 127 ms
41,548 KB
testcase_10 AC 130 ms
42,028 KB
testcase_11 AC 129 ms
41,392 KB
testcase_12 AC 127 ms
41,100 KB
testcase_13 AC 129 ms
41,472 KB
testcase_14 AC 128 ms
41,364 KB
testcase_15 AC 131 ms
41,448 KB
testcase_16 AC 126 ms
41,640 KB
testcase_17 WA -
testcase_18 AC 131 ms
41,620 KB
testcase_19 AC 117 ms
41,624 KB
testcase_20 AC 132 ms
41,492 KB
testcase_21 AC 130 ms
41,404 KB
testcase_22 AC 130 ms
41,448 KB
testcase_23 AC 130 ms
41,364 KB
testcase_24 AC 128 ms
41,656 KB
testcase_25 AC 140 ms
41,700 KB
testcase_26 AC 129 ms
41,864 KB
testcase_27 AC 161 ms
41,820 KB
testcase_28 AC 143 ms
41,800 KB
testcase_29 AC 142 ms
41,924 KB
testcase_30 AC 143 ms
41,900 KB
testcase_31 AC 140 ms
41,904 KB
testcase_32 AC 145 ms
41,568 KB
testcase_33 AC 166 ms
41,704 KB
testcase_34 AC 160 ms
41,636 KB
testcase_35 AC 170 ms
42,048 KB
testcase_36 AC 170 ms
42,028 KB
testcase_37 AC 199 ms
42,076 KB
testcase_38 AC 176 ms
42,168 KB
testcase_39 AC 176 ms
42,216 KB
testcase_40 AC 174 ms
42,164 KB
testcase_41 AC 184 ms
42,232 KB
testcase_42 AC 183 ms
42,308 KB
testcase_43 AC 181 ms
42,276 KB
testcase_44 AC 177 ms
42,324 KB
testcase_45 AC 180 ms
42,472 KB
testcase_46 AC 184 ms
42,312 KB
testcase_47 AC 181 ms
42,316 KB
testcase_48 AC 185 ms
42,456 KB
testcase_49 AC 185 ms
42,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] a = new int[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		sc.close();

		boolean[] ek = new boolean[n];
		Arrays.fill(ek, true);
		for (int m = 0; m < n; m++) {
			for (int e = 0; e < n; e++) {
				if (a[m][e] == a[e][m] && a[m][e] == m) {
				} else {
					ek[e] = false;
					break;
				}
			}
		}
		for (int e = 0; e < n; e++) {
			if (ek[e]) {
				boolean flga = true;
				for (int m = 0; m < n; m++) {
					boolean flg = false;
					for (int i = 0; i < n; i++) {
						if (a[m][i] == a[i][m] && a[m][i] == e) {
							flg = true;
							break;
						}
					}
					if (!flg) {
						flga = false;
						break;
					}
				}
				if (flga) {
					label:
					for (int m0 = 0; m0 < n; m0++) {
						for (int m1 = 0; m1 < n; m1++) {
							for (int m2 = 0; m2 < n; m2++) {
								if (a[a[m0][m1]][m2] != a[m0][a[m1][m2]]) {
									flga = false;
									break label;
								}
							}
						}
					}
					if (flga) {
						System.out.println("Yes");
						return;
					}
				}
			}
		}
		System.out.println("No");
	}
}
0