MasterCook Cook Off!
All submissions for this problem are available.
MasterCook Cook Off!
It’s Season 7 of MasterCook and the teams of Chefs prepare for Round 5, the innovation round. Chefs are secretive, much like magicians, and as organizers of MasterCook, we must give them the privacy and space they require. Given the layout of the workstations in the MasterCook kitchen, can you figure out the best way to place the Chefs so that the only thing that fires up is the stove and not their tempers?
Rules for the organizers:
- No two chefs working on the same dish can be directly next to each other. Imagine the consequences, what if the chef from chef A swaps chef B's dish for his own?
- Rows may have gaps in between to allow passage of the MasterCook crew. Chefs on either side of this gap may be allowed to cook the same dish.
- Chefs in each row are isolated from the chefs in the adjacent rows by the shelves of ingredients. No problem there!
- All workstations must be occupied. If less is good, more must be better!
Can you find all possible ways in which this can be done?
- The first line contains the number of dishes being prepared in the competition N.
- The next line describes the number of rows and columns M1 and M2.
- This is follwed by M1 lines describing the workstation placement for each row of M2 columns in the grid. A 1 indicates the presence of a workstation and 0 indicates a gap.
Total number of ways in which the chefs can be arranged.
- 1 < N < 10
- 0 <= M1,M2 < 10
Input: 3 3 4 1 1 0 1 0 1 0 1 1 0 1 0 Output: 1458
The first line says that there are 3 dishes (N=3)
The next line describes the grid by the number of rows (M1=3) and columns (M2=4).
The next M1(3) lines describe the presence or absence (1 or 0) of a workstation in each of the M2(4) columns of each row.
The output contains a single integer representing the number of different arrangements of the chefs: 1458
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.