Tuesday, March 6, 2007 Match summaryThe last region to compete in Round 1 was also the one with most contestants. One hundred and eleven high school competitors, mostly from Europe, competed to get a positive score. At the end, all but two got their ticket to Round 2. The only red of this region, Zuza, was the favorite of the round, but he lost too many points by resubmitting the hard problem twice. tomekkulczynski got the first place with a 75 point lead over rlp. Third place went to Kalq, who rounded out the allPolish podium. tomekkulczynski's victory also brought his highschool rating into the red, where his nonHS algorithm rating has been for some time.The ProblemsBadExamUsed as: Division One  Level One: To solve this problem, you just need to follow the steps explained in the statement. First, calculate the highest mark mmax. After that, modify each mark with the formula of the statement. Then you just need to calculate the average of the marks, summing them all and then dividing by the number of students. CountingCrowds Used as: Division One  Level Two: The first thing to consider is what the problem is really asking you. You have to do an interpretation of the data, which means you have to decide when each person going through the door is first noticed by the sensor. If you want the minimal interpretation, you can assume that each person is under the sensor until the measure of the sensor contradicts their presence, i.e. the sensor measures a height lower than that person. With this idea, you have to keep track of the heights of the people going through the door at each moment. And of course, you will suppose that two persons of the same height will never be under the sensor at the same moment. After each measure, you have to update the people that are under the sensor. If any person is taller than the new measure, it means that this person has already left. tomekkulczynski implemented such an algorithm. Other solutions use an O(n^2) algorithm  for an example, see icanadi’s solution. FamilyTravel Used as: Division One  Level Three: First of all, we need to translate the problem into a graph problem. We are asked for the shortest path from node 0 to node 1, such that the length of the edges in the path forms a decreasing sequence. This problem can be solved in a couple of different ways. The most straightforward one was to use Dynamic Programming, a technique that is very useful in TopCoder problems. If you have not heard about it, take a look at this tutorial. We will solve it with a recursive function that will tell us how much it costs to get to node 1 from node u given that the last edge on the actual path has a length of len. We have to be careful not to fall into a cycle of edges of the same length, which could lead us to a infinite recursion. Thus, we will have to mark which states (which combinations of node and last length) we have visited, so if we visit them again, we can stop the recursion at that level. int shortest(int node, int len) { if ( memo[node][len] != 1) return memo[node][len]; if ( vis[node][len] == 1 ) return infinity; vis[node][len] = 1; int ret = infinity; for(int i=0;i<n;i++)if(graph[node][i]!='0' && dis( graph[len][i] ) <= len ) { ret = Math.Min( ret, shortest( i, dis( graph[len][i] ) ) + dis( graph[len][i] ); } return memo[node][len]=ret; }Such a solution was implemented by fpavetic. Other contestants used a kind of breadthfirst search algorithm. 
