Exact algorithms for a discrete metric labeling problem