結果

問題 No.1717 Levi-Civita Triangle
ユーザー noetherian_ringnoetherian_ring
提出日時 2021-10-22 23:25:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 171 ms / 2,000 ms
コード長 1,505 bytes
コンパイル時間 1,123 ms
コンパイル使用メモリ 81,408 KB
実行使用メモリ 158,868 KB
最終ジャッジ日時 2023-10-24 15:32:38
合計ジャッジ時間 7,167 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
55,416 KB
testcase_01 AC 46 ms
55,416 KB
testcase_02 AC 45 ms
55,416 KB
testcase_03 AC 45 ms
55,416 KB
testcase_04 AC 45 ms
55,416 KB
testcase_05 AC 109 ms
63,988 KB
testcase_06 AC 80 ms
77,456 KB
testcase_07 AC 125 ms
114,096 KB
testcase_08 AC 44 ms
55,424 KB
testcase_09 AC 42 ms
55,424 KB
testcase_10 AC 54 ms
66,060 KB
testcase_11 AC 73 ms
76,796 KB
testcase_12 AC 89 ms
93,380 KB
testcase_13 AC 56 ms
55,424 KB
testcase_14 AC 51 ms
55,424 KB
testcase_15 AC 57 ms
60,760 KB
testcase_16 AC 68 ms
73,188 KB
testcase_17 AC 164 ms
138,848 KB
testcase_18 AC 48 ms
55,424 KB
testcase_19 AC 48 ms
55,424 KB
testcase_20 AC 52 ms
60,724 KB
testcase_21 AC 73 ms
73,664 KB
testcase_22 AC 127 ms
107,660 KB
testcase_23 AC 42 ms
55,424 KB
testcase_24 AC 42 ms
55,424 KB
testcase_25 AC 54 ms
66,064 KB
testcase_26 AC 56 ms
68,124 KB
testcase_27 AC 78 ms
85,536 KB
testcase_28 AC 41 ms
55,424 KB
testcase_29 AC 41 ms
55,424 KB
testcase_30 AC 53 ms
66,060 KB
testcase_31 AC 57 ms
72,220 KB
testcase_32 AC 138 ms
140,476 KB
testcase_33 AC 164 ms
158,840 KB
testcase_34 AC 164 ms
158,844 KB
testcase_35 AC 168 ms
158,844 KB
testcase_36 AC 164 ms
158,844 KB
testcase_37 AC 164 ms
158,844 KB
testcase_38 AC 164 ms
158,844 KB
testcase_39 AC 163 ms
158,864 KB
testcase_40 AC 171 ms
158,864 KB
testcase_41 AC 163 ms
158,868 KB
testcase_42 AC 165 ms
158,868 KB
testcase_43 AC 164 ms
158,864 KB
testcase_44 AC 164 ms
158,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
from itertools import repeat
import sys
import os

sys.setrecursionlimit(100000)
is_local = "TERM_PROGRAM" in os.environ
input = sys.stdin.readline
INF = float('inf')
MOD = 998244353

def debug(*args, **kwargs):
    if is_local:
        print(*args, **kwargs)
def I(): return input().rstrip()
def IS(): return input().split()
def II(): return int(input())
def IIS(): return map(int, input().split())
def LIIS(): return list(map(int, input().split()))

jun_map = {0: 1, 1: 2, 2: 0}
rev_map = {0: 2, 2: 1, 1: 0}

def main():
    n = II()
    va = LIIS()
    rev = n % 2 == 0
    one_array = [0]
    two_array = [0]
    cnt = 0
    for _ in range(2*n):
        one_array.append(step(one_array[-1], rev))
        two_array.append(step(two_array[-1], not rev))
        cnt += 1
        if cnt == 2:
            rev = not rev
            cnt = 0

    one_array2 = []
    one_array3 = []
    two_array2 = []
    two_array3 = []
    for i in range(2*n+1):
        one_array2.append(jun_map[one_array[i]])
        one_array3.append(rev_map[one_array[i]])
        two_array2.append(jun_map[two_array[i]])
        two_array3.append(rev_map[two_array[i]])
    if va == one_array or va == one_array2 or va == one_array3:
        print(1)
    elif va == two_array or va == two_array2 or va == two_array3:
        print(2)
    else:
        print(0)


def step(x, rev):
    if rev:
        return rev_map[x]
    else:
        return jun_map[x]


if __name__ == "__main__":
    main()
0