There's really not much you can do now except either buy a new computer, or try to get the computer out of the river (only if it's safe to do so, which it most likely isn't if you put it in the river a while ago). If somehow you're able to get the computer out of the river, assuming it's a laptop, keep it open and upside down on a surface to let the water drain and HOPEFULLY it works again (but most likely, it won't).
For the future: So for next time, you can use Ad blockers (Adblock plus is one I use, and some other people use Ublock Origin), which are extensions into multiple browsers, which prevent these ads from coming. Another tip: if you put your mouse over the ad (but don't click it), you'll see on the bottom left of the browser what URL it redirects to, so you can kind of tell if it's a good or bad website. But it's still best not to click on any ads unless you're VERY sure where it takes you.
Also, if the message says you're doing illegal stuff, most likely it is a scam (fake message) and you can ignore it. Same with most "computer locked" or "computer infected" messages. Just close the webpage (if you can't, try to close it from Task Manager or just simply restart your computer). Most likely, nothing bad would happen to your computer just by visiting a website (unless the website downloaded something onto your machine).