How are these events judged? Is it all a freestyle thing? Or are all of the participants given the same routine and are judge on how well they execute?
There are (4) flight programs, and this is the order in which they're flown at all contests - the Known (Q), Freestyle (Free), Unknown, and 4-minute Freestyle. All but the 4-minute flight involve a specific sequence of figures that the judging team has a copy of on the ground for following the flight. Judging criteria is too big a subject to describe here. The Known sequence is a sequence that is published by CIVA each year, and changes year-to-year. All pilots fly this same sequence for the first flight at each contest. At the world level, this is a qualifying flight that does not count toward the overall standings. It counts in IAC contests in the US. The 2nd flight (Freestyle) is a sequence custom-designed by each pilot, so most pilots have different Free sequences. The Unknown flight involves a sequence that the pilots are handed the day before it must be flown, and have never seen before. It cannot be practiced. You walk through it on the ground, and pre-plan as well as you can, then go fly it.
In IAC contests here, we're handed a single Unknown sequence. In world competition, each team (country) submits a single figure for inclusion in the Unknown. All figures are gathered, but the teams do not see all the other figures until it's time to construct the sequence. With these figures, each team is allowed to arrange the figures as desired to create a sequence. Then they fly that sequence.
The last flight - The 4-minute Free flight is basically an airshow-style flight that is judged largely on impression and creativity, along with some technical standards. There is no set sequence that the judges see.