Redirecting to
NADOS

Magnets

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

1. You are given n number of domino shaped bipolar magnets.
2. You have to place these magnets in M*N following the conditions.
3. Conditions are -
a. Each box of 1*2 or 2*1 can contain a magnet or can be empty.
b. Empty box can be represented by X's and magnets are represented by + and
- sign.
c. Digits along left and top side of the board represents the number of + in
corresponding rows and columns.
d. Digits along right and bottom of the board represents the number of - in
corresponding rows and columns.
e. -1 denotes that the corresponding row and column can have any number of
+ and - signs.
f. No two adjacent cell can have the same sign.


Note -> Check out the question video and write the recursive code as it is intended without changing signature. The judge can't force you but intends you to teach a concept.
Input Format
A number M
A number N
M*N characters containing only 'L', 'R', 'T' and 'B'.
(For 1*2 box 'L' represents left end and 'R' represents the right end)
(For 2*1 box 'T' represents top end and 'B' represents the right end)
N integers representing count of '+' along the top edge.
M integers representing count of '+' along the left edge.
M integers representing count of '-' along the right edge.
N integers representing count of '-' along the bottom edge.
Output Format
Check the sample output and question video
Question Video
Constraints
2 <= M <= 10
2 <= N <= 10
Both M and N are not odd.
Sample Input
5 6
LRLRTT
LRLRBB
TTTTLR
BBBBTT
LRLRBB
1 -1 -1 2 1 -1
2 3 -1 -1 -1
-1 -1 -1 1 -1
2 -1 -1 2 -1 3
Sample Output
+ - + - X - 
- + - + X +
X X + - + -
X X - + X +
- + X X X -


  • Asked in Companies
  • Related Topics






Video Solution

Code Solution

Run
 
Run
Id Name