31.07.2015 Views

LITHUANIAN OLYMPIADS INFORMATICS

LITHUANIAN OLYMPIADS INFORMATICS

LITHUANIAN OLYMPIADS INFORMATICS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Input data are presented in the input file. The first line of the input file containsthe number of guests N (2 < N ≤ 200). The second line contains the numbers of gueststhe first person was familiar with: the first number in the line indicates how manyguests the first guest knew, further there are presented the numbers of the guests. Thethird line contains the numbers of guests the second guest was familiar with, etc.Output – the number of absent guest – must be written to the output file.Note. If several solutions (absent persons) exist, output any one of them.STAGE III, PART II41SENIOR DIVISION223. Game-machine. (Run time limit – to 3 sec.; processor Pentium 133 MHz).On the screen of the game-machine there are ten squares. One digit (from 0 to 9) canbe seen in each square. There are buttons under squares, numerated from 1 to 10.Each button controlscertain squares.Their connectionsare presented intable below.When a button ispressed, the numbersin squares controlledby this buttonare increased by one.If the number seen inthe square was 9, itwould become 0.Number of Numbers of squares controlled by buttonsbutton1 4, 5, 8, 9, 102 9, 103 8, 104 3, 5, 9, 105 6, 8, 96 2, 3, 4, 5, 8, 107 1, 2, 4, 6, 8, 9, 108 109 7, 8, 1010 5, 7, 9, 10Task. Write a program, which for the given sequence of numbers of squares findssuch the shortest sequence of pressing buttons (if only such exists) that after performingit digits in all squares become the same.Input. The only line of input file contains 10 digits, separated by a single spacecharacter.Output. The first line of the output file must contain IT IS IMPOSSIBLE, if it isnot possible to find the described sequence of pressings, or IT IS POSSIBLE, if it canbe found. In this case the number of pressings N must be written to the second line,and the numbers indicating how many times a certain button was pressed must bewritten to the remaining ten lines (one number per line). If the button was not pressed,zero must be written.Notes. 1. If several solutions (shortest sequences) exist, output any one of them.2. If all digits are the same in the input data, then the solution must be IT ISPOSSIBLE, and number of button pressings must be equal to zero.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!