結果

問題 No.1292 パタパタ三角形
ユーザー Kiri8128Kiri8128
提出日時 2020-11-20 21:59:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,282 bytes
コンパイル時間 70 ms
コンパイル使用メモリ 11,184 KB
実行使用メモリ 44,268 KB
最終ジャッジ日時 2023-09-30 19:13:50
合計ジャッジ時間 3,822 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,116 KB
testcase_01 AC 16 ms
8,112 KB
testcase_02 AC 15 ms
8,072 KB
testcase_03 WA -
testcase_04 AC 16 ms
8,212 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 252 ms
16,196 KB
testcase_08 WA -
testcase_09 AC 325 ms
42,924 KB
testcase_10 AC 336 ms
42,336 KB
testcase_11 AC 331 ms
42,076 KB
testcase_12 AC 318 ms
38,104 KB
testcase_13 AC 355 ms
44,268 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

A = [ord(a) - 97 for a in input()]
N = len(A)
x, y = 0, 0
U = [(1, -1), (-1, 1), (-1, -1)]
S = set((0, 0))
for i, a in enumerate(A):
    x += U[a][0]
    y += U[a][1]
    S.add((x, y))
    if i % 2 == 0:
        if U[a] == (1, -1):
            U[a] = (-1, 1)
            if U[a-1] == (-1, 1):
                U[a-1] = (1, 1)
                U[a-2] = (1, -1)
            else:
                U[a-1] = (1, -1)
                U[a-2] = (1, 1)
        elif U[a] == (-1, 1):
            U[a] = (1, -1)
            if U[a-1] == (1, -1):
                U[a-1] = (1, 1)
                U[a-2] = (-1, 1)
            else:
                U[a-1] = (-1, 1)
                U[a-2] = (1, 1)
        else:
            U[a] = (1, 1)
        
    else:
        if U[a] == (1, -1):
            U[a] = (-1, 1)
            if U[a-1] == (1, 1):
                U[a-1] = (1, -1)
                U[a-2] = (-1, -1)
            else:
                U[a-1] = (-1, -1)
                U[a-2] = (1, -1)
        elif U[a] == (-1, 1):
            U[a] = (1, -1)
            if U[a-1] == (1, 1):
                U[a-1] = (-1, 1)
                U[a-2] = (-1, -1)
            else:
                U[a-1] = (-1, -1)
                U[a-2] = (-1, 1)
        else:
            U[a] = (-1, -1)
print(len(list(S)))
0