結果

問題 No.2267 群の公理
ユーザー ks2mks2m
提出日時 2023-04-14 21:53:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 1,180 bytes
コンパイル時間 2,401 ms
コンパイル使用メモリ 77,816 KB
実行使用メモリ 54,636 KB
最終ジャッジ日時 2024-04-18 19:17:15
合計ジャッジ時間 10,575 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
52,944 KB
testcase_01 AC 128 ms
53,828 KB
testcase_02 AC 126 ms
54,180 KB
testcase_03 AC 115 ms
52,828 KB
testcase_04 AC 126 ms
53,932 KB
testcase_05 AC 129 ms
54,044 KB
testcase_06 AC 129 ms
54,164 KB
testcase_07 AC 128 ms
53,996 KB
testcase_08 AC 127 ms
54,076 KB
testcase_09 AC 128 ms
53,928 KB
testcase_10 AC 126 ms
54,208 KB
testcase_11 AC 116 ms
52,876 KB
testcase_12 AC 128 ms
54,024 KB
testcase_13 AC 131 ms
52,932 KB
testcase_14 AC 116 ms
52,996 KB
testcase_15 AC 126 ms
53,844 KB
testcase_16 AC 129 ms
54,108 KB
testcase_17 AC 113 ms
52,920 KB
testcase_18 AC 118 ms
52,808 KB
testcase_19 AC 117 ms
52,796 KB
testcase_20 AC 131 ms
54,248 KB
testcase_21 AC 127 ms
53,904 KB
testcase_22 AC 123 ms
53,924 KB
testcase_23 AC 115 ms
53,068 KB
testcase_24 AC 125 ms
54,256 KB
testcase_25 AC 134 ms
54,592 KB
testcase_26 AC 134 ms
54,008 KB
testcase_27 AC 140 ms
54,120 KB
testcase_28 AC 139 ms
54,276 KB
testcase_29 AC 138 ms
54,284 KB
testcase_30 AC 139 ms
54,200 KB
testcase_31 AC 144 ms
54,020 KB
testcase_32 AC 141 ms
53,952 KB
testcase_33 AC 148 ms
54,188 KB
testcase_34 AC 153 ms
54,136 KB
testcase_35 AC 164 ms
54,448 KB
testcase_36 AC 162 ms
54,180 KB
testcase_37 AC 173 ms
54,208 KB
testcase_38 AC 173 ms
54,300 KB
testcase_39 AC 174 ms
54,344 KB
testcase_40 AC 168 ms
54,444 KB
testcase_41 AC 172 ms
54,168 KB
testcase_42 AC 171 ms
54,164 KB
testcase_43 AC 171 ms
54,416 KB
testcase_44 AC 183 ms
54,552 KB
testcase_45 AC 173 ms
54,544 KB
testcase_46 AC 177 ms
54,516 KB
testcase_47 AC 186 ms
54,340 KB
testcase_48 AC 167 ms
54,380 KB
testcase_49 AC 181 ms
54,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 flg1 = true;
		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]]) {
						flg1 = false;
						break label;
					}
				}
			}
		}
		if (!flg1) {
			System.out.println("No");
			return;
		}

		for (int e = 0; e < n; e++) {
			boolean flga = true;
			for (int m = 0; m < n; m++) {
				if (a[m][e] != a[e][m] || a[m][e] != m) {
					flga = false;
					break;
				}
			}
			if (flga) {
				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) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
}
0