結果

問題 No.1292 パタパタ三角形
ユーザー tamatotamato
提出日時 2020-11-20 22:13:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 964 bytes
コンパイル時間 401 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 102,240 KB
最終ジャッジ日時 2023-09-30 19:23:54
合計ジャッジ時間 3,015 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,468 KB
testcase_01 AC 74 ms
71,492 KB
testcase_02 AC 75 ms
71,816 KB
testcase_03 AC 75 ms
71,808 KB
testcase_04 AC 74 ms
71,836 KB
testcase_05 AC 75 ms
71,900 KB
testcase_06 AC 76 ms
71,756 KB
testcase_07 AC 114 ms
81,800 KB
testcase_08 AC 114 ms
81,156 KB
testcase_09 AC 138 ms
102,240 KB
testcase_10 AC 137 ms
102,108 KB
testcase_11 AC 136 ms
102,100 KB
testcase_12 AC 127 ms
97,552 KB
testcase_13 AC 132 ms
99,520 KB
testcase_14 AC 98 ms
77,140 KB
testcase_15 AC 98 ms
77,140 KB
testcase_16 AC 98 ms
77,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    S = input().rstrip('\n')

    up = {(0, 0)}
    down = set()
    x, y = 0, 0
    flg = 0
    D = [0, 1, 2]
    for ss in S:
        s = ord(ss) - 97
        #print(D)
        if flg == 0:
            if D[s] == 0:
                x -= 1
            elif D[s] == 1:
                y += 1
                D[0], D[1], D[2] = D[1], D[2], D[0]
            else:
                D[0], D[1], D[2] = D[2], D[0], D[1]
            flg = 1
            down.add((x, y))
        else:
            if D[s] == 0:
                x += 1
            elif D[s] == 1:
                D[0], D[1], D[2] = D[1], D[2], D[0]
            else:
                y -= 1
                D[0], D[1], D[2] = D[2], D[0], D[1]
            flg = 0
            up.add((x, y))
        #print(x, y, D)
    print(len(up) + len(down))
    #print(up)
    #print(down)


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