結果

問題 No.2267 群の公理
コンテスト
ユーザー chro_96
提出日時 2023-04-14 21:31:01
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 987 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 340 ms
コンパイル使用メモリ 39,168 KB
最終ジャッジ日時 2026-02-22 10:25:33
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>

int main () {
  int n = 0;
  int n0n1[30][30] = {};
  
  int res = 0;
  
  int is_ok = 1;
  int e = -1;
  
  res = scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      res = scanf("%d", n0n1[i]+j);
    }
  }
  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (n0n1[n0n1[i][j]][k] != n0n1[i][n0n1[j][k]]) {
          is_ok = 0;
        }
      }
    }
  }
  
  for (int i = 0; i < n; i++) {
    int is_e = 1;
    for (int j = 0; j < n; j++) {
      if (n0n1[i][j] != j || n0n1[j][i] != j) {
        is_e = 0;
      }
    }
    if (is_e > 0) {
      e = i;
    }
  }
  
  for (int i = 0; i < n; i++) {
    int is_inv = 0;
    for (int j = 0; j < n; j++) {
      if (n0n1[i][j] == e && n0n1[j][i] == e) {
        is_inv = 1;
      }
    }
    is_ok *= is_inv;
  }
  
  if (is_ok <= 0 || e < 0) {
    printf("No\n");
  } else {
    printf("Yes\n");
  }
  
  return 0;
}
0