結果
問題 | No.1292 パタパタ三角形 |
ユーザー | brthyyjp |
提出日時 | 2020-11-20 21:38:32 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 691 bytes |
コンパイル時間 | 251 ms |
コンパイル使用メモリ | 87,008 KB |
実行使用メモリ | 128,360 KB |
最終ジャッジ日時 | 2023-09-30 19:02:59 |
合計ジャッジ時間 | 4,104 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
71,344 KB |
testcase_01 | AC | 71 ms
71,172 KB |
testcase_02 | AC | 71 ms
71,296 KB |
testcase_03 | WA | - |
testcase_04 | AC | 73 ms
71,232 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 | 250 ms
124,136 KB |
testcase_13 | AC | 241 ms
124,376 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 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)