Voters swept aside the two main communist parties that had shaped Nepali politics for years, reducing them to minor players in parliament.