結果

問題 No.1292 パタパタ三角形
ユーザー tktk_snsntktk_snsn
提出日時 2020-11-20 22:33:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 973 bytes
コンパイル時間 212 ms
コンパイル使用メモリ 10,876 KB
実行使用メモリ 35,384 KB
最終ジャッジ日時 2023-09-30 19:37:12
合計ジャッジ時間 3,461 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,036 KB
testcase_01 AC 16 ms
7,932 KB
testcase_02 AC 15 ms
8,100 KB
testcase_03 WA -
testcase_04 AC 16 ms
7,988 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 274 ms
35,352 KB
testcase_13 AC 281 ms
35,324 KB
testcase_14 AC 194 ms
8,392 KB
testcase_15 AC 201 ms
8,324 KB
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()

nx = 0
ny = 0

memo = set()
memo.add((nx, ny))

da = [0, 1]
db = [0, -1]
dc = [1, 0]
for s in S:
    if s == "a":
        dx, dy = da
        if dx != 0:
            da[0] *= -1
        else:
            db, dc = dc, db
            da[0] *= -1
            da[1] *= -1
            db[0] *= -1
            db[1] *= -1
            dc[0] *= -1
            dc[1] *= -1
    elif s == "b":
        dx, dy = db
        if dx != 0:
            db[0] *= -1
        else:
            da, dc = dc, da
            da[0] *= -1
            da[1] *= -1
            db[0] *= -1
            db[1] *= -1
            dc[0] *= -1
            dc[1] *= -1
    else:
        dx, dy = dc
        if dx != 0:
            db[0] *= -1
        else:
            da, db = db, da
            da[0] *= -1
            da[1] *= -1
            db[0] *= -1
            db[1] *= -1
            dc[0] *= -1
            dc[1] *= -1
    nx += dx
    ny += dy
    memo.add((nx, ny))


print(len(memo))
0