#pragma once #include "clusters.hpp" #include template struct Solution { std::deque taps; }; template auto solve_impl(Field const & field, Solution & s){ for(auto&& p : field.all_positions()){ if(!field.empty(p)) goto analyse; } return true; analyse: for(auto&& c : all_clusters(field)){ if(c.size() < 3) continue; auto new_field = make_empty(field, c); if(solve_impl(new_field, s)) { s.taps.push_front(*c.begin()); return true; } } return false; } template auto solve(Field const & field){ Solution s; solve_impl(field, s); return s; }