NUS HomeVA
Home | Up


The LORD is my shepherd, I shall not be in want. He makes me lie down in green pastures, he leads me beside quiet waters, he restores my soul. He guides me in paths of righteousness for his name's sake. Even though I walk through the valley of the shadow of death, I will fear no evil, for you are with me; your rod and your staff, they comfort me. You prepare a table before me in the presence of my enemies. You anoint my head with oil; my cup overflows. Surely goodness and love will follow me all the days of my life, and I will dwell in the house of the LORD forever. - A psalm of David, King of Israel.

This page is last updated on: 07 August 2008 12:02:39 PM

I consider this ACM ICPC live archive site: http://acmicpc-live-archive.uva.es/nuevoportal is "better" than the standard Online Judge: http://acm.uva.es/p (Both site require separate account!). It contains more up-to-date ACM ICPC World Finals and Regional contest problems, some of them can be judged, while the standard OJ only have "outdated" problems + user-based contest problems. Frankly speaking, some of the problem in volume contest can be considered as having "lesser quality" (no offence to those who created the problem set) due to poor English, ambiguity, etc.

It is very importance to emulate these past contests for any ACM ICPC team preparation. Therefore, I decide to start writing something in this section. The content of this page will be gradually added soon. Meanwhile, you can see solutions for several "easy" problems first.

No Problem Name * Algorithm

2000

Asia - Tehran (Iran) - 2000

2052 Number Steps 2.0 Ad Hoc

Europe - Southwestern (Valladolid-Spain) - 2000

2202 Vito's Family 3.0 Ad Hoc
2203 Smith Number 4.0 Ad Hoc

2001

North America - East Central - 2001

2356 Web Navigation 3.0 Stack simulation

North America - Mid Atlantic - 2001

2362 Financial Management 0.5 Ad Hoc

Africa and the Middle East - Pretoria (South Africa) - 2001

2241 Stockbroker Grapevine 3.5 Graph (All pairs shortest path)

Oceania - South Pacific - 2001

2247 Prime Digital Root 2.5 Ad Hoc

Europe - Northeastern - 2001

2450 Team them up! 4.0 Graph (Maximum Clique)
2452 Cable Master 3.5 Binary Search

2002

Oceania - South Pacific - 2002

2483 House Numbering 3.0 Math (Base Number)
2485 Vowels Frequencies 3.0 Ad Hoc

North America - South Central - 2002

2540 The Hardest Problem Ever 2.5 Ad Hoc
2542 Polar Explorer 3.5 Ad Hoc

South America - 2002

2616 I Hate SPAM, but some people love it 4.0 Special BFS
2617 Noise Effect 2.5 Brute Force

Asia - Dhaka (Bangladesh) - 2002

2697 Big Integer * Haven't try yet

2003

Oceania - South Pacific - 2003

2731 Wacmian Numbers 2.0 Math (Base Number)
2732 CD Titles 3.0 Ad Hoc
2733 Caesar Cipher 3.0 Ad Hoc

Europe - Southeastern - 2003

2759 Common Subsequence 4.0 DP (LCS)

Asia - Manila - 2003

2800 Somebody Save the Prince 4.5 Ad Hoc

Asia - Kaohsiung - 2003

2817 The Suspects 3.5 Set (Union Find)
2820 Gap Punishment Alignment Problem 6.0 DP (String Alignment with Affine Gap)

North America - Greater New York - 2003

2865 Biker's Trip Odometer 2.0 Ad Hoc
2866 Candy Sharing Game 3.0 Ad Hoc

Latin America - South America - 2003

2881 Dice 2.0 Simulation

2004

Oceania - South Pacific - 2004

3003 Jelly 2.0 Ad Hoc
3004 Change 5.0 DP (Coin Change)
3005 Necklaces 3.0 Ad Hoc
3006 Graphics 4.5 Ad Hoc
3007 Shopping * Ad Hoc (Preemptive task scheduling in OS)

Asia - Dhaka (Bangladesh) - 2004

3012 All Integer Average 3.0 Ad Hoc

North America - Rocky Mountain - 2004

3045 Gold Coins 2.0 DP

North America - Mid Central - 2004

3055 Symmetric Order 2.0 Ad Hoc
3056 Flow Layout 2.5 Ad Hoc
3055 Speed Limit 1.0 Ad Hoc

North America - East Central - 2004

3071 Relative Relatives 4.0 Ad Hoc
3077 No Brainer 0.5 Ad Hoc, bonus question

North America - East Central - 2004

3078 Alphacode 4.5 DP, but I still got WA...
3084 To and Fro 3.5 Ad Hoc

Latin America - Mexico and Central America - 2004

3093 IP Address 2.5 Math (Base Number)
3094 Boolean Expressions * BNF Grammar
3098 Power of Cryptography * Math (Big Number + Power)

Asia - Beijing (China) - 2004

3135 Argus 3.5 Simulation

Latin America - South America - 2004

3157 Grandpa is Famous 3.5 Ad Hoc

2052 - Number Steps

Figure out the pattern and then output the result accordingly.

2202 - Vito's Family

See p10041

2203 - Smith Number

See p10042

2241 - Stockbroker Grapevine

Apply all pairs shortest path algorithm (Floyd Warshall) and check which row in the adjacency matrix result in the smallest value overall... :)

2247 - Prime Digital Roots

Just implement those described in the problem definition.

2256 - Web Navigation

Simulate this problem using a stack, simple.

2362 - Financial Management

Sum all those 12 input data (using float), then divide by 12... very very simple (bonus question).

2452 - Cable Master

The only way to solve this within time limit is using binary search. First you must figure out the lower bound and upper bound of the length of the cut, then do binary search using this range to get the optimal one. Avoid floating point as far as possible.

2483 - House Numbering

Simple base number conversion, Decimal to Binary (always divide by 2), if currentValue mod 2 = 0 then totalCost add a, if currentValue mod 2 = 1 then totalCost add b. At the end, output totalCost.

2485 - Vowels Frequencies

Initially set frequencies of vowels to all 0. For each line, do linear scan and update frequencies of each vowels and then output in descending order (or alphabetically if the frequencies are tied).

2540 - The Hardest Problem Ever

Standard Caesar Cypher encryption/decryption problem. Very straightforward.

2542 - Polar Explorer

Should be very straightforward but I still encounter WA. I already choose the smallest angle (if angle > 180, set it to 360-angle)... Maybe precision error, I'll try it again later.

2616 - I Hate SPAM, but some people love it

Construct the graph, and then do BFS (with slight variation) to simulate the SPAM forwarding behavior. Then output the result.

2697 - Big Integer

Almost similar to 10219. Here you just need to find the digit of a factorial number. Use the formula below:
digit = floor[log10(number)] + 1

Look at this example and try to understand the process.
digit of 4 ! = floor [log10(4) + log10(3) + log10(2) + log10(1)] + 1

2731 - Wacmian Numbers

Simple base number conversion.
value = 0
for each char in input
  value = value * 6 + convert(char) // % to 0, ) to 1, etc
output value

2732 - CD Titles

Store all lines, if any of those lines has length > 36, truncate it. And then, just output them in reverse order. Should be very straightforward.

2733 - Caesar Cipher

Don't afraid when you see big values for shift, just modulo by 26 (for alpha characters A-Z,a-z) or modulo by 10 (for numeric 0-9), and then, just cycle each characters accordingly, for example:
newChar = 'A' + ((26 + (oldChar-'A') + shift%26) % 26)

2759 - Common Subsequence

A direct application of well known O(m*n) DP algorithm for Longest Common Subsequence.

2800 - Somebody Save the Prince

This problem is easy but tedious. You need to check through all 27 possible directions (use loops, don't do it by hand) to determine the magic password.

2817 - The Suspects

This is a simple Set problem, parse the input accordingly and build the set along the way. At the end, ask your data structure, what is the size of set containing item 0.

2820 - Gap Punishment Alignment Problem

There exist a very efficient extended DP solution using 4 m*n matrix from the original m*n DP algorithm for String Alignment / Edit Distance, this model is used in Computational Biology...

2865 - Biker's Trip Odometer

Very very straightforward...

2866 - Candy Sharing Game

Brute force is possible. Just simulate the problem. It shouldn't exceed time limit.

2881 - Dice

Direct simulation.

3003 - Jelly

Read the input and for each child's mould, compute the volume and sum them up. Then, compute the average volume. Do one more loop, if you encounter one child with mould's volume < average volume, then you know that the cleaner mess up something. Since it already simplified in the input that there can only be exactly one such pair, find another child in the list that have mould's volume > average volume, output this pair.

3004 - Change

Round the values and check trivial cases (Exact amount, or Not enough money), and then use DP to solve the third case (when you need to answer the minimum notes/coins required for the change).

3005 - Necklaces

Brute force, just try all 4 possibilities and then output the lowest and highest possible values:
(forward and B=0/W=1)
(forward and B=1/W=0)
(backward and B=0/W=1)
(backward and B=1/W=0)

3006 - Graphics

It is a bit hard to see the pattern, but once you figure it out, this problem become trivial. You only need to store 1 cell, modify this cell according to the moves given.

3007 - Shopping

This problem is well known as pre-emptive task scheduling in Operating System concept. Sort the task/shopping list according to their duration (use priority queue) and then advance time according to the arrival time of the next tasks/customers. If new task has duration < the remaining duration of current task, preemptive this and put the current task (with the remaining duration) in the priority queue and process the new task. This greedy strategy will lead to optimal solution.

3012 - All Integer Average

Straightforward problem.

3045 - Gold Coins

Simple problem, but to avoid re computation, save the result into a memoization array (precalculate), and then output the answers when required.

3055 - Symmetric Order

Prepare two array, one for the input, one for the output. Initially, let topIndex=0 and bottomIndex=n-1, then as you read the input, add every odd lines to output[topIndex] and then increase topIndex by 1, add every even lines to output[bottomIndex] and then decrease bottomIndex by 1. Very simple.

3056 - Flow Layout

Should be quite straightforward since the order of placement is totally fixed... Just place the items according the problem specification and update the window width and height respectively.

3059 - Speed Limit

Another problem that can be solved in under 5 minutes... Very straightforward.

3071 - Relative Relatives

Should be just a simple counting problem. Iterate through each person name and update their age until all ages are determined. Then output them in decreasing order of age... I'll fix my WA solution later...

3077 - No Brainer

I bet you can solve this in under 5 minutes...

3078 - Alphacode

A Dynamic Programming problem since it contains overlapping optimal sub-problems.
Let numWay(suffixIndex) returns number of way to decode the input's suffix: str[suffixIndex..length-1],
Then numWay(suffixIndex+1) + numWay(suffixIndex+2) with proper pruning and memoization will be the answer. I still got WA though... I will fix my solution later.

3084 - To and Fro

A well known encryption/decryption scheme... Need some time to figure out the correct pattern, but once you figure it out, this problem is easy.

3093 - IP Address

A simple base conversion problem. Read the string, read per 8 characters and convert binary to decimal. Output the result in dotted decimal format.

3094 - Boolean Expressions

If you are familiar with Recursive Descent Parser, you should be able to solve this problem easily. Formulate the BNF grammar for the Boolean expression and evaluate them.

3098 - Power of Cryptography

A familiar problem, but you need to use Big Number (up to 10^101) and some tricks... I haven't solve this anyway.

3135 - Argus

Simulation using Priority Queue.

3157 - Grandpa is Famous

A simple ranking problem. Set up an Integer array of 10000 elements, all initialized to 0. Increment the values every time a player is in the weekly chart. At the end, use one pass to determine the highest occurrence, use another pass to determine the second highest excluding the highest, and use the third pass to this Integer array to print out players with occurrence = second highest.


This document, volArchive.html, has been accessed 9911 times since 25-Oct-03 15:12:11 SGT. This is the 4th time it has been accessed today.

A total of 4931 different hosts have accessed this document in the last 1781 days; your host, 38.103.63.60, has accessed it 1 times.

If you're interested, complete statistics for this document are also available, including breakdowns by top-level domain, host name, and date.