F010B. Threatening bishops P67340


Statement
 

pdf   zip

html

Consider a rectangular chessboard where there are some bishops. A bishop threatens to other one if both are in the same diagonal and there is not any other bishop between them. We want to know all the threats between bishops.

For instance, consider the following chessboard with 4 rows and 5 columns:

unit=0.75cm linewidth=0.6pt (6,5.5)

(1,1)(1,0)6(0,0)(0,4) (1,1)(0,1)5(0,0)(5,0)

[c](0.5 , 1.5 )4 [c](0.5 , 2.5 )3 [c](0.5 , 3.5 )2 [c](0.5 , 4.5 )1

[c](1.5 ,0.5 )1 [c](2.5 ,0.5 )2 [c](3.5 ,0.5 )3 [c](4.5 ,0.5 )4 [c](5.5 ,0.5 )5

[c](1.5 ,1.5 )X [c](3.5 ,3.5 )X [c](4.5 ,2.5 )X [c](4.5 ,4.5 )X [c](5.5 ,2.5 )X

The bishop of the position (3,5) has not any threat. The bishop of the position (4,1) threatens the bishop of the position (2,3). The bishop of the position (2,3) threatens to the bishops of the positions (4,1), (1,4) and (3,4). The set of all the threats is:

(4,1)↔(2,3) 
(2,3)↔(4,1) 
(2,3)↔(1,4) 
(1,4)↔(2,3) 
(2,3)↔(3,4) 
(3,4)↔(2,3)

Your task is to write a program that reads a chessboard with bishops and writes all their threats.

Input

The input starts with the number of rows and the number of columns of the chessboard (two integers strictly positive). Afterwards, there is a chessboard of the indicated size, with characters ‘|X|’ to indicate the bishops and dots to indicate the empty boxes.

Output

For each threat of a bishop to the position (r1,c1) to other bishop in the position (r2,c2), print a row with the text “(|r1|,|c1|)<->(|r2|,|c2|)”. The positions are numbered from top to bottom and from left to right, starting for 1.

Observation

The order which you write the lines is irrelevant. The Judge will consider as good any output that contains all the correct threats, with independence of their order.

Public test cases
  • Input

    4 5
    ...X.
    ..X..
    ...XX
    X....
    

    Output

    (1,4)<->(2,3)
    (2,3)<->(3,4)
    (2,3)<->(4,1)
    (2,3)<->(1,4)
    (3,4)<->(2,3)
    (4,1)<->(2,3)
    
  • Input

    3 3
    XXX
    XXX
    XXX
    

    Output

    (1,1)<->(2,2)
    (1,2)<->(2,3)
    (1,2)<->(2,1)
    (1,3)<->(2,2)
    (2,1)<->(3,2)
    (2,1)<->(1,2)
    (2,2)<->(3,3)
    (2,2)<->(3,1)
    (2,2)<->(1,3)
    (2,2)<->(1,1)
    (2,3)<->(3,2)
    (2,3)<->(1,2)
    (3,1)<->(2,2)
    (3,2)<->(2,3)
    (3,2)<->(2,1)
    (3,3)<->(2,2)
    
  • Input

    6 11
    .....X.....
    ...........
    ...........
    ...........
    ...........
    XXXXXXXXXXX
    

    Output

    (1,6)<->(6,11)
    (1,6)<->(6,1)
    (6,1)<->(1,6)
    (6,11)<->(1,6)
    
  • Input

    1 1
    .
    

    Output

    
            
                                
  • Information
    Author
    Professorat de P1
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++