cpp solution