EDIT: Oh, and the maths/physics/etc. competitions started at neighborhood level, so every school would typically send at least a few kids, and encourage the kids who were better at the subjects to do well. I went to neighborhood biology/history/etc. competitions too, but never did very well. I assume whoever did well in those and went into next rounds could go on to enroll into a different set of specialized schools :) Also, some parents did enroll their kids straight into those schools, but I dunno how prevalent that is. They are very ability focused, unlike US private schools that I've heard of where money and helicopter parenting seem to be a major factor.
As a side note, my friend did enroll into #2, and I didn't go because was too lazy to commute 40mins one way when my own school was a 3-minute walk (it was a subway trip for him as is, so I'd like to think that was the difference ;)). We've both done well for ourselves but he's definitely much better at math now.