Solitaire of the stones (2) P52369


Statement
 

pdf   zip

html

This exercise is a variation of the exercise : “”. The only difference in the rules of the game is that now the jumps do not make disappear the stones that have been jumped.

Write a program such that, given two configurations of a solitaire, prints if is possible to go from one to the other one.

Input

Input consists of a natural n ≥ 3, followed by the descriptions of the two configurations, each one with n rows with n characters each one. A ’X’ indicates a stone. The empty positions are indicated with a dot.

Output

Your program must print "1" if you can go from one configuration to the other one, or "0" if it is not possible.

Public test cases
  • Input

    3
    
    .XX
    X..
    .XX
    
    .X.
    X..
    XXX
    

    Output

    1
    
  • Input

    3
    
    XXX
    ...
    XXX
    
    XXX
    ...
    XXX
    

    Output

    1
    
  • Input

    4
    
    XX..
    .XX.
    ..X.
    XXX.
    
    XXX.
    ...X
    XX..
    ..XX
    

    Output

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