結果

問題 No.1292 パタパタ三角形
ユーザー tsuzuiritsuzuiri
提出日時 2020-11-26 00:35:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 1,077 bytes
コンパイル時間 534 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 104,716 KB
最終ジャッジ日時 2023-10-01 02:04:26
合計ジャッジ時間 2,872 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,268 KB
testcase_01 AC 70 ms
71,104 KB
testcase_02 AC 68 ms
71,148 KB
testcase_03 AC 68 ms
70,948 KB
testcase_04 AC 69 ms
71,192 KB
testcase_05 AC 66 ms
71,256 KB
testcase_06 AC 71 ms
71,356 KB
testcase_07 AC 112 ms
82,204 KB
testcase_08 AC 111 ms
80,976 KB
testcase_09 AC 138 ms
104,716 KB
testcase_10 AC 137 ms
104,432 KB
testcase_11 AC 138 ms
104,580 KB
testcase_12 AC 130 ms
99,044 KB
testcase_13 AC 133 ms
101,764 KB
testcase_14 AC 90 ms
76,424 KB
testcase_15 AC 91 ms
76,868 KB
testcase_16 AC 90 ms
76,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def p2(inputs):
    ref = 0
    x=0
    y=0
    inv=0
    history = set()
    history.add((x,y))
    for _in in inputs:
        if 0==ref:
            if _in == 'a':
                if inv:
                    y+=1
                else:
                    y-=1
            elif _in == 'b':
                x+=1
                ref=2
            else:
                x-=1
                ref=1
        elif 1==ref:
            if _in == 'b':
                if inv:
                    y+=1
                else:
                    y-=1
            elif _in == 'c':
                x+=1
                ref=0
            else:
                x-=1
                ref=2
        else:
            if _in == 'c':
                if inv:
                    y+=1
                else:
                    y-=1
            elif _in == 'a':
                x+=1
                ref=1
            else:
                x-=1
                ref=0
        history.add((x,y))
        inv^=1
    print(len(history))


from sys import stdin
input = stdin.readline

p2(input().rstrip())
0