Код: Выделить всё
eg. Given 3 missionaries/cannibals and max capacity of boat is 2, the expected result is 11;
Given 4 missionaries/cannibals and max capacity of boat is 3, there is no solution, and expected result is -1.
Ниже приведен мой код, который входит в тупик при вводе равен 4 2 и не может пройти онлайн-судью.
Код: Выделить всё
#include
using namespace std;
struct state
{
int wolf, sheep;
};
state s[65536];
int d[65536] = {0};
int k;
vector op;
void solve(int n, int m)
{
if (m == 1)
{
cout = op.size())
d[k--] = 0;
} while (!(s[k].wolf == 0 && s[k].sheep == 0));
cout n >> m;
solve(n, m);
return 0;
}
Искренне рассчитываем на вашу щедрую помощь.
Подробнее здесь: https://stackoverflow.com/questions/792 ... ral-situat
Мобильная версия