New ACM ICPC Season

N

It’s been quite a while since I posted, but the Pacific Northwest regional competition is coming up in about a month. As a result, beginning last night, I’ve started training UVic undergrads in preparation for the competition. I had all the newbies work on four different simple problems, mostly dealing with string processing.


Links to problems:
  • http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=585
  • http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=1056
  • http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=951
  • http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=350
Everyone solved at least one problem and several solved a couple over the 3 hour meeting time. I had the more experienced members work as a team on problems from the 2002 Rocky Mountain regional. Working in a team of two, they solved 5 problems in about 2.5 hours. The problems in this particular regional were pretty straightforward, but it’s still an encouraging start.

I’m becoming more and more convinced that Java is the better competition language for the ACM competitions, especially if you have access to Eclipse. With Java 1.6, the combination of the various collections, scanner class, and regular expressions makes it quite attractive over C++.

For example, one of the problems from the Rocky Mountain regional was to parse e-mail addresses out of a stream of ASCII text. Back in my competition days, using C++, I would have had to painstakingly encoded the various matching rules to parse the strings looking for the e-mail addresses. However, last night, one of the students quickly solved this problem with less than 10 lines of code using a regular expression for the matching in Java.

What in C++ would be an ugly set of methods, becomes the following regular expression in Java:

Pattern.compile("[A-Za-z0-9_-] (\.?[A-Za-z0-9_-])*@[A-Za-z0-9_-](\.?[A-Za-z0-9_-])*");


Also, using an IDE like Eclipse removes much of the tedium of dealing with some of Java’s rather verbose syntax. I’ve seen experienced Eclipse users rapidly produce code through a combination of typing commands and hitting CTRL+space for term completion. Eclipse will also automatically compile, fix your imports, point out syntax errors, and has an integrated interactive debugger.

About the author

Sean Falconer

1 Comment

  • I'm starting to practice for ICPC myself and decided regular expressions would GREATLY simplify some of the problems.

    Time to go brush up on my Java. See you at the Northwest Reigonals…

By Sean Falconer

Sean Falconer

Get in touch

I write about programming, developer relations, technology, startup life, occasionally Survivor, and really anything that interests me.