結果
問題 | No.2267 群の公理 |
ユーザー |
|
提出日時 | 2023-04-14 21:49:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,148 bytes |
コンパイル時間 | 1,792 ms |
コンパイル使用メモリ | 175,368 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-10 12:31:56 |
合計ジャッジ時間 | 2,948 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 50 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector<vector<int>> A(N, vector<int>(N)); for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ cin >> A[i][j]; } } vector<int> e; for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ for(int k = 0; k < N; k++){ if(A[A[i][j]][k] != A[i][A[j][k]]){ cout << "No" << '\n'; return 0; } } if(A[i][j] == i){ e.emplace_back(j); } } } sort(e.begin(), e.end()); e.erase(unique(e.begin(), e.end()), e.end()); if(e.size() != 1){ cout << "No" << '\n'; return 0; } for(int i = 0; i < N; i++){ bool flag = true; for(int j = 0; j < N; j++){ if(A[i][j] == e[0]){ flag = false; break; } } if(flag){ cout << "No" << '\n'; return 0; } } cout << "Yes" << '\n'; }