Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 S1
Index -> Contests
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
HeavenAgain




PostPosted: Tue Feb 27, 2007 11:46 pm   Post subject: S1

S1
problem description
for the big election on february 27 2007, the government has commissioned an electronic voting system, and you have been hired as a sub-subcontractor for this very grand programming project.

your task is to write the system that determines whether a given person is old enough to vote. the voting age is 18, so given someone's birthday, you must determine whether that person will be 18 years of age on the day of the election

input specification
the input will consist of a number n(1<= n <= 100) on a single line, indicating the number of birthdays to evaluate. then, each of the following n lines, will be of the form y m d, where y is the year of a potential voter's birth ( 0<= y <= 2007), m (1 < = m <= 12) is the month of birth, and d ( 1 <= d <= 31) is the day, it is assured that each birthday is correct and valid date.

output specification

for each date in the input, output a line with either "yes" if the voter is eligible to vote, or "no" other wise

Sample input
5
1933 10 29
1989 2 28
1961 11 23
1999 12 31
1989 2 27

sample output

yes
no
yes
no
yes
Sponsor
Sponsor
Sponsor
sponsor
HeavenAgain




PostPosted: Tue Feb 27, 2007 11:58 pm   Post subject: Re: S1

S2

problem description
nowadays, almost any item can be bought and sold on the internet. the problem is shipping. before an item can be sent, it must be carefully packaged in a cardboard box to protect it.

while items come in many shapes and sizes, finding a box just the right size can be a problem. if the box is too small, the item will not fit. if the box is unnecessarily big, shipping cost will be higher, and the item is more likely to move around inside the box, and it may break.

cardboard box manufacturers offer a fixed set of standard box sizes. your task is to find the standard box size with the smallest volume into which an item will fit.

each box is a rectangular prism with a given length, width, and height. each item is also a rectangular prism with a given length, width, and height. and item may be rotated by multiples of 90 degrees in any direction before being packed into a box, but when it is packed, its faces must be parallel to the faces of the box. an item will fit into a box as long as its dimensions are equal to or less than the dimensions of the box


input specification
the first line of input will contain a single integer n, 0 < n < 1000, the number of different sizes of boxes available. the next n lines will contain three integers each, giving the length, width, and height of a box. the following line will contain a single integer m , 0 < m < 1000, the number of items to be packaged. the next m lines will contains three integers each, giving the length, width, and height of an item. all dimensions will be in millimetres and in the range from 1 mm to 2000 mm


output specification
output is to consist of m lines, one for each item in the input. for each item,, output a line containing a single integer, the volume (in mm^3) of the smallest box into which the item will fit. the same size of box may be reused for any number of items. if an item does not fit in any box, print the line: item does not fit.


sample input

3
1 2 3
2 3 4
3 4 5
5
1 1 1
2 2 2
4 3 2
4 3 3
4 4 4

output for sample input
6
24
24
60
item does not fit.
HeavenAgain




PostPosted: Wed Feb 28, 2007 12:13 am   Post subject: Re: S1

S3
friends


problem description
in a certain school, it has been decided that students are spending too much time studying and not enough time socializing, to address thsi situation, it has been decided to give every student a friend. friendship is one-way. that is, if Janet is assigned to be Sarah's friend, Janet must be friendly to Sarah, but Sarah is not required to reciprocate.

the assignment of friends is done by computer using student numbers. every student is assigned exactly one friend. sometimes, a 'circle of friends' occurs. for example, if Marc is assigned Fred, Fred is assigned Lori, Lori is assigned Jean, and Jean assigned Marc, we have a circle of 4 friends containing Marc, Fred, Lori , and Jean, in the circle, we can say that Marc has a separation of 0 from Fred, of 1 from Lori, of 2 from Jean, and of 3 from Marc

your task it to identify, given the computer assignment of friends, whether two students are in the same circle of friends, and if so, determine their separation

input specification
input begins with a single integer n (2 <= n <=9999) , on a line by itself, indicatiing the number of students in the class. the next n lines contain the computer assignment of friendship. an assignment is of the form x y (where 1 <= x <=n, 1 <= y <=n, x not = y). for example, 1234 8765 is a possible friendship assignment indicating that student 1234 must be friends with student 8765

following the friendship assignments, there are a series of lines containing two student numbers, separaed by a single whitespace. these lines represent the pairs of students that you will determine if they are in the same circle of friends and, if so, their separation. the last line of unput can be identified by the use of the 0 0 as the friend assignment.

output specification
for each case, you are to print, on a separate line, either yes or no depending on whether they are in the same circle of friends. if the answer is yes, follow the output yes with a single white space and then an integer indicatig the friend's separation.


sample input

6
1 2
2 3
3 1
10 11
100 10
11 100
1 100
2 3
0 0

output for sample input
no
yes 0
zylum




PostPosted: Wed Feb 28, 2007 12:15 am   Post subject: Re:s1

thanks for taking the time and posting these Wink keep em coming Very Happy
HeavenAgain




PostPosted: Wed Feb 28, 2007 12:28 am   Post subject: Re: S1

S4
waterpark

problem description

the local waterpark has a great slide complex, with many paths crisscrossing down the hill. there is one start point and one end point, but at various points one can turn and take different paths. walter and wanda are wondering exactly how many different ways there are to go down the slide. can you solve their problem?

more precisely, there are n marked points (including the start at 1 and the end at n) where the paths down the hill may split or merge. all paths move down the hill to higher numbered positions; some paths will actually cross over others without meeting but we dont have to worry about that. we wont worryy about the collisions between sliders that can happen either. our problem is simply to determine the number of different sequences of marked points we can follow down the hill

for example, at one small waterpark, there are 4 points with direct slides from 1 to points 2 and 4; from 2 to 3 and 4; and from 3 to 4. there are 3 ways down the hill. you can check this by seeing that we can go (1,2,3,4),(1,2,4),or(1,4)

(here is a hint: think about starting at the bottom of the slide.)


input specification
input begins with a single integer n (1<= n <= 9999), on a line by itself, indicating the number of marked pints. the next n lines contain point pairs of the of the form x y, where 1 <= x < y <=n. for example, 1234 8765 indicates a direct slide from point 1234 to point 8765. the last line of input will be indicated by point pair 0 0.

output specification
the output is an integer, which is the number of different paths from point 1 to point n. you can assume that the number of paths will be less than 2^30, it is possible that there is no path from point 1 to point n, in which case the number of paths is 0


sample input

4
1 2
1 4
2 3
2 4
3 4
0 0

output for sample input
3
HeavenAgain




PostPosted: Wed Feb 28, 2007 12:39 am   Post subject: Re: S1

s5

bowling for numbers

problem description

at the canadian carnival competition (CCC), a popular game is bowling for numbers. a large number of bowling pins are lined up in a row. each bowling pin has a number printed on it, which is the score obtained from knocking over that pin. the player is given a number of bowling balls; each bowling ball is wide enough to knock over a few consecutive and adjacent pins

for example, one possible sequence of pins is : 2 8 5 1 9 6 9 3 2

if the alice was given two balls, each able to knock over three adjacent pins, the maximum score alice could achieve would be 39, the sum of two throws: 2 + 8 + 5 = 15 , and 9 + 6 + 9 = 24.

bob has a strategy where he picks the shot that gives him the most score, then repeatedly picks the shot that gives him the most score from the remaining pins. this strategy doesn't always yield the maximum score, but it is close. on the test data, such a strategy would get a score of 20%

input specification

input consists of a series of test cases, the first line of input is t, 1 <= t <= 10, indicating the number of test cases in the file, the first line of each test case contains three integers n k w. first is the integer n, 1 < = n <= 30000, indicating the number of bowling pins. the second integer, k, 1 <= k <= 500, giving the number of bowling balls available to each player. the third and final integer is w, 1 <= w <= n, the width of thw bowling ball (the number of adjacent pins it can knock over). the next n lines of each test case each contain a single non-negative integer less than 10000, giving the score of the pins, in order. 20% of the test data will have size n <=50.

output specification

for each test case, output the maximum achievable score by the player. this score is guaranteed to be less than one billion.

sample input

1
9 2 3
2
8
5
1
9
6
9
3
2

output for sample input

39
HeavenAgain




PostPosted: Wed Feb 28, 2007 12:42 am   Post subject: Re:s1

zylum @ Wed Feb 28, 2007 12:15 am wrote:
thanks for taking the time and posting these Wink keep em coming Very Happy

noo problem... it was quite tiring ..... BUT is worth it! hope for those of you who didnt join can still have some little experience of it at home
Amailer




PostPosted: Wed Feb 28, 2007 3:33 pm   Post subject: Re:s1

Eee! Thank you
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Wed Feb 28, 2007 3:37 pm   Post subject: Re:s1

Muchly appreciated. +Bits +Karma. Thank you.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Clayton




PostPosted: Wed Feb 28, 2007 6:24 pm   Post subject: Re: S1

What about me?
Tony




PostPosted: Wed Feb 28, 2007 7:34 pm   Post subject: Re:s1

HeavenAgain has an earlier timestamp Razz And apparently I've got a time limit for giving out karma... Dan?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Clayton




PostPosted: Wed Feb 28, 2007 7:39 pm   Post subject: Re: S1

But this wasn't in the list of recent stuff, and the new posts icon wasn't up... I blame this on Dan... fix it Razz

EDIT: and just for the record, I sent the problems to another user at ~10 pm last night, but was having problems trying to post them, so I waited until today.
PaulButler




PostPosted: Wed Feb 28, 2007 9:16 pm   Post subject: Re: S1

Freakman @ Wed Feb 28, 2007 7:39 pm wrote:
But this wasn't in the list of recent stuff, and the new posts icon wasn't up... I blame this on Dan... fix it Razz

EDIT: and just for the record, I sent the problems to another user at ~10 pm last night, but was having problems trying to post them, so I waited until today.


Ok, I gave you some bits and karma. I know my karma isn't as good as Tony's, but it's the best I can do . Smile
Clayton




PostPosted: Thu Mar 01, 2007 10:51 am   Post subject: Re: S1

I was really only kidding... but thanks Very Happy
Display posts from previous:   
   Index -> Contests
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 14 Posts ]
Jump to:   


Style:  
Search: