The currently available, detailed properties (e.g., isotopic ratios) of solar system planets may provide guides for constructing better approaches of exoplanet characterization. With this motivation, we explore how the measured values of the deuterium-to-hydrogen (D/H) ratio of Uranus and Neptune can constrain their formation mechanisms. Under the assumption of in-situ formation, we investigate three solid accretion modes; a dominant accretion mode switches from pebble accretion to drag-enhanced three-body accretion and to canonical planetesimal accretion, as the solid radius increases. We consider a wide radius range of solids that are accreted onto (proto)Neptune-mass planets and compute the resulting accretion rates as a function of both the solid size and the solid surface density. We find that for small-sized solids, the rate becomes high enough to halt concurrent gas accretion, if all the solids have the same size. For large-sized solids, the solid surface density needs to be enhanced to accrete enough amounts of solids within the gas disk lifetime. We apply these accretion modes to the formation of Uranus and Neptune and show that if the minimum-mass solar nebula model is adopted, solids with radius of ~ 1 m to ~ 10 km should have contributed mainly to their deuterium enrichment; a tighter constraint can be derived if the full solid size distribution is determined. This work therefore demonstrates that the D/H ratio can be used as a tracer of solid accretion onto Neptune-mass planets. Similar efforts can be made for other atomic elements that serve as metallicity indicators.