結果

問題 No.1292 パタパタ三角形
ユーザー Kiri8128Kiri8128
提出日時 2020-11-20 22:03:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 354 ms / 2,000 ms
コード長 1,290 bytes
コンパイル時間 511 ms
コンパイル使用メモリ 11,160 KB
実行使用メモリ 44,320 KB
最終ジャッジ日時 2023-09-30 19:16:49
合計ジャッジ時間 4,204 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,044 KB
testcase_01 AC 16 ms
8,088 KB
testcase_02 AC 15 ms
8,048 KB
testcase_03 AC 15 ms
8,116 KB
testcase_04 AC 16 ms
8,168 KB
testcase_05 AC 16 ms
8,036 KB
testcase_06 AC 16 ms
8,012 KB
testcase_07 AC 250 ms
16,152 KB
testcase_08 AC 245 ms
15,952 KB
testcase_09 AC 323 ms
42,968 KB
testcase_10 AC 325 ms
42,312 KB
testcase_11 AC 320 ms
41,992 KB
testcase_12 AC 301 ms
38,060 KB
testcase_13 AC 354 ms
44,320 KB
testcase_14 AC 235 ms
10,204 KB
testcase_15 AC 231 ms
10,192 KB
testcase_16 AC 184 ms
10,068 KB
権限があれば一括ダウンロードができます

ソースコード

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()
S.add((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