結果
| 問題 | 
                            No.2267 群の公理
                             | 
                    
| コンテスト | |
| ユーザー | 
                             nagisa5101
                         | 
                    
| 提出日時 | 2023-04-14 21:28:44 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 1,838 bytes | 
| コンパイル時間 | 4,219 ms | 
| コンパイル使用メモリ | 258,176 KB | 
| 最終ジャッジ日時 | 2025-02-12 06:19:57 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 50 | 
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repll(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep2(i, n, m) for (int i = n; i < (int)(m); i++)
#define repll2(i, n, m) for (long long i = n; i < (long long)(m); i++)
#define all(v) v.begin(),v.end()
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vvvl=vector<vvl>;
using vld=vector<ld>;
using vvld=vector<vld>;
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};
const double PI = acos(-1);
//const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=(1LL<<60);
const int INF2=(1<<30);
//using mint=modint1000000007;
//using mint=modint998244353;
int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n;cin>>n;
    int op[n][n];
    rep(i,n)rep(j,n)cin>>op[i][j];
    int e=-1;
    set<int> st;
    //単位元
    rep(i,n){
        int f=1;
        rep(j,n)if(op[i][j]!=j||op[j][i]!=j)f=0;
        if(f){
            e=i;
            st.insert(e);
        }
    }
    if(e==-1){
        cout<<"No"<<endl;
        return 0;
    }
    //逆元
    rep(i,n){
        int f=0;
        rep(j,n)if(st.count(op[i][j])&&st.count(op[j][i]))f=1;
        if(f==0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    rep(i,n){
        rep(j,n){
            rep(k,n){
                int v=op[i][j],u=op[j][k];
                if(op[v][k]!=op[i][u]){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}
            
            
            
        
            
nagisa5101