Anda di halaman 1dari 9

Australian Informatics Olympiad

Thursday 4 September, 2014


Intermediate Paper
Duration: 3 hours
3 questions
All questions should be attempted
Australian Informatics Olympiad 2014 (Intermediate) Important Notes 1
Important Notes
Some nal reminders for competitors:
Solutions may be submitted in C, C
++
, C#, Pascal, Java, PHP or Python.
Solution templates can be downloaded from the submission website. These templates perform
all the necessary le input and output for each question. We strongly recommend using these
as a starting point for your solutions.
You should submit your solutions directly via the internet during the three hours of the
contest. Please read the Contest Rules in the Information Booklet if you have not yet done
so.
Some languages have special constraints:
Pascal programmers may not import any units except for Math, Strings and/or SysUtils.
Java programmers may not use any classes aside from those in packages java.lang,
java.io and java.util. Solutions must be contained in a single class called Solution,
and must be run from the routine
public static void main(String[] args)
within this Solution class.
PHP programmers may not use any functions provided by extensions or external li-
braries.
Python programmers may not import any packages except for sys.
If you are not sure about how your program should be structured, see the submission site
http://orac.amt.edu.au/aio/ for sample solutions to past problems in each of the sup-
ported languages (you are welcome to browse these during the contest).
It is particularly recommended that Java and PHP programmers visit this site, due to the
unusual constraints described above.
Dont leave all your submissions until the last few minutes! Submitting your solu-
tions may take a little time, and once your three hours are over the submission site will not
accept any more solutions.
The best strategy is to submit solutions as you write them. If you improve a solution later
in the contest, you can always resubmit it.
If you have any queries, please ask your teacher to email aioquery@amt.edu.au and we will
respond as soon as possible. For urgent issues (such as losing your internet connection),
please ask your teacher to contact either Mr Jarrah Lacko on 02 8091 2321 or Mr Robert
Newey on 0432 748 904.
Please see the full contest rules for further information.
Good luck!
Australian Informatics Olympiad 2014 (Intermediate) Why Did I Score Zero? 2
Why Did I Score Zero?
Candidates sometimes score zero even though they believe that they have a working solution to a
problem. Below are some of the common reasons that good solutions score zero.
Note that examples of solutions that score 100% in the various AIO languages can be found on
the website http://orac.amt.edu.au/aio/.
Incorrect Input and Output Files
Each problem statement lists the names of its input and output les, similar to the example below.
Input File: zeroin.txt
Output File: zeroout.txt
In this example, if you try to open any of
"a:\zeroin.txt"
"c:\mydir\zeroin.txt"
"input.txt"
then the le you are looking for will almost certainly not be on the judging machine and your
program will score zero. Just open "zeroin.txt" without any additional directory information.
The same goes for the output le.
Keyboard and Mouse Input
Your program should not be interactive. It should not have a graphical user interface. It should
simply read from the input le, write to the output le, and exit. If your program requires any
input from the user, the judging software will not supply this input and you will exceed the time
limit. Examples include:
Please enter the following value...
Press any key to exit...
Providing a form on which the user has to click a button to start the program.
Incorrect Output Format
Each problem is very precise about how the output le should be formatted. Your score is assigned
by a judging program which tries to automatically extract your solution from your output le.
Every problem statement includes sample input and output les, as a way of illustrating these
formats. For Problem 1 on the Intermediate paper, the rst sample output le contains the single
line:
4
In this example, the following output les would almost certainly score zero:
The answer is 4.
"4"
Violating Contest Rules
Each year a few programs are submitted that violate the contest rules. Be sure to read the Program
Restrictions section of the rules, which details specic restrictions for each programming language.
If you are unsure about anything then please email aioquery@amt.edu.au for clarication.
Australian Informatics Olympiad 2014 (Intermediate) Pygmy Hippos 3
Problem 1
Pygmy Hippos
Input File: hippoin.txt
Output File: hippoout.txt
Time Limit: 1 second
Your backyard has been overrun by adorably tiny hippos, and they are eating the daisies!
You have a line of N daisies, labelled from 1 to N. There are three hippos standing next to
dierent daisies . . . and they are already eating them! If you dont act fast, they will eat all the
daisies in your garden.
You have enough plywood to build up to three fences. Each fence will be built between two
daisies that are next to each other. Hippos cannot go through fences (or over them, or under them,
or around them).
Once you have built your fences, the hippos will roam back and forth along the line of daisies,
eating all the daisies they can reach without crossing your fences. What is the greatest number of
daisies you can save?
Input
Your program should read from the le hippoin.txt.
The rst line of input will contain one integer N: the number of daisies.
The next three lines will each contain an integer describing which daisy one hippo is currently
eating. These will be in increasing order. No two hippos start at the same daisy.
Output
Your program should write to the le hippoout.txt. Your output le should contain one line with
one integer: the greatest number of daisies you can save.
Australian Informatics Olympiad 2014 (Intermediate) Pygmy Hippos 4
Sample Input 1
9
2
5
7
Sample Input 2
3
1
2
3
Sample Output 1
4
Sample Output 2
0
Explanation
In the rst sample case, as illustrated above, if we put a fence between daisies 2 and 3, between
daisies 4 and 5 and between daisies 7 and 8, no hippo will be able to reach daisies 3, 4, 8 or 9.
There is no placement of fences that will save more daisies, so 4 is the correct answer.
In the second sample case, no matter where you place the three fences you will not save any daisies,
as they are all being eaten.
Constraints
To evaluate your solution, the judges will run your program against several dierent input les.
All of these les will adhere to the following bounds:
3 N 1 000 000
Australian Informatics Olympiad 2014 (Intermediate) Coreys Party 5
Problem 2
Coreys Party
Input File: partyin.txt
Output File: partyout.txt
Time Limit: 1 second
Your friend Corey wants to organise a party and invite a few mates.
In the past, Coreys parties havent always ended well. Some guests get bored because they
dont know anyone, then start causing trouble. Other guests get bored because they already know
everyone, then start causing trouble.
Thus, Coreys new party invitation strategy is to invite a set of people to the party such that
every guest already knows at least A other guests (not including Corey), and doesnt know at
least B other guests. This way, everyone will have at least A friends to chat to and at least B new
people to meet.
Corey will give you a list of the M existing friendships between his N friends. You must write
a program to output the largest number of friends he can invite to his party satisfying the above
constraints.
Input
Your program should read from the le partyin.txt. The rst line of input will contain four
space-separated integers in this order:
N: the number of Coreys friends
M: the number of friendships between Coreys friends
A: the number of guests that each guest must already know
B: the number of guests that each guest must not already know
The following M lines of input will each contain two space-separated integers x and y, represent-
ing that Coreys friend x and Coreys friend y are already friends with each other. Friends are
represented as integers between 1 and N.
Output
Your program should write to the le partyout.txt. Your output le should contain one line with
one integer: the maximum number of friends Corey can invite to his party such that every invited
guest knows at least A other guests and doesnt know at least B other guests. Note that it may
not always be possible to invite a set of guests that satises these constraints, in which case you
should output 0.
Australian Informatics Olympiad 2014 (Intermediate) Coreys Party 6
Sample Input 1
6 9 2 1
1 2
1 3
1 4
1 5
2 3
3 4
4 5
5 2
6 2
Sample Input 2
7 8 2 0
1 2
4 5
1 6
2 6
3 6
4 6
5 6
7 1
Sample Output 1
4
Sample Output 2
5
Explanation
In the rst sample case, if Corey invites friends 2, 3, 4 and 5 to a party, each will already know
exactly 2 other guests and not know exactly 1 other guest. This satises Coreys constraint that
every guest must know at least 2 other guests and not know at least 1 other guest. It is not possible
to organise a party that includes friends 1 or 6, thus 4 is the maximum number of guests Corey
can invite.
In the second sample case, Corey can invite friends 1, 2, 4, 5 and 6. Each guest would already
know at least two other guests, thus satisfying A = 2. Since B = 0, there is no constraint on the
number of guests each invited guest doesnt already know.
Constraints
To evaluate your solution, the judges will run your program against several dierent input les.
All of these les will adhere to the following bounds:
1 N 1000
1 M 100, 000
0 A, B N 1
Furthermore, for 50% of available marks, B = 0. That is, there is no constraint on the number of
people an invited guest must not already know.
Australian Informatics Olympiad 2014 (Intermediate) Chimera 7
Problem 3
Chimera
Input File: chimin.txt
Output File: chimout.txt
Time Limit: 1 second
Next week is your schools Mad Science Fair, and everyone is hard at work on their mad science
projects. For example, Gru is building a rocket big enough to steal the moon, whilst Elsa is
tinkering with her freeze ray. For your project, you are breeding a chimera.
A chimera is a monster that is part lion, part snake, and part goat. Your plan is to take the
DNA sequences of each of the three creatures and combine them into a new DNA sequence for the
chimera. A DNA sequence is a string of N letters, each one of A, T, C or G.
?
G A T T A T A
C A G G A T A
T A T T A C A
C A T T A T A
The list above shows an example of three DNA sequences of length 7 representing lion, snake
and goat DNA. The bottom DNA sequence is one possible sequence of chimeras DNA. Letters in
bold in the top three lines are the same as the letter in the chimeras DNA at the same position.
The lionishness of your chimera is dened as the number of positions in which the lion DNA
and the chimera DNA have the same letter. In the example above, the lionishness of your chimera
is 6, as they match in all but the rst position. The snakiness and goatism of your chimera are
dened similarly. In the example above, the snakiness and goatism of your chimera are both 5.
The task before you is to construct the chimeras DNA sequence. You will be given the DNA
sequences for lions, snakes and goats. The mark for your project will be whichever is lowest: the
lionishness, snakiness or goatism of your chimera. You must determine the highest mark you can
possibly achieve.
Australian Informatics Olympiad 2014 (Intermediate) Chimera 8
Input
Your program should read from the le chimin.txt.
The rst line of input will contain one integer N: the length of each DNA sequence.
The next three lines will represent lion, snake and goat DNA respectively. Each of these will
contain a sequence of N letters, each one of A, T, C, or G.
Output
Your program should write to the le chimout.txt. Your output le should contain one line with
one integer: the highest possible mark you can achieve. (Remember, your mark will be whichever
is lowest: the lionishness, snakiness or goatism of your chimera.)
Sample Input 1
7
GATTATA
CAGGATA
TATTACA
Sample Output 1
5
Explanation
The sample data reects the case described on the previous page. There is no chimera DNA
sequence that will receive a mark higher than 5.
Constraints
To evaluate your solution, the judges will run your program against several dierent input les.
All of these les will adhere to the following bounds:
1 N 100 000
Furthermore,
For 30% of available marks, the lion and snake DNA sequences will be exactly the same.
For 50% of available marks, all DNA sequences will only use the letters A and T.

Anda mungkin juga menyukai