HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Data Structures > problem:


50490 - Across the River

Guest
• Review clarifications (1)

Volume problems

• 50429 - Secret Message
• 50818 - Depth Limited BST
• 50836 - Censored
• 50505 - kht Puzzle
• 50840 - Tanker trucks
• 50877 - Friendly Queue
• 50876 - He is my cousin
• 50997 - Dynamic Knights
• 50490 - Across the River
• 50816 - Largest Sum Path
• 50857 - Nine-Stones Game
• 50837 - Sum is equal to K
• 50772 - The Path of a Node
• 50936 - Saving the Soldiers
• 50447 - Swimming Contest - 2
• 50828 - Arranging Time Table
• 50794 - Writing Files Into HDD

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Ibrahim Mesecan.

Across the River

There are n people escaping from the war. They have to cross over a river. There is a boat which can carry k people. After crossing the river, they can pull back the boat using a string. To provide security on both sides of the river, certain people cannot leave together. At least one soldier must exist on either side of the river.

Question: Write a program that is going to read the people information and decide by how many different ways all the people can cross the river.

Input specification: There are 3 integers in the first line:

  • n: the number of people
  • m: the number of soldiers where m is between 2 and 4
  • k: the number of people the boat can carry
where 0 < n < 8, 1 < m ≤ 4, and 2 ≤ k ≤ 6, and k is a multiple of (m+n) The following line lists the name of n people separated by spaces. The last line contains the name of the soldiers. Names contain only 26 English uppercase or lowercase characters.

Output specification
Show one integer: the number of different ways all the people can cross the river.

Sample Input I
2 2 2
Andi Anisa
Ani Geri
Sample Output I
4

Explanation: There are 4 possible ways that they can use the boat and cross over a river. The soldiers below are underlined.

  1. [Andi Ani] - [Anisa Geri]
  2. [Andi Geri] - [Anisa Ani]
  3. [Anisa Ani] - [Andi Geri]
  4. [Anisa Geri] - [Andi Ani]


Для отправки решений необходимо выполнить вход.

www.contester.ru