Вы находитесь на странице: 1из 9

COCI 2013/2014

3rd round, December 7th, 2013

TASK

RIJE I rijeci.pas rijeci.c rijeci.cpp

OK!IR okvir.pas okvir.c okvir.cpp

RE E"ICE recenice.pas recenice.c recenice.cpp

KO#I"JE kolinje.pas kolinje.c kolinje.cpp

$ARO!I parovi.pas parovi.c parovi.cpp

ODA%I#JA I odasiljaci.pas odasiljaci.c odasiljaci.cpp

&ource code

'n(ut out(ut t'me )'m't memor* )'m't 1 second 32 MB +0 (o'nt ./)ue 1 second 32 MB ,0

standard input (stdin) standard output (stdout) 1 second 32 MB 100 -+0 1 second 32 MB 120 1 second 64 MB 140 1 second 32 MB 1-0

Problems translated from Croatian by: Paula Gombar

COCI 2013/2014 3rd round, December 7th, 2013

T/&0 RIJE I Author1 2/r'n Tom'3

One day, little Mirko came across a funny looking machine! It consisted of a very very large screen and a single button. When he found the machine, the screen displayed only the letter . fter he pressed the button, the letter changed to !. "he ne#t fe$ times he pressed the button, the $ord transformed from ! to ! , then to ! !, then to ! !! ... When he sa$ this, Mirko reali%ed that the machine alters the $ord in a $ay that all the letters ! get transformed to ! and all the letters get transformed to !. mused by the machine, Mirko asked you a &ery difficult 'uestion! fter K times of pressing the button, ho$ much letters and ho$ much letters ! $ill be displayed on the screen(
I"$4T

"he first line of input contains the integer K )* + K + ,-., the number of times Mirko pressed the button.
O4T$4T

"he first and only line of output must contain t$o space/separated integers, the number of letters and the number of letter !.
SCORI"5

In test data $orth 012 of total points, K $ill be less or e'ual to *1.
SA2$#E TEST S
input input input

1
output

4
output

10
output

0 1

2 3

34 55

COCI 2013/2014 3rd round, December 7th, 2013

T/&0 OK!IR Author1 Adr'/n S/t6/ Kurd'6/

Mirko has assembled an e#cellent cross$ord pu%%le and no$ he $ants to frame it. Mirko3s cross$ord pu%%le consists of M # N letters, and the frame around it should be U characters $ide on top, L characters on the left, R characters on the right and D characters on the bottom side. "he frame consists of characters 4 )hash. and . )dot. $hich alternate like fields on a chessboard. "hese characters should be arranged in a $ay that, if the frame is e#panded to co&er the entire cross$ord pu%%le and $e treat these characters as a chessboard, the 4 characters should be placed as the red fields on a chessboard )i.e. the top left field.. 5ee the e#amples belo$ for a better understanding of the task.
I"$4T

"he first line of input contains t$o integers M and N )* + M, N + *1.. "he second line of input contains integers U, L, R, D )1 + U, L, R, D + -.. "he follo$ing M lines of input contains N characters 6 lo$ercase letters of the 7nglish alphabet. "hese lines represent Mirko3s cross$ord pu%%le.
O4T$4T

Output the framed cross$ord pu%%le as stated in the te#t.


SA2$#E TEST S
input input

4 4 2 2 2 2 honi oker nera irak


output

2 4 1 0 3 1 rima mama
output

#.#.#.#. .#.#.#.# #.honi#. .#oker.# #.nera#. .#irak.# #.#.#.#. .#.#.#.#

#.#.#.# rima.#. mama#.# .#.#.#.

COCI 2013/2014 3rd round, December 7th, 2013

T/&0 RE E"ICE Author1 2/r'n Tom'3

Once upon a time in a land far far a$ay, inhabited only by math students, I&a and 8edran $ere discussing self/e#planatory sentences. part of these sentences is e#actly one number and it is equal to the total number of letters in the sentence. 5ome e#amples are: 9"his sentence has thirtyone letters.:, 9!lah blah se&enteen:. ;ittle <urica o&erheard his friends3 con&ersation and decided to impress them $ith the amount of self/ e#planatory sentences he kno$s by heart. =e rushed back home and $rote a programme $hich $ill, gi&en a sentence, tell him the minimum number he can put inside so that the sentence is &alid. >nfortunately, his computer broke and no$ he needs your help. Write a programme to help <urica! "he form of the sentence is: word1 word2 word3 ? @ word_n-1 word_n. "he character @ represents the place $here the number should be put in. Aor e#ample, the form of the sentence 9this sentence has thirtyone letters: $ould be 9this sentence has @ letters:. "he rules that apply to $riting numbers are the follo$ing: numbers from * to *1 are $ritten 9one:, 9t$o:, 9three:, 9four:, 9fi&e:, 9si#:, 9se&en:, 9eight:, 9nine:, 9ten:, respecti&ely numbers from ** to *B are $ritten 9ele&en:, 9t$el&e:, 9thirteen:, 9fourteen:, 9fifteen:, 9si#teen:, 9se&enteen:, 9eighteen:, 9nineteen: the remaining double digit numbers are $ritten in a $ay that $e name the tens3 digit and add to it the name of the one digit remaining $hen $e remo&e the tens3 digit. 5pecially, if by remo&ing the tens3 digit $e remain $ith %ero, $e add nothing to it the tens3 digits )respecti&ely from 0 to B. are named the follo$ing: 9t$enty:, 9thirty:, 9forty:, 9fifty:, 9si#ty:, 9se&enty:, 9eighty:, 9ninety: three digit numbers are $ritten in a $ay that $e name the hundreds3 digit number and add to it the number of the double digit number remaining. 5pecially, if by remo&ing the hundreds3 digit $e remain $ith %ero, $e add nothing to it the hundreds3 digits )respecti&ely from * to B. are named the follo$ing: 9onehundred:, 9t$ohundred:, 9threehundred:, 9fourhundred:, 9fi&ehundred:, 9si#hundred:, 9se&enhundred:, 9eighthundred:, 9ninehundred: the rules that apply for numbers $ith more than three digits are not relevant because the input data $ill al$ays be such that the output is less than a thousand

7#amples of naming some numbers: CD E 9si#ty: F 9eight: E 9si#tyeight: G*B E 9threehundred: F 9nineteen: E 9threehundrednineteen: -G1 E 9fi&ehundred: F 9thirty: E 9fi&ehundredthirty: BH* E 9ninehundred: F 9se&enty: F 9one: E 9ninehundredse&entyone:

COCI 2013/2014 3rd round, December 7th, 2013

T/&0 RE E"ICE Author1 2/r'n Tom'3

I"$4T

"he first line of input contains the integer N )* + N + 01., the number of $ords in the sentence. 7ach of the follo$ing N lines contains a $ord not longer than -1 lo$ercase letters of the 7nglish alphabet or the character @ )none of the $ords $ill be the name of a number.. "he character @ $ill appear e#actly once.
O4T$4T

"he first and only line of output must contain the re'uired sentence. "he numbers are named as mentioned before, e&en if the sentence sounds gramatically incorrect. "he input data $ill be such that a solution $ill al$ays e#ist and is less than *111.
SCORI"5

In test cases $orth ,12 of total points, the re'uired number for the sentence $ill be less or e'ual to -1.
SA2$#E TEST S
input input input

5 this sentence has $ letters


output

7 $ is the number of letters here


output

5 the letters are $ potato


output

this sentence has thirtyone letters

thirty is the number of letters here

the letters are twentynine potato

larification of the second e!ample" 5entence is split in t$o lines because of the lack of space in the table. "he total number of letters in the sentence is C F 0 F G F C F 0 F H F , E G1 larification of the third e!ample" s you can see, this sentence is gramatically incorrect. Ie&ertheless, <urica is not concerned by that, for he is a mathematician, not a linguist.

COCI 2013/2014 3rd round, December 7th, 2013

T/&0 KO#I"JE Author1 Adr'/n S/t6/ Kurd'6/

Melita has Just returned from the annual pig slaughter. Kon3t $orry, this is a regular thing in Croatia. "he best part $as the abundance of food! "here $as e&erything, starting from good spicy sausages, ham, black pudding, up to tee$urst, top 'uality bacon and L&arci, all $ith $arm $hite bread and butter. fter these appeti%ers, it $as the perfect time to $hip up a deep pot full of sarma )Melita ate t$entyish of them. as $ell as a large platter of fine roast pork, so soft that it almost melts in your mouth. "hey $atered all of this do$n $ith copious gulps of the best dry $hite $ine that made them e&en hungrier. !utcher !aJs kept his a$ard/$inning ham for the &ery end. N people attented the annual pig slaughter, labeled $ith numbers from * to N. "hese people already ate a lot of meat: the #th person ate $%#& kilograms of meat so far. !aJs $ill distribute his ham to the people in the ratio 'M*N : 'M0N : ? : 'MIN, e#actly in that order, but he doesn3t kno$ the total amount )number of kilos. of ham $hich he $ill be distributing yet. t the end of the slaughter, the Man of the Oear $ill be declared. ranking list is made according to the total kilos of meat eaten. !aJs impacts directly on this list by choosing the amount of ham to distribute. lthough !aJs has been offered bribes many times, he refused each time, saying that he $as an honest man $ho $ould not hurt a fly. !aJs cares about order, because he3s a nice gentleman, and $ants to ha&e the order of people in the e#act form of *, 0, G, ..., N, respecti&ely from the one $ho ate the most kilos of meat to those $ho ate less, allo$ing ties bet$een participants. =elp !aJs select the total amount of ham that he $ill distribute )in the ratio mentioned before. to achie&e his intention.
I"$4T

"he first line of input contains an integer N )0 + N + *111., the number of competitors for the Man of the Oear a$ard. 7ach of the follo$ing # lines contains integers $M#N i 'M#N, as mentioned in the te#t )1 + $M#N, 'M#N + *1C.. t least one of the numbers 'M#N $ill not be e'ual to 1.
O4T$4T

"he first and only line of output must contain /* if the re'uired order cannot be achie&ed. Other$ise, output the re'uired amount of ham in kilos, a real number )rounded up to *0 decimal places. bet$een 1 and *1H )inclusi&e.. If there are multiple possible solutions, output any.
SA2$#E TEST S
input input input

3 7 1 3 2 10 0
output

3 2 1 4 0 0 3
output

5 15 4 6 7 12 5 9 6 1 7
output

10.5

-1

87

larification of the first e!ample" *1.- kilos of ham is distributed in the ratio * : 0 : 1, $hich gi&es us G.-, H and 1 kilos of ham, respecti&ely. If $e add this to the already eaten amount of meat, $e conclude that the participants ate *1.-, *1 and *1 kilos in total, $hich is a &alid order.

COCI 2013/2014 3rd round, December 7th, 2013

T/&0 $ARO!I Author1 2/r'n Tom'3

(he distance bet$een t$o integers is defined as the sum of the absolute result of subtracting their digits. Aor e#ample, the distance bet$een the numbers ,-C* and G0HD is P, 6 GP F P- / 0P F PC / HP F P* / DP E *0. If one of the numbers consists of fe$er digits than the other, $e fill it $ith leading %eroes. "herefore, the distance bet$een the numbers G0 and -CHD is P1 / -P F P1 / CP F PG / HP F P0 / DP E 0*. Oou are gi&en t$o integers $ and '. Calculate the sum of distances bet$een each pair of numbers belonging in the inter&al M$, 'N!
I"$4T

"he first and only line of input contains integers $, ' )* + $ + ' + *1-1111..
O4T$4T

"he first and only line of output must contain the re'uired number from the te#t. Qi&en that the number could be e#tremely large, output ans$er modulo * 111 111 11H.
SCORI"5

In test cases $orth 012 of total points, $ and ' $ill not e#ceed *1111. In test cases $orth ,12 of total points, $ and ' $ill not e#ceed *1*11.
SA2$#E TEST S
input input input

1 5
output

288 291
output

1000000 10000000
output

40

76

581093400

larification of the second e!ample" "he distances are, respecti&ely, )0DD, 0DB. E *, )0DD, 0B1. E B, )0DD, 0B*. E D, )0DB, 0B1. E *1, )0DB, 0B*. E B, )0B1, 0B*. E *. 7ach of them counts t$ice, $hich is in total 0 R )* F B F D F *1 F B F*. E HC.

COCI 2013/2014 3rd round, December 7th, 2013

T/&0 ODA%I#JA I Author1 2/t'6/ 2')'7'3

"he mayor has decided that it is high time to implement a ne$ system of tele&ision transmitters. "he city can be represented as a segment of the length D on $hich there are buildings of different heights. "he $idth of a building is negligible. On top of some buildings, television transmitters are set, their dimensions are also negligible. "ele&ision transmitters emit a tele&ision signal in all directions around them. "he signal is spread through space in straight lines and cannot pass through buildings. certain point in the city is considered covered if it is reached by a signal from an e#isting transmitter.

Aind the segment of the city co&ered by tele&ision signal and output its length.
I"$4T

"he first line of input contains the integer N )* + N + G S *1-., the number of buildings, and the integer D )* + D + *1B., the city length. 7ach of the follo$ing N lines contains three numbers $hich describe the ith building: *. a number $hich determines $hether there is a transmitter on top of the building: 1 )no. or * )yes. 0. an integer )i )1 + )i + D., the distance bet$een the building and the left end of the city G. an integer *i )* + *i + *1B., the building height "he buildings are sorted in ascending order by the distance from the left end of the city. Io t$o buildings $ill be located on the same distance from the left end of the city.
O4T$4T

"he first and only line of output must contain the re'uired length from the te#t. Iote: the ma#imum permissible de&iation from the official solution is *1/G.

COCI 2013/2014 3rd round, December 7th, 2013

T/&0 ODA%I#JA I Author1 2/t'6/ 2')'7'3

SCORI"5

In test cases $orth G12 of total points, N $ill be less or e'ual to *111.
SA2$#E TEST S
input input

3 1 0 0

10 2 6 4 3 8 2

5 0 1 1 0 0

15 4 3 5 5 6 6 9 2 10 3

output

output

6.000000

8.500000

larification of the second e!ample" "his e#ample corresponds to the image from the te#t. "he image depicts the city. "he buildings are marked $ith &ertical lines, and the transmitters $ith circles on the tops of the buildings. "he bold lines on the #/a#is represent the segment of the city not co&ered by tele&ision signal.

Вам также может понравиться