結果

問題 No.2267 群の公理
ユーザー NAMIDAIRONAMIDAIRO
提出日時 2023-04-14 21:39:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,195 bytes
コンパイル時間 1,269 ms
コンパイル使用メモリ 120,092 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 19:00:40
合計ジャッジ時間 2,179 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 1 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 1 ms
5,376 KB
testcase_43 AC 1 ms
5,376 KB
testcase_44 AC 1 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
testcase_49 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <random>
#include <iomanip>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)

template<class T>
using vi = vector<T>;

template<class T>
using vii = vector<vi<T>>;

template<class T>
using viii = vector<vii<T>>;

using P = pair<ll, int>;

void chmin(ll & x, ll y) { x = min(x, y); }

int main()
{
	int n;
	cin >> n;
	vii<int> a(n, vi<int>(n));
	rep(i, n) rep(j, n) cin >> a[i][j];

	bool ok = true;
	rep(i, n) rep(j, n) {
		if (a[i][j] != a[j][i]) ok = false;
	}

	//結合律
	rep(i, n) rep(j, n) rep(k, n) {
		if (a[a[i][j]][k] != a[i][a[j][k]]) ok = false;
	}

	//単位律
	vi<bool> check(n);
	rep(i, n){
		bool t = true;
		rep(j, n) {
			if (a[i][j] == j && a[j][i] == j) continue;
			t = false;
		}
		check[i] = t;
	}
		
	//逆元律
	bool ok2 = false;
	rep(i, n) {
		if (!check[i]) continue;
		
		int cnt = 0;
		rep(j, n) {
			rep(k, n) {
				if (a[j][k] == i) {
					cnt++;
					break;
				}
			}
		}
		if (cnt == n) ok2 = true;
	}

	if (ok && ok2) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}
0