Welcome to ZOJ
Information
Select Problem
Runs
Ranklist
ZOJ Problem Set - 3786
Unreachable Statement

Time Limit: 2 Seconds      Memory Limit: 65536 KB

You are a senior programmer of MacroHard software company. Recent days, you are working on the compiler of a modern programming language invented by MacroHard. The programming language is a C-based language called C♭ (pronounced see flat). Here is a sample code of C♭:

function gao() {
    if (x <= 5)
        print a
    else {
        if (x < 3)
            print b
        else
            print c
    }
    print d
}

As you see, there is an unreachable statement in the sample code: "print b". As C♭ is a modern programming language, the compiler should be able to check the validity of source code. In other words, the compiler should report the statement which will never be executed.

A grammar subset of C♭ programming language is listed below:

  • <function> ::= function <function-name> ( ) { <body> }
  • <body> ::= <statement> <body> | ε
  • <statement> ::= <branch-statement> | <output-statement> | { <body> }
  • <branch-statement> ::= if ( <expression> ) <statement> [ else <statement> ]
  • <output-statement> ::= print <variable>
  • <expression> ::= true | false | <variable> <operator> <constant>
  • <operator> ::= < | > | <= | >=
  • <constant> ::= <nonzero-digit> <digit>* | 0
  • <variable> ::= <alpha> <alpha>*
  • <function-name> ::= <alpha> <alpha>*
  • <alpha> ::= A | B | ... | Z | a | b | ... | z
  • <digit> ::= 0 | 1 | ... | 9
  • <nonzero-digit> ::= 1 | 2 | ... | 9

The name of functions and variables have at most 20 characters. Each variable stores a 32-bit unsigned integer. Each constant is also in the range of 32-bit unsigned integer. If two adjacent lexical elements only consist of letters or digits, they will be separated by at least one whitespace character. To avoid ambiguity, each else will be attached to the closest if.

Input

There is only one test case.

The input contains several function definition of C♭ programming language. All variables referred in the function have been predefined in other places with constant non-null values.

The total input will not exceed 2 MB. Each function will use no more than 500 variables. The whitespace characters in the input will only contain space (0x20) and newline (0x0A).

Output

Report the unreachable statements in the format of "Unreachable statement at line #, column #".

All unreachable statements should be reported, except for those which are the part of another unreachable statement. See the sample output for details.

Sample Input

function gao() {
    if (x <= 5)
        print a
    else {
        if (x < 3)
            print b
        else
            print c
    }
    print d
}

function zaigao()
{
    if(x>100)
    {
        print LongVariable
        if(x<=15)
        {
            print hello
            print world
        }
        print lol
    }
}

Sample Output

Unreachable statement at line 6, column 13
Unreachable statement at line 19, column 9

Author: JIANG, Kai
Source: The 11th Zhejiang Provincial Collegiate Programming Contest
Submit    Status