A - Treasure Chest Editorial by evima

Proposer's Implementation

You can use regular expression to represent the pattern “|, zero or more any characters, *, zero or more any characters, |” and search for it in \(S\) to find the answer at once.

Sample Implementation (Python. The pattern looks a bit complicated because both | and * are special characters and need to be escaped)

import re
N, S = input(), input()
print('in' if re.search('\|.*\*.*\|', S) else 'out')

posted:
last update: