Universally-optimal distributed algorithms for known topologies