Hello everyone! Codeforces Round #254 is coming soon.

In this round, there will be a really cute boy named DZY. He loves many things, we can even say everything. He has a great passion for the gorgeous world, but he can't deal with everything he's interested in. So he needs your help, and he will present rating in return.

My thanks go to Gerald, who gave me much advice and helped about the problems. And I also would like to thank MikeMirzayanov, who created such a wonderful platform.

The problem setters are FancyCoder and me, and thank vfleaking, jqdai0815 and lsmll for testing.

Come and join us in helping DZY.

Good luck and have fun.

**UPD**

In Div. 1, scores for each problem will be **500-1000-2000-2000-2500**.

In Div. 2, scores for each problem will be **500-1000-1500-2000-3000**.

**UPD**

For technical reasons, the round will be delayed by 5 minutes.

**UPD**

The contest is over. Thanks for participating.

Congrats the winners.

Division 1:

Division 2:

You can find editorial here

Finally :D

A contest announcement,after almost 20days.

It will have a record high of registrants! :D

We hope so.

I can't just believe that I had been waiting a month for this contest.

I wish DZY to be a MERCIFUL guy ..... Everyone Good Luck and Have FUN :)

Sure, he is :)

:)

From my point of view,the problems are all very interesting.Wish you high rating!

PS:DZY's CF handle is dzy493941464.

Hmmm chinese contest. Brave yourselves guys!!

Actually all we need is bravery :))

Brace*

Sounds great! I love cute boys (and girls)!

u love both boys and girls !!! don't confused us about your gender ;) :P

well, some people are just too lovely...

this is the contest after more half month. FUNNY ! :D

the Chinese IOI team 0_0

Brace yourselves, DZY loves desert (http://vfleaking.blog.163.com/blog/static/174807634201422485914893/) incoming...

DZY loves DYNAMIC CACTUS.

20k length…

Link-Cut Cactus??? WTF! So beautiful!

omagad :O! Firstly CACTUS and secondly LINK-CUT? https://www.youtube.com/watch?v=McaV4Ua-QMA (translation ~ "exploding brain") You Chinese are really crazy :P. Hope that I won't see any cactuses in this contest :P.

You had no decrease in your rating chart!

I hope I will get expert in this contest http :D

hope the testing system will testing quick after the contest

Probably won't be able to participate in the contest cause here in Bangladesh its the time for iftar(time to break fasting in the holy month of Ramadan) :( :( BTW best wishes for other participants....

That doesn't prevent you from participating you can put a lot of dates with water beside you :) and continue eating after the contest.

Taking food is not the problem!! The important thing is magrib prayer. Besides there is Isha prayer as well as tarawih prayer which starts within one and half hour of iftar. After all its ok cause, "To get something u have to lose something". Inshallah will enjoy plenty of contests in later days :) :)

How to register this competition?

Registration will be available after 2 Days

http://codeforces.com/contests/444,445

bvd

hey DZY please grow up and try to solve your problems by yourself ! :)

but then we will not have a contest, do you want to wait more for a contest after waiting two weeks? :P

please how i can register to the contest i'm new here

Registration will be open in 3 hours. It always starts 24 hours before the start of the contest.

it's now 24 hours before the start of contest, but the Contests page says that registration for the round will open in

9 more hoursonly.Please don't use such silly names; they confuse us.

They make us dizzy.

hehehe yeahhhhhhhhh

Why are we having so few rounds these days? Even TopCoder has only 2 SRMS planned this month :/

Because the Chinese students in preparation for the final exam.//hahaha~

sad its timing clashes with the timing of wimbeldon finals

i hope Federer wins! :)

also, i hope that the Wimbledon final takes more than 2 hrs to finish, then we can watch it after contest is over :)

same here

because of round extension by 5 minutes, maybe we can even watch the first game! ;)

good news. only

two setsare over, and both players have wonone each.so we still have a long way to go! :)

yeah ...and hope federer wins this one

hey DZY take it easy !

WARNING: Mathyround approaching!"DZY loves math xxx"

so he also loves DP, probability, graphs, geometry, data structures (and many more concepts) in addition to just math. ;)

It seems that my prediction was wrong :p

However, round #255 was indeed a very mathy round :D

PS: authors of round #255 is the same as "DZY loves math" series in BZOJ(a Chinese online judge contains only

very tough problems)what round #

255? u mean round #FF, right? ;)I don't have my library currently and my last contest was more than 2 months ago. My question is can I do it as a virtual contest during the same time as the official contest?

PS: For all coders who don't have an online backup for their library, do it ASAP. My laptop's HDD crashed recently and I don't even know yet if the data can be recovered.

I don't think that I notice virtual contest button appear after final system test.

And, what about the unusual contest time??

From the "Urban Dictionary":

DZY

1)Complementary definition of a person, place, or thing..that epitomizes the elements of sheik, classy, cool,or just downright unique.

2) An intensifier

3) Kastration technique (????)

4) Generally used to describe a very cool person

5) Nondescript term that can be used to define anything that is awesome, over the top, and dope.

4) Generally used to describe a very cool person

Now i understand ..

There was a few consecutive contests without delay but I think it's back! Good Luck

Extended by 5 minutes.!

Pretty tough competition, but great fun!

I liked

`B`

a lot, though using the randomness of the simple generator felt a bit risky.Was problem

`A`

greedy somehow?Yes; choose the edge that gives the maximum density. (The induced subgraph will have two vertices.)

Oh...

Because if we have already picked some nodes

`vs`

and edges`es`

, and we want to add node`u`

with`e`

being the sum of edges from`vs`

to`u`

, then we must have`(vs+c)/(es+e) > vs/es`

, but that implies`c/e > (vs+c)/(es+e)`

so clearly just picking`c`

and any node from`vs`

would be a better choice.Thanks :D

Exactly. I went on and proved that first before submitting my solution to ensure correctness. :P

Of course, you have to pick the node in

`vs`

that is connected to`c`

, but that's why you inspect each edge (instead of any pair of vertices) to ensure the connectivity.for A, we always had to choose

two nodesandone edge. adding more edges will make the density lower.Please can anyone tell me how to do Div2 C ?

new graph consists of 1 edge. :)

OMG I should have thought of that! :(

how to prove it's the optimal solution?

Just above you.

Answer is the best (x[i]+x[j])/c(i,j) where i,j are vertices

how to solve Div-1 B?

also, why my code 7029179 gives

WA#9?del

Problem E uses Inteval Tree (Segment Tree) ?

Oh God, a stupid mistake, in problems B div 1 I use ios::sync_with_stdio(false) but then I use print("%d"). May my code will fail system test because that mistake ?

nope

No, if you used only printf

Contest is difficulty with me !

How solved problem B ?

Put chemicals in order of DFS then caculate danger. I learnt to code DFS when contest is running LOL.

Fast system :D

Good Contest ... Thanks Authors ...

Segment Tree range updates in problem E/Div2 C/Div1 was very similar to UVA12436

UPD : ok ok ... DownVoters i got ... in case colors was fixed this kind of solution would be correct , but in this problem, it wont work ... I hope some days we only DownVote to rude speeches, NOT WRONG IDEAsVery quickly system testing :D

very fast system testing! :)

I liked the round a lot. C was super nice , I solved it on paper with sets and an segment tree. ( but I'm not sure it's ok ) I got WA on B for something that I thought it works in O(N log N) , but got TLE. Overall , very nice round even though I think I'm going to be div2 after it. :)) Congrats for the authors !

Definitely, fastest system test!

Following my previous blog post on ranking submissions as a collaborative wisdom for picking good reference solutions, i.e. http://codeforces.com/blog/entry/12917, you can now vote your favourite submissions for this contest at:

Div1: http://hiukim.com/cfsubmissions/contest.php?contestId=444

Div2: http://hiukim.com/cfsubmissions/contest.php?contestId=445

Damn it. One character and I'm the first:

What's even more painful is that I wrote right at first, then changed it for testing purposes and then forget to change it back.

This bug has costed me 100 points.I have clicked once submit.

I wrote lots of code for C(div 2). Than I recognized we just need two nodes and an edge. :(

My code got wrong answer on pretest 5 div2 A. I see the test case but I think my output is also correct. Can someone check it for me please? http://codeforces.com/contest/445/submission/7032620

On the second line of your output, you have two B's next to each other.

Oh I see. Thanks

Next time you should take a look at checker comment before asking such questions

I did but I was such in a hurry to find the wrong one and angry because of not being accepted, so I didn't see it. You're right. Thanks for your advice

the fourth last line, the last two characters are the same.

"wrong answer Two same chessmen stand in adjacent cells 2, 27 and 2,28" . Check those places, BB occurring there.

will there be any solutions posted?

Editorial will be posted very soon. BTW,the contestants' solution for Div1 E was unexpected to us...Our solution was far more slower,that's why

nis only 3000Anyone who tried to exploit the random generator in 1B? Many solutions (including mine) depends on randomness. Problem statement blocked the unique fixed point, but there might be some small cycle which can hack these kinds of solutions.

Our intended solution do depend on randomness,so we blocked that number.

Is there any solution for arbitrary permutations (better than straightforward n^2)?

Check it out in another thread

Oops, I forgot people might try to hack that. I was relying on the problem setters being nice :-)

If there is a 1-cycle, probably there are also cycles of most other lengths?

No, there are one 1000000006-cycle and one 1-cycle.

Seems like authors considered such hack :-

Any proof for that?

1e9+7 mean nothing, brute it.

I don't know if

`% (i + 1)`

could help create some "cool" sequence, likely not.You can get the explicit formula of this sequence, and you will find 37 is the primitive root of 10^9+7, so the cycle's length is 10^9+6.

This is very interesting. So actually the 10007 term was unnecessary and nearly half of all numbers less than 10^9+7 would have worked as factors. At least these would all have given a 10^9+6 cycle.

http://mathworld.wolfram.com/PrimitiveRoot.html

How to get on the main page after the contest without actually participating. =)

I have used 4 Segment tree to get AC problem C (after the contest). Does anyone have better solution? Thank you.

waiting for editorials...

How to solve div2D? FFT?

A Div2 was harder than a usual A Div2

English Editorial has been posted!

interesting problem set, I wrote complicated solutions for C and E, and got very simple solutions after reading subscriber's code, cool!

3 bytes far from all clear orz.

Very nice round. I liked the problems even though i only managed to solve 1. Div. 1 A proved to be a nice revelation. I got the idea by thinking back to when i used to play online shooters when I wanted to maximize my kdr (Kill-Death Ratio). Say my current kdr was K/D and in a match i'd manage to get k kills and d deaths. Now if k/d > K/D then (K+k)/(D+d) > K/D and my kdr would grow or it would fall otherwise. The same thing applies to the problem at hand.

The TIme limit for problem C should have been 3s. My algo was correct (used sqrt-decomposition) but I had to reduce the size of each partition by a constant amount to get it accepted.

What's the problem then? It's absolutely OK that some implementation details matter a lot, imho.

You can see the country wise standings for the contest here. In case you want to report bugs / suggest features, kindly use this blog.

Round Stats

Div1-B can be solved without regard to randomness in time. See 7031500

I'm curious why do you use integers in your BitSet? For example my implementation with longs 7040099 works like 1.5 times faster than same with ints 7040106.

It seems to me that and

O(n^{2}) are same, therefore there is no reason to write 32 in the denominator.Formally, they are, but in this case, the /32 factor is used to denote that the constant factor will be that much smaller.

Still my notation leads to a little bit better understanding of actual solution timing, isn't it?

How to solve div1 C using segment tree ?