P2509 [SCOI2008] Warning

Description

There is a simple scripting language with only three kinds of statements: assignment, conditional, and return. Variable names must be single uppercase letters, and all variables are 32-bit signed integers. Each statement of this language must occupy its own line. The program contains no empty lines, and there are no spaces at the beginning or end of any line. Different tokens on the same line are separated by a single space. The BNF of the language is as follows: ```cpp :: | | | ELSE | END IF | :: PARAM | PARAM :: = :: IF THEN :: RETURN :: | :: | :: | :: + | - | * | / :: < | = | > :: A | B | ... | Z :: 不含前导 0 的 32 位带符号整数 ``` The first line of the program is a `` statement that defines the function’s parameters, and the last line is guaranteed to be a `` statement. A `` statement cannot appear anywhere except the first line, but `` statements may appear multiple times in the program. Line numbers start from $1$. Every `IF` statement always has a matching `END IF` statement, and may have an optional `ELSE` statement (note that there is no `ELSE IF` statement). `IF` statements may be nested, and they always compare a variable with an integer or another variable. You should analyze a given program and output two kinds of warning messages (see the sample output format): - Type 1 warning: unreachable code lines. These are lines that cannot be executed no matter whether the boolean expressions of the `IF` statements evaluate to true or false (assume that each `IF` condition is independently both possibly true and possibly false, unaffected by other `IF` results). - Type 2 warning: possibly uninitialized variables. A statement uses the value of some variable, but this variable is neither listed in the parameter list on the first line nor assigned by an assignment statement before this point. If a statement is unreachable, you should not report this warning for it. Note that the statements `ELSE` and `END IF` are not executable, so they should not receive any warnings.

Input Format

At most $50$ lines, i.e., the program you need to process. The program is guaranteed to be legal.

Output Format

Output warnings sorted by line number in ascending order. If there are multiple possibly uninitialized variables on the same line, list them in alphabetical order. If there are no warnings, your output should be empty.

Explanation/Hint

Translated by ChatGPT 5