The British Informatics Olympiad is the computing competition for schools and colleges. We are proud to present BIO 2000. |
The 2000 British Informatics Olympiad - Round One
Question 1 Passwords |
Some computer programs try to prevent easily guessable passwords being used, by rejecting those that do not meet some simple rules. One simple rule is to reject passwords which contain any sequence of letters immediately followed by the same sequence.
For example:
APPLE Rejected (P is repeated) CUCUMBER Rejected (CU is repeated) ONION Accepted (ON is not immediately repeated) APRICOT Accepted |
|
1 (a) [22 marks] |
Write a program which inputs a password (between 1 and 10 upper case letters) and then prints Rejected if the password is rejected, or Accepted otherwise. Your program should then terminate. | Sample run Password: BANANA Rejected |
1 (b) [5 marks] |
Suppose the only valid letters are A and B; the password ABA cannot be made longer since both ABAA and ABAB will be rejected. What is the length of the shortest password that cannot be made longer, if A, B and C are valid? Give an example. |