Skip to content

Commit cd602e9

Browse files
author
hangyeol
committed
114차 1번 문제풀이
1 parent cd62198 commit cd602e9

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import sys
2+
from itertools import combinations
3+
4+
5+
def main():
6+
input = sys.stdin.readline
7+
8+
expression = str(input().strip())
9+
stack = []
10+
pair = []
11+
12+
for index, char in enumerate(expression):
13+
if char == '(':
14+
stack.append(index)
15+
elif char == ')':
16+
start = stack.pop()
17+
pair.append((start, index))
18+
19+
result = set()
20+
21+
for i in range(1, len(pair)+1):
22+
for comb in combinations(pair, i):
23+
temp = list(expression)
24+
for s, e in comb:
25+
temp[s] = temp[e] = ''
26+
result.add(''.join(temp))
27+
28+
for res in sorted(result):
29+
print(res)
30+
31+
if __name__ == '__main__':
32+
main()

0 commit comments

Comments
 (0)