Sei sulla pagina 1di 11

Knight Coders

Computer Technicals, Aranya 2008


Rules:
Scoring: The algorithm used Rank and “Score” (Penalty Points) is the one used in the ACM
ICPC World Finals, which is as follows:
 Teams are ranked according to the number of problems solved; a team solving more
problems is always ranked higher than a team solving fewer problems.
 Within a group of teams solving the same number of problems, teams are ranked by
increasing “Penalty Points” (that is, the team with the lowest number of Penalty Points
is ranked highest within the group). Teams only accrue Penalty Points for problems
which the team has solved; unsolved problems do not affect the scoring in any way.
 Teams accrue Penalty Points for solved problems in two ways:(Penalty Points will come
into picture only in the case of a tie breaker)
o One point for each minute elapsed from the start of the contest until the
problem was solved (the time of SUBMISSION is counted as the “time solved”; it
does not matter how long it took the Judges to judge it).
o A specific number of penalty points for each INCORRECT submission submitted
to the Judges prior to a correct solution for the problem (runs submitted after a
correct solution is not counted in the scoring). The number of penalty points for
each incorrect submission prior to solving a problem is 20.
 If two or more teams have the same number of solved problems and exactly the same
number of Penalty Points, ties are broken in favor of the team with the earliest time of
the last correct submission (that being the time when the team “finished” the contest).
 Only the GNU GCC, G++ or Java compiler is allowed. Note that the C/C++ compiler
does not support void main(you have to use int main), clrscr(), strrev() of turbo C++
compiler
 The exe file should be exactly same in all cases.
 The spellings as well as the input and output format should match 100% otherwise the
software will declare an error.
Note: You should submit only the source code. The explanation (if reqd.) should be present
as the comment.

The team no. and the team name along with the member usernames, roll nos.,
email addresses and preferably a contact no. (For quick references) should be
present in the comment section on the top.

 No indiscipline will be tolerated.


 Any team found copying, cheating or exchanging notes will be disqualified.
 The decision of the organizers will be final.
You are allowed to carry books in the finals.
Knight Coders

Problem 1: Chanda Ikkatha


Aranya 2008 would be a great success (hopefully) what with scintillating
performances from Jal , Glow Jugglers, 3D movie showcase etc. After all, the
most popular event of Aranya(or that is what we intend to believe),
KnightCoders is also underway. So much effort has gone into the organization
of the entire fest that we have forgotten some minute details. Oops! We forgot that we have to
give prizes to the winner of KnightCoders..and now that all the funds have been used up, what
prizes would we give to you?
Please don’t walk out of the computer lab after reading the above lines, we have devised a
contingency plan to solve this problem. We have decided that we would take a clay pot(matka)
and roam about in the university looking for people who would wish to put some coins in the
matka. That way, by collecting coins from many participants, we could generate enough funds
for your prize money.
In order to prevent greedy participants or organizers from stealing money from the matka, we
decided to use a matka in which coins when inserted cannot be taken out until the entire matka
itself is broken to pieces. But this poses another grave problem. How can we determine the
amount of money collected in the matka? We would have to break it to find out. But if we do that
and find out that the money is less than the required prize money, then it would be a disastrous
situation for us, since now without the matka we cannot collect more money.
The only solution to solve this problem is by weighing the matka and trying to guess the number
of coins inside. Assume that we are able to determine the weight of the matka exactly and that
we know the weights of all coins of a given currency. Then there is some minimum amount of
money in the matka that we can guarantee. Your task is to find out this worst case and
determine the minimum amount of cash inside the piggy-bank. We need your help. Or if you
want your prize money, you better solve it 
Input Specification
The input consists of T test cases. The number of them (T) is given on the first line of the input.
Each test case begins with a line containing two integers E and F. They indicate the weight of an
empty matka and of the matka filled with coins. Both weights are given in grams. No matka will
weigh more than 10 kg, that means 1 <= E <= F <= 10000. On the second line of each test
case, there is an integer number N (1 <= N <= 500) that gives the number of various coins used
in the given currency. Following this are exactly N lines, each specifying one coin type. These
lines contain two integers each, Pand W (1 <= P <= 50000, 1 <= W <=10000). P is the value of
the coin in monetary units, W is it's weight in grams.
Output Specification
Print exactly one line of output for each test case. The line must contain the sentence "The
minimum amount of money in the matka is X." where X is the minimum amount of money that
can be achieved using coins with the given total weight. If the weight cannot be reached exactly,
print a line "This is impossible."
Sample Input 2
3 11
10 110 50 30
2 16
11 2
30 50 10 3
10 110 20 4

© Knight Coders, Computer Technicals, Aranya 2008. Page 2


Knight Coders

Output The minimum amount of money in the matka is 100.


for the This is impossible.
Sample
Input

The
minimum
amount of money in the
matka is 60.

Problem 2: Problem 2 problem 2 problem 2 problem 2


Oh no! The ‘Repeater’ virus has affected this file as well! The ‘Repeater’
virus is deadly computer virus that plays pranks with official looking word
documents by repeating certain words in a particular sentence. While
sending a letter to a potential sponsor, the ‘Repeater’ virus changed the
original document into something like this:
‘Due to terrible weather conditions we were unable to meet conditions with
your terrible company.’
The word terrible got repeated again at another place leaving us in a
terrible situation now. We have tried our best to solve this problem but to
no avail. The virus cannot be removed. We need to review all our documents
and remove all the duplications in these virus infected files. Since the task
was so tedious, we decided that we would give this problem over to you so
that we would obtain the program to solve this problem, free of cost and
hopefully under 7 hours.
Given a paragraph in English language, you have to look at each sentence
of the paragraph and remove the repetition of words in each sentence. That
is if one word appears multiple times in a sentence then your answer would
be a sentence which contains only the first instance of that word. Each
sentence is terminated by a ‘.’ (full stop). Assume that all basic English
language syntaxes are followed.
Input Specifications
The input consists of T test cases such that 1<=T<=50. The number of (T)
Test cases is given in the first line of the input. Each test case consists of a
string (senetences of English language) such that the length of the string
(the total number of characters in the string) is less than 500. After
specifying the number of test cases, strings belonging to each test case are
entered one line after another.
Output Specifications
© Knight Coders, Computer Technicals, Aranya 2008. Page 3
Knight Coders

For each test case the output consists of the corrected string.
Sample Input
3
The quick brown fox jumps over quick brown cat.
Words are repeated here there here there and everywhere. But
not in this this program.
You are the biggest noob of all noob people who think they know
programming.
Output for the sample Input
The quick brown fox jumps over cat.
Words are repeated here there and everywhere. But not in this program.
You are the biggest noob of all people who think they know programming.

Problem 3: Umpire Ki Izzat Bachao


In order to promote and bring more publicity to women’s cricket, we decided to organize a
cricket tournament (for girls) at our fest. The tournament rules and format would follow that of
standard cricket match. Almost every detail was considered and all the plans were made, except
one crucial decision. Who would be the umpire for the match?? Almost every one of the male
organizers volunteered for the prestigious post but the senior organizer (due to his seniority)
decided to become the umpire. So, our umpire went down to the stadium, all smartly dressed up
and ready to govern the match.
But unfortunately, as the game got underway, he realized that he knew nothing about cricket. He
had no clue as to what would be a valid ‘over’ in the match. Stuck in the midst of 22 girls and
losing his self respect gradually, the umpire is greatly worried about his reputation. It is your job
as a responsible participant to help the organizers whenever they ask you for help.
Given a set of runs for corresponding balls, you must check whether the given combination
would result in the possible completion of a valid over or a match (in case a match gets finished
before completion of the over). Assume that the concept of free hit does not exist and No Ball
and Wide Ball are the only extras. (And are commonly referred to by ‘E’). (If you know your
cricket then you would be knowing that a wide ball or a no ball would result in an extra delivery).
Input Specifications
The input consists of T test cases such that 1<=T<=50. The first line of the input consists of the
(T) number of test cases. Each test case begins with a line containing the number of balls
(N<=500) that have been bowled in that particular over. On the second line of each test case, N
number of characters are to be specified each separated by a space. Each character specifies the
number of runs (R) that have been scored on the particular delivery of the over. Assume that the
R={0,6} U {‘EX’,’W’}, where E stands for Extra (No ball and Wide) and W stands for wicket and X
is the number of runs that have been scored on that particular extra delivery. Assume that
0<=X<=6.
Output Specifications
Print exactly one line of output for each test case. If the test case is not a valid over, your output
should be, “This is not a valid over”. If the respective test case is a valid over, your output should
be, “This is a valid over”.
Sample Input

© Knight Coders, Computer Technicals, Aranya 2008. Page 4


Knight Coders

5
6
104356
6
7 8 9 10 11 3
7
0123456
7
0 N1 2 4 0 1 2
6
W N4 2 4 0 0
Output for the sample input
This is a valid over
This is not a valid over
This is not a valid over
This is a valid over
This is not a valid over

© Knight Coders, Computer Technicals, Aranya 2008. Page 5


Knight Coders

Problem 4: Show me the way!


Our initial motive was to make Aranya, the biggest tech fest in Northern India.
Well, it seems that thousands of participants have turned out for the event. With
more than 3000 students of the university itself, the density of population during
the fest has become so large that it is becoming difficult not to crush someone’s
foot. One even finds it difficult to push and shove people to move around. We have
indeed realized our dream of making our fest the biggest, but unfortunately, it has become so
big that even breathing fresh air has become a near impossibility. Under such chaotic conditions,
we concluded that participants were finding it difficult to reach the venue of their respective
events. Although they know where the venue is, they are unable to find a path to reach there.
Please help us in solving this grave problem. Remember you(yeah..you who are sitting in the
comfort of the labs)could have been the one crushed in the crowds unable to find his way to the
computer center. So it is your responsibility towards your fellow participants to solve this
problem.
Given the source co-ordinate(You are here) and the destination co-ordinate(Event venue) in a
matrix form, you need to find whether a path exists from the source to the destination. The
matrix contains some free spaces and some occupied spaces. The free spaces represent the
areas where you can move and the occupied spaces represent the crowds of people whom you
cannot step over. That is you can move only along free spaces. Furthermore, you can either
move horizontally or vertically along the free spaces but not diagonally. Assume that both the
source
Input Specifications
The input consists of T test cases such that 1<=T<=50. The first line of the input consists of the
(T) number of test cases. Each test case begins with a line containing two integers R and C. R
represents the number of rows in the matrix (1<=R<=100) and C represents the number of
columns in the matrix (1<=C<=100). This is succeeded by the input matrix itself. The matrix
consists of two symbols, a ‘*’ and a space. ‘*’ represents occupied space and ‘ ‘(space)
represents free space. The next line of the input consists of 4 integers A,B,C and D. A and B
represent the row and column positions of the source, C and D represent the row and column
positions of the destination. Assume that row and column positions start with 0.
Output Specifications
Print exactly one line of output for each test case. If there is a path between the source and the
destination, then you must print “There is a path”. If there is no path between the source and the
destination, then you must print “There is no path”.
Sample Input 64
3
37

0110 1141
48
Output for the sample input
There is no path
There is a path
2201 There is a path

© Knight Coders, Computer Technicals, Aranya 2008. Page 6


Knight Coders

Problem 5: Water Boy


The After sitting in the lab solving the weird mind breaking questions put up
by the ruthless organizers, you must have become a little tired. We have decided that we should
give the provision of an unlimited supply of drinking water. But the problem is we have only two
jugs available with us and unfortunately the water tap is a bit far off. So in order to quench your
thirst and your team-mates’ thirst, you need to solve this problem. The weird thing is that after
sitting here for such a long time you have decided that you would drink only integral amounts of
water in litres.
There are three types of actions that you can use: (1) you can fill a jug, (2) you can empty a jug,
and (3) you can pour from one jug to the other. Pouring from one jug to the other stops when the
first jug is empty or the second jug is full, whichever comes first. For example, if A has 5 litres
and B has 6 litres and a capacity of 8, then pouring from A to B leaves B full and 3 litres in A.
A problem is given by a triple (Ca,Cb,N), where Ca and Cb are the capacities of the jugs A and B,
respectively, and N is the goal. A solution is a sequence of steps that leaves exactly N litres in jug
B. The possible steps are

fill A empty B success


fill B pour A B
empty A pour B A
where "pour A B" means "pour the contents of jug A into jug B", and "success" means that the
goal has been accomplished.
You may assume that the input you are given does have a solution.
Input Format
Input to your program consists of a series of input lines each defining one puzzle. Input for each
puzzle is a single line of three positive integers: Ca, Cb, and N. Ca and Cb are the capacities of
jugs A and B, and N is the goal. You can assume 0 < Ca <= Cb and N <= Cb <=1000 and that A
and B are relatively prime to one another.
Output Format
Output from your program will consist of a series of instructions from the list of the potential
output lines which will result in either of the jugs containing exactly N litres of water. The last line
of output for each puzzle should be the line "success". Output lines start in column 1 and there
should be no empty lines nor any trailing spaces.
Sample Input
354
573

Sample Output
fill B
pour B A
empty A
pour B A

© Knight Coders, Computer Technicals, Aranya 2008. Page 7


Knight Coders

fill B fill A
pour B A pour A B
success empty B
fill A pour A B
pour A B success

Problem 6: Solution to Problem 6


For the first time in the history of all competitions, we are going to provide the solution to
the problem in the problem itself! Well…not really. You need to solve a particular riddle to
get that solution. We have placed the solution in to this problem locked behind a set of
secret doors. Each door is locked using the ancient Egyptian technique of ‘AmunRaRa’.
So let us acquaint you with this ancient art of door locking.
There are a large number of magnetic plates on placed on each door. Every plate has
one word written on it. The plates must be arranged into a sequence in such a way that
every word begins with the same letter as the previous word ends. For example, the
word ``knightcoders'' can be followed by the word “super”. Your task is to write a
computer program that will read the list of words and determine whether it is possible to
arrange all of the plates in a sequence (according to the given rule) and consequently to
open the door and obtain the solution to this problem.
Input Specification
The input consists of T test cases. The number of them (T) is given on the first line of the
input file. Each test case begins with a line containing a single integer number ‘N’ that
indicates the number of plates (1 <= N <= 100000). Then exactly N lines follow, each
containing a single word. Each word contains at least two and at most 1000 lowercase
characters, that means only letters 'a' through 'z' will appear in the word. The same word
may appear several times in the list.
Output Specification
Your program has to determine whether it is possible to arrange all the plates in a
sequence such that the first letter of each word is equal to the last letter of the previous
word. All the plates from the list must be used, each exactly once. The words mentioned
several times must be used that number of times. If there exists such an ordering of
plates, your program should print the sentence "Ordering is possible.". Otherwise, output
the sentence "The door cannot be opened."

Sample Input
3
2
computer
reverse
3
spam
malform
mouse

© Knight Coders, Computer Technicals, Aranya 2008. Page 8


Knight Coders

2
ok
ok

Output for the Sample Input


Ordering is possible.
Ordering is possible.
The door cannot be opened.

© Knight Coders, Computer Technicals, Aranya 2008. Page 9


Knight Coders

Problem 7: Fit the plug


We presume that you would know that today morning (assuming that the time
has passed 12am) the Battle of the Bytes, one of the most exciting events is
about to take place. It is going to be a very high profile event with media
personnel from different countries coming to cover the event. These media
personnel would bring along with them their different equipment such as laptops,
microphones, cameras etc. since they are from different countries, their
equipment plugs require different types of sockets(plug points). We do not have
all these types of plug points available in room D-205. So went to a local electric
store and purchased a few adapters which would provide a virtual plug point that
would enable us to connect a device of a particular plug type . But since we are
stuck up here late at night, trying to organize Knightcoders, we couldn’t do all the purchases.
Thus for damage limitation, you must help us in calculating the smallest number of devices that
cannot be plugged in at all.
Input Format
Input will consist of one case. The first line indicates the number of sockets ‘n’ (plug points) in
the room. (1<=n<=1000)The next n lines list the types of the plug points present in the room.
Each plug point type consists of a string of atmost 24 alphanumeric characters. The next line is a
single positive integer ‘m’ that represents the number of devices to be connected. Each of the
next m lines that follow list the name of the device and the type of the plug each device uses
(which is the same format as that of the plug point)A device name is a string of atmost 24
alphanumeric characters. No two devices will have the same name. The plug plug is separated
from the device name by a space. The next line contains a single positive integer k(1<=k<=100)
indicating the number of different types of adapters that have been purchased. Each of the next
k lines describes the variety of adapter, giving the type of the plug point provided by the
adapter, followed by a space followed by the type of the plug.
Output Format
A line containing a single non-negative integer indicating the smallest number of devices that
cannot be plugged in.
Sample Input
4
A
B
C
D
5
laptop B
phone C
clock B
camera X
lights Z
3
BX
XA
XD
Sample Output

© Knight Coders, Computer Technicals, Aranya 2008. Page 10


Knight Coders

© Knight Coders, Computer Technicals, Aranya 2008. Page 11

Potrebbero piacerti anche