Text this: Exact Dynamic Programming for Solow--Polasky Diversity Subset Selection on Lines and Staircases