結果

問題 No.2267 群の公理
ユーザー FlkanjinFlkanjin
提出日時 2023-10-02 05:50:37
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,670 bytes
コンパイル時間 2,114 ms
コンパイル使用メモリ 192,016 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-10-02 05:50:42
合計ジャッジ時間 5,000 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,384 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,384 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 2 ms
4,380 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <array>
#include <bit>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <concepts>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numbers>
#include <numeric>
#include <queue>
#include <random>
#include <ranges>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

constexpr int MOD{1'000'000'007};
constexpr int MOD2{998'244'353};
constexpr int INF{1'000'000'000}; //1e9
constexpr int NIL{-1};
constexpr long long LINF{1'000'000'000'000'000'000}; // 1e18
constexpr long double EPS{1E-10L};
using namespace std::literals;

template<class T, class S> bool chmax(T &a, const S &b){
    if(a < b){a = b; return true;}
    return false;
}
template<class T, class S> bool chmin(T &a, const S &b){
    if(b < a){a = b; return true;}
    return false;
}
template<class T> bool inside(T x, T lx, T rx){ //semi-open
    return (std::ranges::clamp(x, lx, rx-1) == x);
}
template<class T> bool inside(T x, T y, T lx, T rx, T ly, T ry){
    return inside(x, lx, rx) && inside(y, ly, ry);
}
template<class T> void print_vec(std::vector<T> &v, std::string sep = " "s, std::string end = "\n"s){
    std::ranges::copy(v | std::views::reverse | std::views::drop(1) | std::views::reverse, std::ostream_iterator<T>(std::cout, sep.c_str()));
    if(!v.empty()) std::cout << v.back();
    std::cout << end;
}



int main(){
    std::cout << ([](){
        int N; std::cin >> N;
        std::vector A(N, std::vector<int>(N)); auto At{A};
        for(int i{0}; i < N; ++i) for(int j{0}; j < N; ++j){
            std::cin >> A[i][j]; At[j][i] = A[i][j];
        }
        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]]) return false;
        std::vector<int> B(N); std::iota(std::ranges::begin(B), std::ranges::end(B), 0);
        int e_grp{NIL};
        for(int i{0}; i < N && e_grp == NIL; ++i) if(A[i] == B && At[i] == B) e_grp = i;
        if(e_grp == NIL) return false;
        for(int i{0}; i < N; ++i){
            int i_rev{NIL};
            for(int j{0}; j < N && i_rev == NIL; ++j) if(A[i][j] == e_grp && A[j][i] == e_grp) i_rev = j;
            if(i_rev == NIL) return false;
        }
        return true;
    }() ? "Yes" : "No") << std::endl;
    return 0;
}
0