In a 5-3 ruling, the justices found that state officials used race as the predominant factor in drawing district lines.