結果

問題 No.1292 パタパタ三角形
ユーザー tsuzuiritsuzuiri
提出日時 2020-11-26 00:04:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 1,103 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 11,016 KB
実行使用メモリ 38,380 KB
最終ジャッジ日時 2023-10-01 02:03:18
合計ジャッジ時間 2,053 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,848 KB
testcase_01 AC 15 ms
7,896 KB
testcase_02 AC 14 ms
7,872 KB
testcase_03 AC 15 ms
7,820 KB
testcase_04 AC 15 ms
7,844 KB
testcase_05 AC 15 ms
7,792 KB
testcase_06 AC 15 ms
7,916 KB
testcase_07 AC 87 ms
16,996 KB
testcase_08 AC 84 ms
16,420 KB
testcase_09 AC 146 ms
38,000 KB
testcase_10 AC 145 ms
37,864 KB
testcase_11 AC 145 ms
37,412 KB
testcase_12 AC 141 ms
38,244 KB
testcase_13 AC 145 ms
38,380 KB
testcase_14 AC 56 ms
11,048 KB
testcase_15 AC 57 ms
11,168 KB
testcase_16 AC 59 ms
11,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def p2(data):
    inputs=list(data)
    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(list(input().rstrip()))
0