Codeforces Round #301 Problem Solving report

Source: Internet
Author: User

I think the order of this topic is unreasonable ...

A. Combination Lock

Scrooge McDuck keeps his is treasured savings in a home safe with a combination lock. Each time he wants into put there the treasures that he's earned fair and square, he has to open the lock.

The combination lock is represented by n rotating disks with digits from 0 to 9 written on them. Scrooge McDuck have to turn some disks so, the combination of digits on the disks forms a secret combination. In one move, he can rotate one disk one digit forwards or backwards. In particular, on one move he can go from digit 0 to digit 9 and vice versa. What minimum number of actions does he need for?

The direct simulation is good ... On each of the two number of rings on the distance

B. School Marks

Little Vova Studies programming in an elite school. Vova and his classmates is supposed to Write  n  progress tests, for each test th EY'll get a mark from 1 To  P . Vova is very smart and he can write every test for any mark, but he doesn ' t want-stand out from the crowd too much. If the sum of his marks for all tests exceeds Value  x , then he classmates notice how Smart He is and start distracting him asking to let them copy his homework. And if the median of his marks would be lower Than  y  points  (the definition of a median is given in the notes) and then his mom would decide that he gets too many bad Ma Rks and forbid him to play computer games.

Vova has already wrote K tests and got marks a1, ..., ak. He doesn ' t want to get in the first or the second situation described above and now he needs to determine which marks he Needs to get for the remaining tests. Help him does that.

The simple idea of this problem is that when the median meets the conditions

Make the entire sequence as small as possible to meet the first condition

First, if the lower bound of the read-in is X, then it is clear that the median of the final sequence is also X

We assume that the final median is not X, but the small number of I in the original sequence A[i]

Then A[i] with left not enough N/2 number with 1 fill, a[i] with right not enough N/2 number with A[i] Fill

However, if we use X as the median, the position of X will be less than or equal to I

First look at less than the time, the left to fill the number of 1 more, the right to fill the number of X is less, obviously the sum will be small

Equal to the time, left to fill the 1 unchanged, the number of the right to fill the same, just fill with X, and X<=a[i], so the sum will be smaller

Because the title Guarantee K<n, always fill in a number, so no matter how the median to take X is always right

Need to judge the number and sum of the left and right, but pay attention to some details

Of course, my method is not so good, so I have a lot of details to judge.

Similar to: No number in the original sequence, no number greater than or equal to x in the original sequence ...

C. Ice Cave

You play a computer game. Your character stands on some level of a multilevel ice cave. In order-to-move on forward, you need-descend one level lower and the-only-to-do-is-to-fall through the ice.

The level of the cave where you are a rectangular square grid of  n  rows an D  m  columns. Each cell consists the either from intact or from cracked ice. From each cell you can move to cells that is side-adjacent with yours (due to some limitations of the game engine can Do jumps on the same place, i.e. jump from a cell to itself). If you move to the cell with cracked ice, then your character falls down through it and if your move to the cell with INTAC T ice, then the ice in this cell becomes cracked.

Let's number the rows with integers from 1 to  N  from top to bottom and the columns with integers from 1 to  m  from left-to-right. Let's denote a cell on the intersection of The  R -th row and The  C -th column As  ( R , C ).

You were staying in the cell (R1, c1) and this cell was cracked because you ' ve just fallen her E from a higher level. You need to fall down through the cell (R2, C2) since the exit to the next level is there. C A you does this?

The sample of this problem is very annoying ><

Around a big circle and decided to use the network flow to do ... Although I think it is not science, CF on the problem actually has so long code?

The last glorious re is not going to find out where it went wrong ... After all, it's a less difficult question.

For a non-cracked point, we sometimes need to find a road that's full of non-cracked squares to go around this point.

In fact it is very simple, as long as it is surrounded by a non-cracked point, go there, and then come back to it ...

There's no need to think of anything else.

After this, the whole problem of the train of thought is a lot easier

First consider the situation where the starting point and end point coincide, as long as there is an open point around it.

And then consider other things, first we need a path from the beginning to the end that has a non-cracked lattice

Of course, if it's next to two, then don't worry.

And then discuss the situation.

If the end point is broken, then direct yes.

If it does not break, it means to find a non-cracked lattice four weeks from this point.

So as long as there is a beginning to the end of the path, and the end of the surrounding existence of >=2 a non-cracked lattice can be

D. Bad Luck

The bad Luck are inhabited by three kinds of species: R Rocks, s scissors and p papers. At some moments of time both random individuals meet (all pairs of individuals can meet equiprobably), and if they belong t o different species, then one individual kills the other one:a rock kills scissors, scissors kill paper, and paper kills A rock. Your task is to determine for each species, what's the probability, this species would be, the only one to inhabit this Island after a long enough period of time.

When I saw such a simple d, I was stunned ...

Define a f[i,j,k] to indicate the probability of having I stone j scissors k Cloth

The initial situation is f[r,s,p]=1, and then the previous push is easier

When the stone is reduced by 1, it means a stone meets a cloth, the probability is i*k/(i*k+i*j+k*k)

Note that the denominator here is not C (i+j+k,2), because when two of the same kind of villagers meet, nothing can be ignored

The other two things are the same.

E. Infinite inversions

There is a infinite sequence consisting of all positive integers in the increasing order:  p = {1, 2, 3, ...}. We performed  n  swapoperations with this Sequence. A  swap ( a , b )  is an operation of swapping the elements of The sequence on Positions  a  and  b . Your task is to find the number of inversions in the resulting sequence, i.e. the number of such index Pairs  ( i , J ), That  I < J  and   p i > p J .

/blockquote>

I was shocked to see the simple e ...

Scatter the data and then simulate it and then count the reverse as if it were possible ...

Of course it's just part of the answer.

And some of those numbers that don't appear in the reading.

For every number that appears in the re-read, just count the number of non-occurrences that precede it in its current position.

This can be preprocessed, then prefixed and, finally, counted.

(See a tag is trees, said very do not understand ...)

To refuel ah ....

In addition, I wish

Master ye-ye-ye, Duchi the country team

CTSC Successful abuse field

2/. May

Codeforces Round #301 Problem Solving report

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.