01_parens.py 241 B

12345678910
  1. #!/usr/bin/env python3
  2. import sys
  3. line = sys.stdin.readline().rstrip()
  4. print(line.count('(') - line.count(')'))
  5. total = 0
  6. for index, c in enumerate(line):
  7. total += 1 if c == '(' else -1
  8. if total == -1:
  9. break
  10. print(index + 1)