2011 ACM-ICPC
Test Cases and Solution Guide of Practice Problems (3 November 2011)
Practice problems (pdf file)
Problem A. Reverse and Sort
Solution guide
In this
problem, you need integer variables larger than 4 bytes. A 64-bit integer (C++ long long type) is enough to contain the value 10^12. The process of this program is quite
straight forward. You may use an array to store all the input integers and then
reverse each value and finally sort the array.
An
example of C++ solution program is here.
Test Cases
Input |
Output |
n=10012,
input_file size = 55 KB |
output_file size = 55 KB, 10012 lines |
10012
5 2233 1601
90100 13009 802 50000000 301
7654321 210
12345678901 12345678909 12345678910 13631 23701 31570 12049 14686 27011 27875 25739 172 ... |
1 1 2 2 3 3 4 4 5 5 5 5 5 6 6 ... |
Problem B. Line of Best Fit
Solution guide
This problem
is a little bit tricky. If you have knowledge about linear regression or least
square method, you may have the solution formula for a and b. They can also be derived using calculus.
The line of minimum error is y=ax+b, where
Otherwise, you need to find a way to
estimate the value of a and b and adjust the two values until you reach the
minimum error. An example of C++ solution program is here.
Test Cases
Input |
Output |
n=11,
input_file size < 1 KB |
output_file size < 1 KB, 2 lines |
11 9
260 13
320 21
420 30
530 31
560 31
550 34
590 25
500 28
560 20
440 5
300 |
11.731 193.852 |
Problem C. Software Licenses
Solution guide
You may
solve this problem by setting up a cost function and then minimize it by
brute-force method or by dynamic programming.
Test Cases
Input |
Output |
n=17,
input_file size < 1 KB |
output_file size < 1 KB, 1 line |
17 720 1.102 650 1.1 501.2 1.108 854.14
1.05 330 1.125 300 1.12 250 1.102 800 1.03 400 1.05 250 1.05 450 1.015 641.1 1.01 280 1.011 300 1.008 200 1.01 210 1.005 150 1.003 |
8995.90 |
Problem creator of problem A, B and C : Seksun Suwanmanee, Dept. of Computer Engineering, Prince of Songkla
University,
Problem D. Crucial Links
Problem creator: Jittat Fakcharoenphol,
Dept. of Computer Engineering,
Problem type: Graph
Solution guide
Explanation
of the third case in the sample input is decribed as below.
The maximum bandwidth is 5.
• You can still transmit with maximum bandwidth 5
when changing the bandwidth of a link from Router 2 to Router 4 to 1, so that
link is not crucial.
• You can still transmit with maximum bandwidth 5
when changing the bandwidth of a link from Router 3 to Router 4 to 3, so that
link is not crucial.
• You can still transmit with maximum bandwidth 5
when changing the bandwidth of a link from Router 2 to Router 3 to 9, so that
link is not crucial.
• You can still transmit with maximum bandwidth 5
when changing the bandwidth of a link from Router 3 to Router 2 to 9, so that
link is not crucial.
Thus, there are 3 crucial links.
An example of C++ program (slow version) without
time minimizing algorithm is here.
The solution program with much less time is here.
Test Cases
Input |
Output |
K=15,
input_file size = 418 KB |
output_file size < 1 KB, 15 lines |
15 300
5000 160
270 2 86
116 3 143
40 7 190
152 1 50
271 6 237
248 2 281
46 1 84
65 4 166
299 4 124
239 5 254
77 5 115
199 3 116
238 2 278
202 2 213
207 5 212
159 3 57
138 5 273
115 5 29
274 3 238
196 7 |
18 122 78 7 3 19 7 11 9 15 92 206 112 108 120 |
Last Update: 2011-11-22