Your task is to write a program that determines, for each given word,
if it is correctly parenthesized or not. Here, a word is a non empty
sequence of ’(’, ’)’, ’[’ and
’]’ without intermediate spaces.
For instance, these are some words correctly parenthesized:
() [] ()[] [()] ((())) ()[]([]) ([[]()](()))
And these are some words incorrectly parenthesized:
) []) (](] [)()] [(())) ()[][])( ([[]()](()
The input consists of a series of words of between 1 and 1000 characters, one per line.
For each given word, your program must print "correct"
or "incorrect" as required.
TestA:
Some test cases will include words like the ones in the instance 1,
that is, only with the characters ’(’ y
’)’.
TestB:
Other test cases will include words with the characters
’(’, ’)’, ’[’ y
’]’.
Author: Unknown
Translator: Carlos Molina
Generation: 2026-01-25T10:25:27.216Z
© Jutge.org, 2006–2026.
https://jutge.org