Customer Service Chat
Get quote & make Payment
, C/C++ Programming
Question 1 / 1
You have an N x N chessboard and you wish to place N kings on it. Each row and column should contain exactly one king, and no two kings should attack each other (two kings attack each other if they are present in squares which share a corner).
The kings in the first K rows of the board have already been placed. You are given the positions of these kings as an array pos[ ]. pos[i] is the column in which the king in the ith row has already been placed. All indices are 0-indexed. In how many ways can the remaining kings be placed?
The first line contains the number of test cases T. T test cases follow. Each test case contains N and K on the first line, followed by a line having K integers, denoting the array pos[ ] as described above.
Output the number of ways to place kings in the remaining rows satisfying the above conditions. Output all numbers modulo 1000000007.
1 <= T <= 20
1 <= N <= 16
0 <= K <= N
0 <= pos_i < N
The kings specified in the input will be in different columns and not attack each other.
1 3 0 2
For the first example, there is a king already placed at row 0 and column 2. The king in the second row must belong to column 0. The king in the third row must belong to column 3, and the last king must beong to column 1. Thus there is only 1 valid placement.
For the second example, there is no valid placement.
Posted Date: 9/9/2012 3:44:09 PM | Location : United States
Ask an Expert
, Assignment Help, Ask Question on , Get Answer, Expert's Help, Discussions
Write discussion on
Your posts are moderated
Write your message here..
Write a program that predicts users age, Write a program that predicts user...
Write a program that predicts users age: Write a program that predicts users' age (0-128 years old) with at most 7 questions. The game starts with asking the user whether he/s
How can one "reopen" std::cin & std::cout in binary mode?, A: It is impleme...
A: It is implementation dependent. Verify with your compiler's documentation. For instance, assume you wish to do binary I/O using std::cin & std::cout. Unluckily there is no st
Linked list, program for singly linked list with out header
program for singly linked list with out header
Explain external variables, External Variables Different functions of t...
External Variables Different functions of the similar program can be written in different source files and can be compiled together. The scope of a global variable is not limit
Cloud computing, hi Bhasker, as we spoke tru phone ,we need a project usin...
hi Bhasker, as we spoke tru phone ,we need a project using cloud computing .we need to present a protoype or demo on it (any thing using cloud should be fine)(ex: P2p)
Describe, A: Use operator overloading to present a friend right-shift opera...
A: Use operator overloading to present a friend right-shift operator, operator>>. It is similar to the output operator, except the parameter doesn't contain a const: "Fred&" instea
Computer organization, what do you mean by control word
what do you mean by control word
Luminous Jewels - The Polishing Game, program
Arrays, how to write the code for operation research
how to write the code for operation research
Described c++ storage classes?, A: auto: the default. Variables are created...
A: auto: the default. Variables are created and initialized automatically while they are defined and destroyed at the ending of the block containing their definition. They are not
Accounting Assignment Help
Economics Assignment Help
Finance Assignment Help
Statistics Assignment Help
Physics Assignment Help
Chemistry Assignment Help
Math Assignment Help
Biology Assignment Help
English Assignment Help
Management Assignment Help
Engineering Assignment Help
Programming Assignment Help
Computer Science Assignment Help
IT Courses and Help
Why Us ?
~24x7 hrs Support
~Quality of Work
~Time on Delivery
~Privacy of Work
Human Resource Management
Literature Review Writing Help
Follow Us |
T & C
Copyright by ExpertsMind IT Educational Pvt. Ltd.