結果
問題 |
No.1292 パタパタ三角形
|
ユーザー |
![]() |
提出日時 | 2020-11-20 21:38:32 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 691 bytes |
コンパイル時間 | 173 ms |
コンパイル使用メモリ | 82,276 KB |
実行使用メモリ | 125,996 KB |
最終ジャッジ日時 | 2024-07-23 12:46:46 |
合計ジャッジ時間 | 3,144 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 3 WA * 11 |
ソースコード
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 else: for i in range(3): if i != c: pos[i] = cur[i] else: pos[i] = cur[i]-1 pos = tuple(pos) if pos not in d: ans += 1 d.add(cur) cur = pos pre = c print(ans)