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..
Minimum shelves, write a c++ program, that finds the minimum total number o...
write a c++ program, that finds the minimum total number of shelves, including the initial one, required for this loading process.
Program to creates a linked list of characters , Note: Please refer to the...
Note: Please refer to the Subject Outline for details regarding the assessment of the advanced assignment. The Problem You are to investigate the use of data structures an
Explain operator overloading fundamentals, Operator Overloading Fundamental...
Operator Overloading Fundamentals The C language uses the concept of Operator Overloading discreetly. The asterisk (*) is used as multiplication operator as well as indirect
Explain static variables, Static Variables Static variables have the si...
Static Variables Static variables have the similar scope s automatic variables, but, unlike automatic variables, static variables retain their values over number of function ca
#superASC2 SRTING COST, A string S is said to be "Super ASCII", if it conta...
A string S is said to be "Super ASCII", if it contains the character frequency equal to their ascii values. String will contain only lower case alphabets (''a''-''z'') and the asci
Described access privileges in c++? what is the default , A: In C++ the acc...
A: In C++ the access privileges are public, private and protected. The default access level assigned to members of a class is private. Private members of any class are accessible o
Big-m method, big-m method operation reseach in progrmme c++..
big-m method operation reseach in progrmme c++..
C program to create, Aim: To implement a program to create, update & displ...
Aim: To implement a program to create, update & display account & admin record of person using display account & admin records of person using virtual base class.. Code:
Luminous Jewels - The Polishing Game, within 2 mins give me answer pllzzzzz...
within 2 mins give me answer pllzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
Decode the code, give the coding in c++
give the coding in c++
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
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.