On Oct/11/2018 17:50 (Moscow time) Educational Codeforces Round 52 (Rated for Div. 2) will start. Series of Educational Rounds continue being held as Harbour.Space University initiative! You can read the details about the cooperation between Harbour.Space University and Codeforces in the blog post.

This round will be **rated for the participants with rating lower than 2100**. It will be held on extented ACM ICPC rules. The penalty for each incorrect submission until the submission with a full solution is 10 minutes. After the end of the contest you will have 12 hours to hack any solution you want. You will have access to copy any solution and test it locally.

You will be given **7 problems** and **2 hours** to solve them.

The problems were invented and prepared by Roman Ajosteen Glazov, Adilbek adedalic Dalabaev, Vladimir Vovuh Petrov, Ivan BledDest Androsov and me.

Good luck to all participants!

**UPD 1:** Our friends from Harbour.Space University are proposing you an unprecedented offer of free (and even with a scholarship!) robotics study in Barcelona! Read the details in the post by the link https://codeforces.com/blog/entry/62357

**UPD 2:** I'll be on the community Discord server shortly after the contest to discuss the problems.

Congratulations to the winners:

Rank | Competitor | Problems Solved | Penalty |
---|---|---|---|

1 | isaf27 | 7 | 263 |

2 | HanwhaEagles | 7 | 340 |

3 | Seraphimon | 6 | 251 |

4 | CJYeong | 6 | 273 |

5 | -vjudge- | 6 | 280 |

Congratulations to the best hackers:

Rank | Competitor | Hack Count |
---|---|---|

1 | Laggy | 63:-10 |

2 | Doriath | 38 |

3 | BohdanPastuschak | 38:-7 |

4 | Kerman | 36:-6 |

5 | zoooma13 | 33:-2 |

And finally people who were the first to solve each problem:

Problem | Competitor | Penalty |
---|---|---|

A | xiaowuc1 | 0:01 |

B | xiaowuc1 | 0:03 |

C | HanwhaEagles | 0:07 |

D | isaf27 | 0:33 |

E | Kyouko | 0:19 |

F | mHuman | 0:35 |

G | tfg | 0:44 |

**UPD 3**: Editorial is published

Educational aka KILL YOUR RATING contest in da house again!

I think it's vice versa, you can really make comeback and get new high rating in Educational rounds.

PikMike and his Educational rounds :D

The greatest hacker halyavin will hack us. Thank you for finding bugs:D

^^Those hacks scare me after every educational codeforces round :(

upd: halyavin didn't appear in this roundThanks to MikeMirzayanov for such a great polygon.

I like Educational Round very much!

Thanks for Codeforces!

Will all problems be about robots?

No, about math

+1

I just hope you're wrong... Though, sadly, I think you'll be right. I'd like to see a Segment Tree + DP problem, something with queries or string, or anything but math. It's like those kind of problems are out of fashion lately. Ugliness and boredom is what programmers are looking for apparently.

`is what programmers are looking for`

I guess programmers aren't looking for math. Just, they are finding only that type of problems.wow, I took a look at cf rounds after a long time, and now it turns out that educational rounds are almost rated for me (I'm away just by 110 points)

Thank you friends from Harbour.Space University

i cant rally undasternd if or no is rated?

You always ask this question it's ridiculous, stop it please.

Educational round! <3

delay

Sorry, we had some troubles with preparing the tasks, so the contest is postponed to 14:50 UTC.

It's a good sign of problems' quality xD

The delay !!!

Good luck to everyone, have a nice contest!

OMG OMG OMG OMG OMG IS IT RATED ?? ? ? ? PICKMIKE DO NOT TELL LIE TO PEOPLE IT WON'T BE RATED!!! KEKEKKEKEKEKKEKEKEKEKKEKEK

I want moooore dislikes

delayed :(

- :v

*It works

First contest. Wish everyone good luck and high ratings!

good luck!

I'm from Viet Nam, Hello everyone, that is the first contest. Wish everyone good luck.

Empty contest xD

Excuse me, WTF?

What is happening to the contest?

Statements are so short, that they don't even exist!! Wow!

Where is the problemset??

WTH, where are the problems? LOL

Might be helpful to copy the upd in the post to the comments)

I'll be on the community Discord server shortly after the contest to discuss the problems.

what a nice problem D is!

contest isn't finished!

Hats Off! A well balanced contest :)it would be better if D was a little easier

better if D wasn't in the contest

How to solve D?(My solution is bfs with lots of states, and will probably fail).

I did bfs with state = (row, column, target_number, piece). This works because you process all states with distance 0, distance 1, distance 2, and so on, so if there is another state that arrives other states (already in the queue) you can update the min number of changes of that state.

What is F test case 4 ?

I believe its a complicated version of this.

Answer should be 5

Why the Answer is 5？

I have draw this tree and the tree in test case 4. They are truly Homologous cases. But I cannot understand why the answer of this case is 5.

You go 1 -> 4 -> 2 -> 5 -> 1 -> 8 -> 7 -> 9 -> 7 -> 10, covering all 5 leaves.

I get it.Thank you.

I coded problem D for more than 1 hour and I couldn't submit it for 30 seconds.

Took me way too long to notice that a semi-naive solution fits time limit in G (44152174) :(.

F and G were very nice problems, but it's kind of silly that the hardest problem was D

Couldn't debug my solution for C throughout the round and lost interest halfway :( RIP rating

Can someone help? 44139210

What is the 3rd test case for Problem C ?

I had a wa on 3d test because my solution idea was wrong the answer is not the amount of cubes divided by k because each slice is not necessarily the same amount of cubes and anyway i just got hacked :( so sad

Is there anyone who solved D in djkstra's algorithm?

Me

I didn't know that djkstra's can be coded with multiset XD I only used priority queue before what is faster?

Priority queue of course. How could it be slower when it implements a strict subset of the functions that a multiset implements :Dd

That makes sense Thanks:)

Well, it depends. With priority queue implementations, usually you insert a node into the queue whenever you find a better cost for that node, which can happen O(E) times, therefore your priority queue with have O(E) size. With a set implementation, when you find successfully relax a node, you look it up and update it (which you can't do in a normal priority queue). Therefore, your set will have O(V) size and usually V < E in problems. I agree many times priority queue will be faster (I personally implement with priority queue as well), but the issue isn't as simple as "it implements a strict subset of the functions, therefore it is faster". The very fact that it is not as powerful means there's certain things you might want to do, but you can not (things that would speed up your solution).

How?

Dijkstra is overkill, BFS is enough

dude, cool contest! thanks a lot

How to solve problem D

Can anyone hack me?Please hack me!HACK ME PLS,PLS,PLS

What idiot wants to be hacked after the contest?

How to solve F?

In addition to the directed tree, we add an edge from each leaf to its kth parent (or the root if there is no kth parent). Now we want to find a path which maximizes the number of different leaves on it, which can be done with SCC + DP.

Or for every leaf node find the node which smallest depth achievable by jumping to leaf to leaf and increase the value of that node(initial all nodes value 0). After we will do dp with our value of nodes.

dp[nd] =max(dp[childsofnd]) +value[nd]Btw we will do first part by segment tree+binary lifting.

Here is my code: 44154622

Or we can use DSU to maintain SCC's with each connected component storing the number of leafs present in them. Then the problem will reduce to finding a path in a tree from root to leaf, having maximum value. It is quite simple to implement this. Here is my code : 44159892

When you running dfs,for each node maintain two value bk(can back) and dbk(dont come back),the answer is bk[1]+dbk[1].

44179107 this code is short

.

I hacked few people with this test:

5 6

3 3 3 3 3

Answer: 0

Your code outputs: 1

fuck, I got hacked in this stupid test

whats the logic for E?

How to solve C ?

heights of tower = th[1...n]

max(th[i]) = mx

min(th[i]) = mn

Let array B of size (mx-mn) , B[1....(mx-mn)] , where B[i] = number of cubes at height[i+mn]

now problem reduces to find the minimum number of contiguous subsegments of array B such that sum of each segment is less or equal to k.

O(max(n,(mx-mn)

My solution for C got hacked but when I submitted the same solution again it's getting accepted.Can someone explain me why this happened?

same here

edit: after I resubmitted the same solution it got accepted and got hacked again lol

deleted.

Not true. Tests are added to the testset during the hacking phase, but it doesn't rebuild the problem packages instantly. You can expect the test to get added to the testset in like half an hour or so.

Do you know the hack for it? My binary search got hacked.

long double g=ceil((1+sqrt(1+(8*m)))/2.0);

if(m==0)

cout<<n<<" "<<n;

else

cout<<max((long long)0,n-(2*m))<<" "<<n-(long long)g;

I solved B using maths ,where g is the minimum number of nodes which can contain g edges and strongly connected. We know in strongly connect graph n(n-1)=total no. of edges. So by solving quadratic equation I got the value of g,and I considered it's upper bound. I hope it's correct.

i was solving this by same approach ..... i dont know what was i doing as i was using 4*m^2 and now i realized this is due to pressure..lol

Nevermind.

How to solve E?

The problem turns into:

You have 2 strings of same size (ignore the middle position if the size is odd) and you can swap prefixes of some given sizes. Find the number of equivalent groups.

First, note that you can swap the intervals between the swap sizes independently. This means you can just count the number of equivalence classes in each group and multiply them to find the total number of equivalence classes.

If you have a group of size S, you have A^S classes with both sides being equal and (A^2S — A^S) / 2 classes with both sides being different. After this, you just need to multiply A^(number of characters outside of groups) because they never change.

great problems :) thanks :D

How to solve D?

Hey natofp, I just solved it with dijkstra's algorithm. Try to minimize (moves, replacements) (sort by moves and then replacements)

Then you can keep track of the state [3][node][level].

The idea is that you can hit multiple nodes from reaching a to a+1. Therefore, we denote 1, 2, ... n as a separate dimension called [level] (the target points or breakpoints we travel through) We can just update level when the node we are on matches the next "level" in the path we need to hit.

And then for the inidividual nodes along the way we have another dimension [node] which is just the current node we are on.

And the [3] is just knight,rook, or bishop.

As an implementation details, by n I actually mean the total amount of nodes so n = 100. If you do this way you have to convert numbers values to row/col and vice versa.

My code: https://pastebin.com/ghseX4WT

Possible Case of Cheating! PikMike

Wtf comments?

To avoid cheating detector I assume...

But maybe hes just trolling and didn't cheat. I think the detector ignores comments anyways.

Here's another

https://codeforces.com/contest/1065/submission/44145755

https://codeforces.com/contest/1065/submission/44146818

If i hack someone will it improve my ranknoIt will (indirectly) if you hack someone ranked above you.

Is it possible to solve C in a fast way if we expand the restriction of 1 <= ai <= 2e5? I'm sure most who solved made observation that vertical was easier than horizontal (because the cuts were horizontal lines), but what about 1 <= ai <= 2e9, is there a good solution for it if we are forced to solve horizontally?

Discretizate ai and then use segment tree

Yeah, my solution was actually horizontal (still O(N log N) cause i gotta sort).

https://codeforces.com/contest/1065/submission/44166753

Thanks, this is what I was looking for.

My solution was horizontal as well, without the extra log factor because I didn't sort, but for some stupid reason I kept getting WA, so I decided to rage quit the contest and went play some Hollow Knight.

By "expand"the restriction I mean make it bigger, so im asking for a solution where ai <= 2e9 instead (where this method wouldn't work, as I also used this idea)

Educational round and halyavin hasn't made a single hack yet? That's weird :P

Is there going to be an editorial? :)

Why for educational rounds system testing takes very long to start ?

This round had a 12h hacking phase after which the system testing started.

Yea 12 hour. But after 12 hrs it takes normally 1 — 3 hrs to start.

Can we get rating in this race?

This round is rated for all users below 2100.

Sorry halyavin

editorial?