Here's how the competitors breathed underwater:
* Harry Potter: He used gills provided by Dobby, the house-elf. These gills were magical and allowed him to breathe underwater.
* Cedric Diggory: He used a gillyweed, a magical plant that allows the user to breathe underwater.
* Viktor Krum: He used a gillyweed as well, presumably. Although not explicitly stated, it's the most logical explanation given that it's the standard solution to breathing underwater in the wizarding world.
* Fleur Delacour: She also used gillyweed, just like Cedric and Krum.
Interestingly, the Triwizard Tournament rules did not specify how the competitors should achieve underwater breathing. It was up to the contestants to figure out a way to achieve it, leading to various solutions within the wizarding world.