結果

問題 No.1292 パタパタ三角形
ユーザー lloyzlloyz
提出日時 2022-09-24 00:07:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 532 ms / 2,000 ms
コード長 617 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 10,904 KB
実行使用メモリ 47,296 KB
最終ジャッジ日時 2023-08-23 21:11:10
合計ジャッジ時間 6,536 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,992 KB
testcase_01 AC 15 ms
7,892 KB
testcase_02 AC 15 ms
7,836 KB
testcase_03 AC 15 ms
7,824 KB
testcase_04 AC 15 ms
7,868 KB
testcase_05 AC 15 ms
7,804 KB
testcase_06 AC 15 ms
7,816 KB
testcase_07 AC 447 ms
17,532 KB
testcase_08 AC 430 ms
16,784 KB
testcase_09 AC 532 ms
47,296 KB
testcase_10 AC 526 ms
46,800 KB
testcase_11 AC 523 ms
46,196 KB
testcase_12 AC 508 ms
42,864 KB
testcase_13 AC 511 ms
42,860 KB
testcase_14 AC 348 ms
9,744 KB
testcase_15 AC 371 ms
9,616 KB
testcase_16 AC 388 ms
9,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = list(input())

n = len(S)
ans = set([(1, 1, 1)])
curr = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
for i in range(n):
    if S[i] == 'a':
        for j in range(3):
            curr[0][j] = -curr[0][j] + curr[1][j] + curr[2][j]
    elif S[i] == 'b':
        for j in range(3):
            curr[1][j] = curr[0][j] - curr[1][j] + curr[2][j]
    elif S[i] == 'c':
        for j in range(3):
            curr[2][j] = curr[0][j] + curr[1][j] - curr[2][j]
    g = (curr[0][0] + curr[1][0] + curr[2][0],
         curr[0][1] + curr[1][1] + curr[2][1],
         curr[0][2] + curr[1][2] + curr[2][2])
    ans.add(g)
print(len(ans))
0