especulars trees P27804


Statement
 

pdf   zip

thehtml

Write a program that reads various binary trees of natural numbers and, for each one, indicates if is a mirror tree or not. We say that a tree is mirror if its left side and its right side are the one like the reflection of the other in a vertical mirror.

Input

Input is a sequence of descriptions of trees as it is explained at the exercise .

Output

For each tree, your program must print "MIRROR" or "NO MIRROR" as required.

Public test cases
  • Input

    7
    100 70 20 -1 30 -1 -1 -1 70 -1 20 30 -1 -1 -1
    
    3
    100 200 -1 -1 300 -1 -1
    
    5
    300 300 300 -1 -1 -1 300 300 -1 -1 -1
    

    Output

    MIRROR
    NO MIRROR
    NO MIRROR
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++