結果

問題 No.2267 群の公理
ユーザー umezoumezo
提出日時 2023-04-14 22:27:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,094 bytes
コンパイル時間 2,208 ms
コンパイル使用メモリ 198,580 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 19:58:47
合計ジャッジ時間 3,099 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  cin>>n;
  
  if(n==0){
    cout<<"Yes"<<endl;
    return 0;
  }
  
  vector<vector<int>> A(n,vector<int>(n));
  rep(i,n) rep(j,n) cin>>A[i][j];
  
  bool b=true;
  for(int x=0;x<n;x++){
    for(int y=0;y<n;y++){
      for(int z=0;z<n;z++){
        if(A[A[x][y]][z]!=A[x][A[y][z]]) b=false;
      }
    }
  }
  
  int e=-1;
  for(int x=0;x<n;x++){
    bool f=true;
    for(int y=0;y<n;y++){
      if(A[y][x]!=y || A[x][y]!=y || A[x][y]!=A[y][x]) f=false;
    }
    if(f){
      e=x;
      break;
    }
  }
  if(e==-1){
    cout<<"No"<<endl;
    return 0;
  }
  
  bool ans=true;
  for(int x=0;x<n;x++){
    for(int i=0;i<n;i++){
      bool f=true;
      for(int y=0;y<n;y++){
        if(A[x][i]!=e || A[i][x]!=e) f=false;
      }
      if(f) break;
      else if(i==n-1) ans=false;
    }
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
    
  return 0;
}
0