May 15, 2002 Lessons Learned the Hard Way SRM 88 was the first match of the new "multiple submissions" era. This was discussed at length in the lobby prior to the match. The sense seemed to be that multiple submissions were a double edged sword, adding to the coding phase, but possibly taking away from the challenge phase. Statistics on multiple submissions in Div-II would be most interesting to see. Perhaps a staff member could post some data to the round tables? My feeling was that the problem slate was too demanding to allow much time for resubmission. The problem slate in Div-II was probably more mathematical or algorithmic than we've seen recently. (Many Div-II problems have had size limits of 100-1000 on integers, for instance. The 500 in SRM 88 went up to a billion.) Recently, Div-II has had a lot of simulation problems, so some clean algorithmic problems were a refreshing change. On the other hand, the socre seems to have been pretty low (particularly on the 250, where many rooms had > 50% systest failure. 300 (BadSpanish) A simple problem: input is a String, output is a String, translate according to the following rules:
This problem is make for java.util.StringTokenizer. The constructor StringTokenizer(String input, String delims, boolean returnDelimiters) saves a considerable amount of coding. Once split into tokens, the rest of the problem is much less tricky. I'm not sufficiently familiar with the C# or C++ apis to comment on the best solution there. Problems:
500 (Divisors) The task was to take an array of up to 50 integers between 1 and 1,000,000,000 and count (once) each integer which was a factor of at least one of the inputs. Unusually for Div-II, this problem require attention to be paid to efficiency. It turned out that the problem could be brute forced, provided some care was taken. An outline of the solution:
for val in input { The java.util.HashSet class or STL hash_set was ideal for this. The critical issue here is to only scroll up to sqrt val. (sqrt(1,000,000,000) is roughly 33,000 times 50 interations is pretty comfortable in 8 secs on a modern box.) Problems:
1000 (Farmers) Three farmers want to fence off and mark the land they own in a field. Count the amount of fencing, and the number of signs required to mark each area. The input is a String[], return is an int. The problem also saw service as the 500 in Div-I. I believe this problem fits in a category called "flood/fill". In outline, the solution is as follows:
// setup :
// check each square to see if it has been visited
int check(char[][] data, int x, int y, char val) { That is far shorter than average Div-II solution. (I took inspiration from the Div-I coders, after the contest.) It's also the sort of problem which is quite easy once you've seen a solution, but is hard to find in textbooks. Note that a little global data is very useful. I noticed that the test cases on which the problems failed tended to involve large amounts of input. This means that I may have failed to spot errors in some of the problems. Problems:
Member Comments In "Lessons Learned the Hard Way" for "Single Round Match 88" slowjoe states for the algorithm of the hard problem: "[...] but is hard to find in textbooks." I believe that depth first search (DFS), what this basically is, can be found in about *every* textbook. The only part you have to do yourself is to see the graph in the matrix. sloejoe, I think you have a problem in your 1000 pt div2 answer. You say
// Recursively check the fences I say
// Recursively check the fences |
|