結果
| 問題 |
No.2267 群の公理
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-31 17:28:03 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 45 ms / 2,000 ms |
| コード長 | 1,133 bytes |
| コンパイル時間 | 128 ms |
| コンパイル使用メモリ | 82,308 KB |
| 実行使用メモリ | 61,392 KB |
| 最終ジャッジ日時 | 2025-03-31 17:28:10 |
| 合計ジャッジ時間 | 3,293 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 50 |
ソースコード
n = int(input())
if n == 0:
print("No")
exit()
op = []
for _ in range(n):
row = list(map(int, input().split()))
op.append(row)
# Check associativity
associative = True
for a in range(n):
for b in range(n):
for c in range(n):
left = op[op[a][b]][c]
right = op[a][op[b][c]]
if left != right:
associative = False
break
if not associative:
break
if not associative:
break
if not associative:
print("No")
exit()
# Find identity element
identity = -1
for e in range(n):
valid = True
for x in range(n):
if op[e][x] != x or op[x][e] != x:
valid = False
break
if valid:
identity = e
break
if identity == -1:
print("No")
exit()
# Check inverse elements
has_inverses = True
for x in range(n):
found = False
for y in range(n):
if op[x][y] == identity and op[y][x] == identity:
found = True
break
if not found:
has_inverses = False
break
print("Yes" if has_inverses else "No")
lam6er