31.07.2015 Views

LITHUANIAN OLYMPIADS INFORMATICS

LITHUANIAN OLYMPIADS INFORMATICS

LITHUANIAN OLYMPIADS INFORMATICS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

any comparator can be only theadjacent elements of the sequencebeing sorted. Only one comparatorcan work with the same elementin parallel. Undoubtedly, not everysuch network sort sequencecompletely Consider the example:If inputs of network on the leftare equal to x 1=5, x 2=9, x 3=4, x 4=2,x 5=6, then outputs will be equal to:y 1=5, y 2=2, y 3=4, y 4=6, y 5=9.Let’s call all the comparations,performed in parallel (i.e. at theX 11 2 3 4žings. step žings. step žings. step žings. stepPicture 237.151y 1yX 22X 3y 3X 4X 5y 5same time) a step. Network is assumed to be more effective if number of steps is less.Task. Create a parallel sorting network to sort the sequence of four members completely.Number of steps must be the least.Represent this network in scheme, as it is shown in picture 237.1.238. Skyscraper. There are n offices, numbered from 1 to n in a new skyscraper.The table (-es) with the number of the office should be fastened to the door of eachoffice. Only one digit is written on one table. If the number of the office is not onedigitnumber, several tables should be fastened to each door.Task. Write a program to calculate the numbers of tables with each digit separatelyneeded to fasten numbers to the doors of all the offices.For example, if n==6, the output should be 0 1 1 1 1 1 1 0 0 0; here thefirst number means the needed amount of tables with digit 0, the second one meansthe amount of tables with digit 1 and etc. The last number means the amount of tableswith digit 9.239. Yang’s Table. Yang’s table consists of different natural numbers groupedinto the rows of non-increasing length, aligned left; members of each row increasefrom left to right, and members of each column increase downwards.There exists an algorithm to update Yang’s table a new element (number). Considerthe example in picture 239.1.The Yang’s table above must be updated with the new element 8.We do the following: write 8 to theplace of number 9 being in the first row,because 9 is the smallest number of thisrow greater than 8. Now number 9 is“pushed” to the second row, where itreplaces number 10. This one “pushes”13 from the third row to the fourth one.1 3 5 9 12 162 6 10 154 13 141117Picture 239.1y 4

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

Saved successfully!

Ooh no, something went wrong!