Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language: C++ (Need to use backtracking!) Given a board with irregular shape, your task is to place chess pieces and make sure no more than

Language: C++ (Need to use backtracking!)

Given a board with irregular shape, your task is to place chess pieces and make sure no more than 1 chess pieces is placed on the same row or the same column. Output the number of different ways of such placement.

The first line of the input consists of two integers n and k. n means the size of board is nn and k is the number of chess pieces to be placed. The next n lines describe the shape of the chess board: '#' describes the board region and '.' is the blank region (cannot place chess piece here).

image text in transcribed

Example 1 Input: 2 1 .# #. Output: 2 Example 2 Input: 33 #. # ## Output: 2 Example 3 Input: 4 4 # Output: 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions