結果

問題 No.1717 Levi-Civita Triangle
ユーザー 👑 kakel-sankakel-san
提出日時 2021-10-22 23:33:49
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 1,468 bytes
コンパイル時間 1,854 ms
コンパイル使用メモリ 110,980 KB
実行使用メモリ 39,512 KB
最終ジャッジ日時 2023-10-24 15:45:34
合計ジャッジ時間 5,465 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
25,392 KB
testcase_01 AC 26 ms
25,392 KB
testcase_02 AC 25 ms
25,372 KB
testcase_03 AC 25 ms
25,372 KB
testcase_04 AC 25 ms
25,372 KB
testcase_05 AC 30 ms
25,736 KB
testcase_06 AC 34 ms
26,432 KB
testcase_07 AC 59 ms
30,520 KB
testcase_08 AC 27 ms
25,372 KB
testcase_09 AC 27 ms
25,372 KB
testcase_10 AC 32 ms
25,740 KB
testcase_11 AC 35 ms
26,392 KB
testcase_12 AC 47 ms
27,316 KB
testcase_13 AC 27 ms
25,392 KB
testcase_14 AC 27 ms
25,392 KB
testcase_15 AC 31 ms
25,760 KB
testcase_16 AC 34 ms
26,208 KB
testcase_17 AC 67 ms
31,940 KB
testcase_18 AC 27 ms
25,392 KB
testcase_19 AC 31 ms
25,716 KB
testcase_20 AC 32 ms
25,728 KB
testcase_21 AC 33 ms
26,192 KB
testcase_22 AC 57 ms
30,424 KB
testcase_23 AC 27 ms
25,392 KB
testcase_24 AC 30 ms
25,716 KB
testcase_25 AC 30 ms
25,764 KB
testcase_26 AC 31 ms
25,860 KB
testcase_27 AC 41 ms
26,628 KB
testcase_28 AC 26 ms
25,392 KB
testcase_29 AC 26 ms
25,392 KB
testcase_30 AC 30 ms
25,764 KB
testcase_31 AC 32 ms
26,112 KB
testcase_32 AC 69 ms
32,228 KB
testcase_33 AC 87 ms
39,512 KB
testcase_34 AC 87 ms
39,512 KB
testcase_35 AC 86 ms
39,512 KB
testcase_36 AC 88 ms
39,512 KB
testcase_37 AC 89 ms
39,512 KB
testcase_38 AC 89 ms
39,512 KB
testcase_39 AC 88 ms
39,512 KB
testcase_40 AC 89 ms
39,512 KB
testcase_41 AC 87 ms
39,512 KB
testcase_42 AC 86 ms
39,512 KB
testcase_43 AC 86 ms
39,512 KB
testcase_44 AC 88 ms
39,512 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;

class yuki319
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(int n) => Enumerable.Repeat(0, n).Select(_ => NList).ToArray();
    static void Main()
    {
        var n = NN;
        var a = NList;
        var list = LCT(a);
        if (Check(list))
        {
            WriteLine(list.Last());
        }
        else
        {
            WriteLine(0);
        }
    }
    static bool Check(List<int> list)
    {
        if (list.Count == 1) return true;
        for (var i = 1; i < list.Count; i += 2) if (list[i] != 0) return false;
        if (list[0] == 0 || list[2] == 0 || list[0] == list[2]) return false;
        for (var i = 4; i < list.Count; i += 4) if (list[0] != list[i]) return false;
        for (var i = 6; i < list.Count; i += 4) if (list[2] != list[i]) return false;
        return true;
    }
    static List<int> LCT(int[] list)
    {
        var nl = new List<int>(list.Length - 2);
        for (var i = 0; i < list.Length - 2; ++i)
        {
            if (list[i] == (list[i + 1] + 1) % 3 && list[i] == (list[i + 2] + 2) % 3) nl.Add(2);
            else if (list[i + 1] == (list[i] + 1) % 3 && list[i + 2] == (list[i] + 2) % 3) nl.Add(1);
            else nl.Add(0);
        }
        return nl;
    }
}
0