結果
問題 | No.1292 パタパタ三角形 |
ユーザー | brthyyjp |
提出日時 | 2020-11-20 21:45:03 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 712 bytes |
コンパイル時間 | 270 ms |
コンパイル使用メモリ | 86,932 KB |
実行使用メモリ | 128,260 KB |
最終ジャッジ日時 | 2023-09-30 19:05:49 |
合計ジャッジ時間 | 4,088 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 77 ms
71,180 KB |
testcase_01 | AC | 77 ms
71,532 KB |
testcase_02 | AC | 74 ms
71,476 KB |
testcase_03 | WA | - |
testcase_04 | AC | 76 ms
71,460 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 | 268 ms
124,312 KB |
testcase_13 | AC | 267 ms
124,476 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
ソースコード
s = list(str(input())) S = [] for c in s: if c == 'a': S.append(0) elif c == 'b': S.append(1) else: S.append(2) S.reverse() d = set() n = len(S) cur = (0, 0, 0) d.add(cur) ans = 1 pre = -1 for i in range(n): c = S.pop() pos = [0, 0, 0] if pre != c: for i in range(3): if i != c: pos[i] = cur[i] else: pos[i] = cur[i]+1 pre = c else: for i in range(3): if i != c: pos[i] = cur[i] else: pos[i] = cur[i]-1 pre = -1 pos = tuple(pos) if pos not in d: ans += 1 d.add(cur) cur = pos print(ans)