portableangel   2년 전

The input string P is invalid if 

(1) the parentheses and the brackets are unmatched, 

(2) it contains punctuation symbols other than parentheses, brackets, and commas, 

(3) the punctuation symbols are added or omitted wrongly such as S,,S, SS, or B,(S), 

and (4) it contains unknown types of node other than S, L, or B.

"빈 문자열" 또는 "공백으로만 이루어진 문자열"은 위에 명시된 invalid 조건을 모두 통과합니다. 즉 valid하다고 판단해도 문제 조건 중 아무것도 위반하지 않습니다.

만약 "빈 문자열" 또는 "공백으로만 이루어진 문자열"이 valid할 경우, Ef=Eb=V=0이기 때문에 답이 2가 되어야 하지만, 지금은 invalid라고 판정하여 -1을 출력해야 정답이 됩니다.

이미 이런 문자열이 들어올 경우 따로 -1을 출력하는 수많은 코드가 있기 때문에 데이터를 수정하기보다는, 해당 데이터(길이가 0이거나 공백 문자만 입력되는 데이터)를 전부 삭제해 주시거나, 입력 단락에 있는 invalid 관련 설명 끝에 "A valid graph must contain at least 1 node"와 같은 조건을 추가해 주세요.

startlink   11달 전

수정했습니다.

댓글을 작성하려면 로그인해야 합니다.