結果

問題 No.2267 群の公理
ユーザー 👑 kakel-sankakel-san
提出日時 2023-07-05 17:35:33
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 1,918 bytes
コンパイル時間 2,059 ms
コンパイル使用メモリ 72,160 KB
実行使用メモリ 25,576 KB
最終ジャッジ日時 2023-09-26 17:52:15
合計ジャッジ時間 9,151 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
25,576 KB
testcase_01 AC 63 ms
21,648 KB
testcase_02 AC 63 ms
21,572 KB
testcase_03 AC 63 ms
23,540 KB
testcase_04 AC 63 ms
23,440 KB
testcase_05 AC 63 ms
21,668 KB
testcase_06 AC 63 ms
21,588 KB
testcase_07 AC 63 ms
21,548 KB
testcase_08 AC 63 ms
23,600 KB
testcase_09 AC 63 ms
23,624 KB
testcase_10 AC 63 ms
21,472 KB
testcase_11 AC 63 ms
21,664 KB
testcase_12 AC 64 ms
23,640 KB
testcase_13 AC 62 ms
21,652 KB
testcase_14 AC 63 ms
21,628 KB
testcase_15 AC 64 ms
23,580 KB
testcase_16 AC 64 ms
23,596 KB
testcase_17 AC 64 ms
23,576 KB
testcase_18 AC 64 ms
21,540 KB
testcase_19 AC 63 ms
23,604 KB
testcase_20 AC 64 ms
21,552 KB
testcase_21 AC 64 ms
21,672 KB
testcase_22 AC 64 ms
19,496 KB
testcase_23 AC 64 ms
21,532 KB
testcase_24 AC 63 ms
21,620 KB
testcase_25 AC 63 ms
19,568 KB
testcase_26 AC 63 ms
21,552 KB
testcase_27 AC 63 ms
21,676 KB
testcase_28 AC 62 ms
21,556 KB
testcase_29 AC 64 ms
23,700 KB
testcase_30 AC 64 ms
23,596 KB
testcase_31 AC 63 ms
23,628 KB
testcase_32 AC 64 ms
23,632 KB
testcase_33 AC 64 ms
23,528 KB
testcase_34 AC 64 ms
23,596 KB
testcase_35 AC 64 ms
21,604 KB
testcase_36 AC 63 ms
19,564 KB
testcase_37 AC 64 ms
21,648 KB
testcase_38 AC 64 ms
21,660 KB
testcase_39 AC 64 ms
21,536 KB
testcase_40 AC 64 ms
19,720 KB
testcase_41 AC 64 ms
21,596 KB
testcase_42 AC 64 ms
21,640 KB
testcase_43 AC 65 ms
23,724 KB
testcase_44 AC 65 ms
21,640 KB
testcase_45 AC 64 ms
21,536 KB
testcase_46 AC 63 ms
23,612 KB
testcase_47 AC 65 ms
21,476 KB
testcase_48 AC 64 ms
21,696 KB
testcase_49 AC 63 ms
21,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var map = NArr(n);
        for (var i = 0; i < n; ++i) for (var j = 0; j < n; ++j)
        {
            if (map[i][j] != map[j][i])
            {
                WriteLine("No");
                return;
            }
            for (var k = 0; k < n; ++k)
            {
                if (map[map[i][j]][k] != map[i][map[j][k]])
                {
                    WriteLine("No");
                    return;
                }
            }
        }
        var elist = new List<int>();
        for (var e = 0; e < n; ++e)
        {
            var flg = true;
            for (var j = 0; j < n; ++j)
            {
                if (map[e][j] != j) flg = false;
            }
            if (flg) elist.Add(e);
        }
        foreach (var e in elist)
        {
            var all = true;
            for (var i = 0; i < n; ++i)
            {
                var flg = false;
                for (var j = 0; j < n; ++j)
                {
                    if (map[i][j] == e)
                    {
                        flg = true;
                        break;
                    }
                }
                if (!flg)
                {
                    all = false;
                    break;
                }
            }
            if (all)
            {
                WriteLine("Yes");
                return;
            }
        }
        WriteLine("No");
    }
}
0