Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб. 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.
- [Andi Ani] - [Anisa Geri]
- [Andi Geri] - [Anisa Ani]
- [Anisa Ani] - [Andi Geri]
- [Anisa Geri] - [Andi Ani]
Для отправки решений необходимо выполнить вход.
|