We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cd62198 commit cd602e9Copy full SHA for cd602e9
1 file changed
live11/test114/문제1/백한결.py
@@ -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