結果

問題 No.2267 群の公理
ユーザー a01sa01to
提出日時 2024-12-19 00:29:24
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 782 bytes
コンパイル時間 3,279 ms
コンパイル使用メモリ 249,720 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-19 00:29:29
合計ジャッジ時間 4,610 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
#else
  #define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

int main() {
  int n;
  cin >> n;
  vector a(n, vector<int>(n));
  rep(i, n) rep(j, n) cin >> a[i][j];
  bool ok = true;
  rep(i, n) rep(j, n) rep(k, n) if (a[a[i][j]][k] != a[i][a[j][k]]) ok = false;
  bool exi = false;
  rep(e, n) {
    bool tmp = true;
    rep(i, n) if (a[i][e] != i || a[e][i] != i) tmp = false;
    rep(i, n) {
      bool exis = false;
      rep(j, n) if (a[i][j] == e && a[j][i] == e) exis = true;
      if (!exis) tmp = false;
    }
    if (tmp) exi = true;
  }
  cout << (ok && exi ? "Yes" : "No") << endl;
  return 0;
}
0