Placid subsets P68087


Statement
 

pdf   zip

You are planning a trip for the nn members of a club. However, some of the members dislike other members. Therefore, you decide to choose a subset SS of members such that:

  • Inside SS, noone dislikes anyone.

  • There is no SS' such that SSS \subset S' and such that SS' fulfils the first property. In other words, SS must be maximal.

Given the information about who dislikes who, can you count the number of such subsets?

Input

Input consists of several cases, each one with nn followed by nn lines with nn characters each. For iji \ne j, the jj-th character of the ii-th line is ‘L’ or ‘D’ depending on whether ii likes or dislikes jj. The diagonal has only dots. Assume 1n201 \le n \le 20.

Output

For every case, print the number of maximal placid subsets.

Public test cases
  • Input

    2
    .D
    L.
    
    5
    .LDDL
    D.LDL
    DL.LL
    LDD.D
    LLLL.
    
    6
    .LLLLL
    L.LLLL
    LL.LLL
    DLL.LL
    LLDL.L
    LLLDD.
    

    Output

    2
    3
    4
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++