입력 문단의 "To make the representation easy to read, P may contain spaces; the pairs of brackets [ and ] can be used instead of the pairs of parentheses and they should be matched." 후에 다음과 같이 추가하면 명확해질 것 같습니다.
"Parentheses and brackets can only be used for enclosing the substructure of a loop node or a branch node."
djm03178 5년 전
대회 때 이의 제기가 있었고 답변을 받았던 내용이라고 들었습니다.
입력 문자열 P가 invalid한 경우 중에 소괄호, 대괄호의 짝이 맞지 않거나, 잘못 추가되거나 생략된 괄호가 있는 경우를 제시해놓기는 했으나, 괄호가 반드시 L과 B 직후에만 나타나야 하는지에 대한 여부는 명확하지 않습니다. 대표적으로
(S)
가 valid한지, invalid한지는 지문과 예시들만 보고는 알기 어렵습니다. 하지만 이는 허용하지 않아야 정답을 받고, 허용하면 틀립니다.
좀 더 구체적으로는 문법을 다음과 같이 하면 틀리고, (시작 심볼 = G)
G -> S | S,G
S -> (G) | [G] | 'L'(G) | 'L'[G] | 'B'(G) | 'B'[G] | 'S'
다음과 같이 해야 맞습니다.
G -> S | S,G
S -> 'L'(G) | 'L'[G] | 'B'(G) | 'B'[G] | 'S'
입력 문단의 "To make the representation easy to read, P may contain spaces; the pairs of brackets [ and ] can be used instead of the pairs of parentheses and they should be matched." 후에 다음과 같이 추가하면 명확해질 것 같습니다.
"Parentheses and brackets can only be used for enclosing the substructure of a loop node or a branch node."