To do well at programming of this sort, it is important to practice. Archives of programming contest problems can be found at various WWW sites. And, the problems appearing in the past few years at the ICPC World Final's can be located in another archive. Past problems appearing at the SE USA region programming are available:
Advice and guidelines [PDF] to people creating problems can be found in a paper by Tom Verhoeff.
In what follows we present two problems with their solutions in several languages.
The problem “North and South” appeared in the 1998 SER contest held at the University of Florida.
Here is the solution to the problem in various languages (note that these languages are not necessarily ones used at regional or world final contests):
Language | Program | HTML'ized | compile | execute |
---|---|---|---|---|
Ada | north.adb | north.adb | gnatmake -o north north.adb | ./north < north_000.in > north_000.out |
C | north.c | north.c | gcc -lm -o north north.c | ./north < north_000.in > north_000.out |
C++ | north.cpp | north.cpp | g++ -lm -o north north.cpp | ./north < north_000.in > north_000.out |
C# | North.cs | North.cs | mcs North.cs | mono North.exe < north_000.in > north_000.out |
Haskell | north.hs | north.hs | ghc -o north north.hs | ./north < north_000.in > north_000.out |
Java | North.java | North.java | javac North.java | java North < north_000.in > north_000.out |
Pascal | north.pas | north.pas | gpc -o north north.pas | ./north < north_000.in > north_000.out |
Python | north.py | north.py | (do nothing) | python north.py < north_000.in > north_000.out |
These programs read from the standard input stream and write to the standard output stream.
Some test data:
Here is the solution to the problem in various languages (note that these languages are not necessarily ones used at regional or world final contests):
Language | Program | HTML'ized | compile | execute |
---|---|---|---|---|
Ada | rare.adb | rare.adb | gnatmake -o rare rare.adb | ./rare < rare_000.in > rare_000.out |
C | rare.c | rare.c | gcc -lm -o rare rare.c | ./rare < rare_000.in > rare_000.out |
C++ | rare.cpp | rare.cpp | g++ -lm -o rare rare.cpp | ./rare < rare_000.in > rare_000.out |
Java | Rare.java | Rare.java | javac Rare.java | java Rare < rare_000.in > rare_000.out |
Haskell | rare.hs | rare.hs | ghc -o rare rare.hs | ./rare < rare_000.in > rare_000.out |
Python | rare.py | rare.py | (do nothing) | python rare.py < rare_000.in > rare_000.out |