ICL 2010 Advantage Round Question Paper

20
[Cover Page] 10101001010101010101010110101010101001010101010101010110101010101001010101010101 01011010101010100101010101010101011010101010100101010101010101011010101010100101 01010101010101101010101010010101010101010101101010101010010101010101010101101010 10101001010101010101010110101010101001010101010101010110101010101001010101010101 01011010101010100101010101010101011010101010100101010101010101011010101010100101 01010101010101101010101010010101010101010101101010101010010101010101010101101010 10101001010101010101010110101010101001010101010101010110101010101001010101010101 01011010101010100101010101010101011010101010100101010101010101011010101010100101 01010101010101101010101010010101010101010101101010101010010101010101010101101010 10101001010101010101010110101010101001010101010101010110101010101001010101010101

description

ICL 2010 was conducted during Apogee 2010. The coding contest involved solving output only problems. Use of any programming language was allowed. This is the problem set for advantage round.

Transcript of ICL 2010 Advantage Round Question Paper

Page 1: ICL 2010 Advantage Round Question Paper

[Cover Page]

10101001010101010101010110101010101001010101010101010110101010101001010101010101 01011010101010100101010101010101011010101010100101010101010101011010101010100101 01010101010101101010101010010101010101010101101010101010010101010101010101101010 10101001010101010101010110101010101001010101010101010110101010101001010101010101 01011010101010100101010101010101011010101010100101010101010101011010101010100101 01010101010101101010101010010101010101010101101010101010010101010101010101101010 10101001010101010101010110101010101001010101010101010110101010101001010101010101 01011010101010100101010101010101011010101010100101010101010101011010101010100101 01010101010101101010101010010101010101010101101010101010010101010101010101101010 10101001010101010101010110101010101001010101010101010110101010101001010101010101

Page 2: ICL 2010 Advantage Round Question Paper

[Problem List]

The questions with credits enclosed within brackets can now be submitted within 24 hours of

start of the contest for complete credit. [Instead of 3 hours as mentioned in the question paper]

The contest will now run for 36 hours instead of scheduled 24 hours.

# Problem Description Name Credits

1 Addition of Big Numbers addition 12

2 Powered Fractions fractions [14]

3 Playing With Fibonacci Numbers fibonacci 14

4 Playing With Tiles tiling 25

5 Three Way Partitions cookies [35]

6 More Players In The Game choice [35]

7 Chocolate Cookies chocolate 50

8 The Winner Takes It All winner 50

9 Poof Go Clouds clouds [100]

10 Pyramids - Pyramids pyramids [165]

Page 3: ICL 2010 Advantage Round Question Paper

[Instructions]

Instructions

1. There are ten questions in this question set. For each question download the input files. Write your program in any language of your choice and submit the output files. See ‘Submission Formalities’ at the end for instructions on how to submit the output files.

2. The total credits possible in this paper are 500.

3. There are credits allocated per problem for solving it completely.

4. Complete credits for some problems can only be scored if the solution is submitted within the specified time period. So, be careful in choosing which questions to solve first.

5. These problems have their credits enclosed within square brackets..

6. Each question has a problem statement, input format, output format and problem details.

7. Please follow the given output format strictly. An automatic evaluator will verify your output files. It will treat incorrect format as wrong output. See submission formalities at the end.

8. Each question has 10 input files each.

9. For any clarifications please use the contact details given on the next page.

Any general clarification will also be posted on the contest page.

Page 4: ICL 2010 Advantage Round Question Paper

[Instructions]

Contact Details

Event Manger

Mayank Abhishek +91-97720-18000

+91-95294-04955

Page 5: ICL 2010 Advantage Round Question Paper

[Problem #1]

12 Credits

Addition of Big Numbers

Problem Statement: Poorva lives in 2050 AD. She is learning addition of two numbers. Her teacher like any other teacher expects her to learn addition by solving a lot of sums. He has given Poorva a set of addition problems to solve. But, being in the future each number in the problem set is of 20 digits. Help Poorva by solving this exercise for her.

Input Format: The first line of the input file contains an integer N. N is the number of problems in that file. The next N lines of the file contain two space separated integers each Ai and Bi. The ith sum is Ai + Bi.

Output Format: Each output file should contain N lines where the ith line contains the sum Ai + Bi.

Problem Details:

Problem name: addition N ≤ 5 1020 ≤ Ai , Bi , Ai + Bi < 1021 Each input file carries 1 credit 2 more credits will be awarded, only if all 10 input files are solved correctly

Sample Input:

3

12345678901234567890 12345678901234567890

23432432213421432432 23432423423423432542

12312445354656576576 43534534657012123343

Sample Output:

24691357802469135780

46864855636844864974

55846980011668699919

Page 6: ICL 2010 Advantage Round Question Paper

[Problem #2]

[14] Credits

Powered Fractions

Problem Statement: Poorva next learns how to compare fractions. She has got a list of fractions and she is supposed to find out the largest fraction amongst them. Help Poorva by solving this exercise for her. The fractions may or may not be in reduced form.

Input Format: The first line of the input file contains a single integer C. Where C is the number of fractions in the file. The next C lines contain 2 space separated integers each, Ni and Di,

where the ith fraction is

.

Output Format:

Each output file should contain 2 space separated integers N and D, where

is the

largest fraction in the list in reduced form.

Problem Details:

Problem name: fractions C ≤ 30 0 ≤ Ni < Di ≤ 10000 Each input file carries 1 credit 2 more credits will be awarded, only if all 10 input files are solved correctly 2 more credits will be awarded, only if a completely correct solution is submitted

within 3 hours of start of the contest

Sample Input:

5

2 3

4 5

198 200

9 10

1 2

Sample Output:

99 100

Page 7: ICL 2010 Advantage Round Question Paper

[Problem #3]

14 Credits

Playing With Fibonacci Numbers

Problem Statement: Poorva loves playing with Fibonacci numbers. The Fibonacci numbers are 1, 1, 2, 3, 5, 8, 13, 21 ……….. Look up on Wikipedia if you don’t know about Fibonacci numbers. Given N she is very curious to know what will be the Nth Fibonacci number. Unlike her teacher Poorva hates big numbers so she wishes to know only the last 4 digits of the Nth Fibonacci number. Help Poorva by finding the last 4 digits of the Nth Fibonacci number.

Input Format: The input file contains a single integer N.

Output Format: Output file should contain a single integer K. Where, K is the last 4 digits of the Nth Fibonacci number. If K is 0093 report it as 93.

Problem Details:

Problem name: fibonacci N ≤ 106 Each input file carries 1 credit 4 more credits will be awarded, only if all 10 input files are solved correctly

Sample Input #1:

5

Sample Input #2:

5000

Sample Output #1:

5

Sample Output #2:

3125

Page 8: ICL 2010 Advantage Round Question Paper

[Problem #4]

25 Credits

Partly based on the problem Architect v/s Mason, INOI Training Camp 2006 Day 1

Playing With Tiles

Problem Statement: Poorva has a doll house of dimensions 2 x N. For her birthday she got an unlimited supply of 2 x 1 decorative tiles as a gift. She can decorate her doll house by laying these tiles either horizontally or vertically. Poorva is very interested in knowing the number of ways in which she can tile her 2 x N dollhouse. For example if N is 3 then there are 3 possible ways of tiling the room, they are shown below. Help Poorva by finding the total number of possible tiling of her 2 x N doll house. Since the number of possible tiling can very easily grow into large numbers (and Poorva hates big numbers), report only the last 5 digits of the answer to keep Poorva happy.

Input Format: The input file contains a single integer N.

Output Format: Output file should contain a single integer K. Where, K is the last 5 digits of the total number of possible tiling of her 2 x N dollhouse.

Problem Details:

Problem name: tiling N ≤ 108 Each input file carries 2 credits 5 more credits will be awarded, only if all 10 input files are solved correctly

Sample Input #1:

3

Sample Input #2:

5

Sample Output #1:

3

Sample Output #2:

8

Page 9: ICL 2010 Advantage Round Question Paper

[Problem #5]

[35] Credits

Three Way Partitions

Problem Statement: Poorva best likes the tiling of her doll house in which all tiles are vertical. So she decides to play a game with her friend Ishaan on that tiling. [Tiling is described in Problem #4] In the game Poorva places a placard with a positive or a negative integer on each tile. Ishaan has splitters which he can place between two tiles. A splitter is used to divide the tiling in sets. For example using one splitter the tiling can be divided into 2 sets. Using 2 splitters the tiling can be divided into three sets. Ishaan has 2 splitters. After Ishaan has placed the splitters, Poorva will get cookies equal to the sum of numbers in one of the sets. Since, Poorva is very intelligent she will always choose the set with the maximum sum. If the sum is negative she gets no cookies. Since, Ishaan had a fight with Poorva he would like her to have the least possible number of cookies. Given the layout of numbers put by Poorva help Ishaan by finding the least possible number of cookies Poorva can win. For example if Poorva has a dollhouse of size 9 and the numbers placed by her are 1, 2, -3, 4, 5, 6, -7, 9, 10. Then the best Ishaan can do is place splitters between 5, 6 and 9, 10. This will make three sets of sum 9, 8 and 10 respectively as 1, 2, -3, 4, 5] [6, -7, 9] [10.

Input Format: The first line of the input file contains a single integer N. The next line contains N space separated integers i, where the ith integer is the number placed on tile i.

Output Format: Output file should contain a single integer K. Where, K is the minimum number of cookies which can be won by Poorva.

Problem Details:

Problem name: cookies N ≤ 5000 Each input file carries 2 credits 5 more credits will be awarded, only if all 10 input files are solved correctly 10 more credits will be awarded, only if a completely correct solution is

submitted within 3 hours of start of the contest

Page 10: ICL 2010 Advantage Round Question Paper

[Problem #5]

[35] Credits

Sample Input:

9

1 2 -3 4 5 6 -7 9 10

Sample Output:

10

Page 11: ICL 2010 Advantage Round Question Paper

[Problem #6]

[35] Credits

More Players In The Game

Problem Statement: More of Poorva’s friends join her in the game. [The game is described in Problem #5] Now there are a large number of splitters placed on the tiling. So Poorva has a very large number of sets to choose from. Help Poorva to make the best choice by finding the maximum number of cookies she can win.

Input Format: The first line of the input file contains a single integer N. The next line contains N space separated integers i, where the ith integer is the number placed on tile i or a splitter. ‘0’ represents a splitter.

Output Format: Output file should contain a single integer K. Where, K is the maximum number of cookies which can be won by Poorva.

Problem Details:

Problem name: choice N ≤ 106 Each input file carries 2 credits 5 more credits will be awarded, only if all 10 input files are solved correctly 10 more credits will be awarded, only if a completely correct solution is

submitted within 3 hours of start of the contest

Sample Input:

14

1 -1 3 0 1 2 3 0 7 11 0 2 11 -2

Sample Output:

18

Page 12: ICL 2010 Advantage Round Question Paper

[Problem #7]

50 Credits

Partly based on Problem#5, ZIO 2003

Chocolate Cookies

Problem Statement: Poorva has gone to Ishaan’s house to play. Ishaan has a very elaborate model of a city to play with. His city is in the form of an M x N matrix with each block of size 1 x 1.

A sample model is shown on the left. This is a 4 x 5 city, i.e. there are four horizontal roads and 5 vertical roads. Every road in Ishaan’s city is one way. Roads either run left to right or top to bottom. It is not possible to travel in the opposite direction. The orange intersections are blocked and it is not possible to

cross them. Poorva is standing at the Red intersection and chocolate cookies are placed at the Green one. Poorva can win the cookies only if she can find the total number of ways of reaching them. In this example it is 3. Given the map of the city, help Poorva by finding the number of ways of reaching the cookies. Since Poorva hates big numbers report only the last 4 digits of the answer.

Input Format: The first line of the input file contains three space separated integers M, N and K. Where M is the number of horizontal roads and N is the number of vertical roads. K is the number of blocked intersections. The next K lines describe the location of blocked intersections. The K lines contain two space separated integers R and C. Describing the Row and Column coordinate of the blocked intersections. Poorva is at 1,1 and the Cookies are at M,N.

Output Format: Output file should contain a single integer K. Where, K is the last 4 digits of total number of ways of reaching the cookies.

Problem Details:

Problem name: chocolate 1 ≤ M, N, K ≤ 5000 Each input file carries 4 credits 10 more credits will be awarded, only if all 10 input files are solved correctly

Page 13: ICL 2010 Advantage Round Question Paper

[Problem #7]

50 Credits

Partly based on Problem#5, ZIO 2003

Sample Input:

4 5 3

2 3

3 2

3 4

Sample Output:

3

Page 14: ICL 2010 Advantage Round Question Paper

[Problem #8]

50 Credits

Based on the problem Advertising Hoardings, INOI Training Camp 2006 Day 11

The Winner Takes It All

Problem Statement: Roads of Ishaan’s city are lined by continuous high rise buildings. [The city is described in Problem #7]. Each building has a width and a height. The winner of the game from the previous question can claim any continuous rectangular area along the walls of the buildings facing the central road as their own and use it to paint their name on it. For example if there are 5 building along the central road of heights 4, 6, 7, 2 and 5 and widths 2, 3, 2, 3 and 3. Then the winner can for example claim the area of height 2 and width 13 spanning all buildings. The largest area which can be claimed is of height 4 and width 7 spanning the first 3 buildings. Poorva has won the game and would like to have the largest possible area for displaying her name. Given the widths and heights of buildings help Poorva by finding the largest possible area she can have.

Input Format: The first line of the input file contains a single integer N, the number of buildings. The next N lines describe the buildings. Each of the next N lines contains two space separated integers W and H, specifying the width and height of the buildings.

Output Format: Output file should contain a single integer K. Where, K is the maximum area which can be claimed by Poorva.

Problem Details:

Problem name: winner N ≤ 5000 Each input file carries 4 credits 10 more credits will be awarded, only if all 10 input files are solved correctly

Page 15: ICL 2010 Advantage Round Question Paper

[Problem #8]

50 Credits

Based on the problem Advertising Hoardings, INOI Training Camp 2006 Day 11

Sample Input:

5

2 4

3 6

2 7

3 2

3 5

Sample Output:

30

Page 16: ICL 2010 Advantage Round Question Paper

[Problem #9]

[100] Credits

Poof Go Clouds

Problem Statement: Ishaan can conjure clouds over his city. [The city is described in Problem #7]. A cloud can span more than one block. The density of a cloud can vary from block to block. Poorva can throw bolts of lightning at the clouds. Whenever these bolts hit a cloud it causes rain. Denser and bigger clouds produce heavy rains. The city is described as an M x N grid of the integers. The value at each grid point represents the cloud density over that block. A value of ‘0’ indicates no cloud. Each grid point has 4 neighbours. Top, bottom, left and right on the map. A cloud is a continuous group of positive integers. The average density of a cloud is the sum of densities it has at each block divided by the total number of blocks it spans. Poorva likes to cause heavy rain. She would like to know how many clouds are there which will cause heavy rain. For a cloud to cause heavy rain its average density has to be more than or equal to D and size more than or equal to S.

Input Format: The first line of the input file contains four space separated integers M, N, D and S. Where M is the number of rows and N is the number of columns in the map of the city. D is minimum density required for a heavy cloud. S is the minimum size of a heavy cloud. The next M lines have N space separated integers each. The value at coordinate i, j is the cloud density over that block.

Output Format: Output file should contain a single integer K. Where, K is the number of clouds capable of causing heavy rain.

Problem Details:

Problem name: clouds 1 ≤ M, N, D, S ≤ 5000 Each input file carries 4 credits 10 more credits will be awarded, only if all 10 input files are solved correctly 50 more credits will be awarded, only if a completely correct solution is

submitted within 3 hours of start of the contest

Page 17: ICL 2010 Advantage Round Question Paper

[Problem #9]

[100] Credits

Explanation of The Sample Input and Output:

There are 4 clouds in this map 1 1 1 0 2 1 0 0 0 0 0 0 3 3 0 0 4 0 0 0

Si: [1: 4], [2:1], [3:2] and [4:1] Di: [1: 3.5], [2:5], [3:5] and [4:2] Thus there are 2 clouds with S ≥ 2 and D ≥ 3

Sample Input:

4 5 3 2

1 6 3 0 5

4 0 0 0 0

0 0 3 7 0

0 2 0 0 0

Sample Output:

2

Page 18: ICL 2010 Advantage Round Question Paper

[Problem #10]

[165] Credits

Pyramids - Pyramids

Problem Statement: Poorva and Ishaan each have a very nice collection of triangular plates. They stack these plates one upon the other to make pyramids. Each plate has a unit’s thickness. They both participate in a pyramid building competition. The rules of the competition state that a plate can be placed on another only if the lower plate is capable of superimposing the upper plate. In simpler words no plate should extend beyond the boundaries of the plates placed below them. Thus a plate having side lengths 3,2,2 can be placed on a plate of sides 3,4,5 but not on one of sides 8,8,1. Poorva knows the dimensions of all of Ishaan’s plates. She would like to know what can be the maximum number of plates Ishaan can use in his pyramid. She would like to make a taller pyramid than Ishaan. Help Poorva by finding the maximum possible height of Ishaan’s pyramid, given the dimensions of his plates.

Input Format: The input file contains a single integer N. The next N lines contain three space separated integers each, describing the lengths of the three sides of the ith plate.

Output Format: Output file should contain a single integer K. Where, K is the height of the tallest pyramid which can be made by Ishaan.

Problem Details:

Problem name: pyramids N ≤ 8000 Each input file carries 10 credits 15 more credits will be awarded, only if all 10 input files are solved correctly 50 more credits will be awarded, only if a completely correct solution is

submitted within 3 hours of start of the contest

Page 19: ICL 2010 Advantage Round Question Paper

[Problem #10]

[165] Credits

Explanation of The Sample Input and Output:

Ishaan can stack the plates in order [3,2,2] upon [3,4,5] upon [10,6,6] upon [6,8,10] to make a pyramid of height 4 units

Sample Input:

5

10 6 6

3 4 5

6 8 10

12 13 5

3 2 2

Sample Output:

4

Page 20: ICL 2010 Advantage Round Question Paper

[Submission Formalities]

Submission Formalities

For submitting make a directory with the problem name For example for Problem #1 make a directory with name addition For each input file 0.in, 1.in ….. 9.in produce the respective output files 0.out,

1.out….. 9.out Zip the directory addition as addition.zip Rename addition.zip as Teamname_addition.zip, replace Teamname with your

team’s name. Do this for each problem. Submit the files Teamname_problemname.zip (containing the output files

0.out, 1.out……. 9.out) only

For submission email the files to [email protected]