<almost-copy-pasted-part>

Hello! Codeforces Round #617 (Div. 3) will start at Feb/04/2020 17:35 (Moscow time). You will be offered 6 or 7 problems (or 8) with expected difficulties to compose an interesting competition for participants with ratings up to 1600. However, all of you who wish to take part and have rating 1600 or higher, can register for the round unofficially.

The round will be hosted by rules of educational rounds (extended ACM-ICPC). Thus, during the round, solutions will be judged on preliminary tests, and after the round it will be a 12-hour phase of open hacks. I tried to make strong tests — just like you will be upset if many solutions fail after the contest is over.

You will be given 6 or 7 (or 8) problems and 2 hours to solve them.

Note that **the penalty** for the wrong submission in this round (and the following Div. 3 rounds) is **10 minutes**.

Remember that only the *trusted participants of the third division* will be included in the official standings table. As it is written by link, this is a compulsory measure for combating unsporting behavior. To qualify as a *trusted participants of the third division*, you must:

- take part in at least two rated rounds (and solve at least one problem in each of them),
- do not have a point of 1900 or higher in the rating.

**Regardless of whether you are a trusted participant of the third division or not, if your rating is less than 1600, then the round will be rated for you.**

Thanks to MikeMirzayanov for the platform, help with ideas for problems and for coordination of my work. Thanks to my good friends Daria nooinenoojno Stepanova, Mikhail awoo Piklyaev, Maksim Neon Mescheryakov and Ivan BledDest Androsov for help in round preparation and testing the round.

Good luck!

</almost-copy-pasted-part>

**UPD**: Editorial is published!

Good Luck to all participants!

so sad that people downvoteing :/

why is it sad?

I hope I will be able to do more than 1 problem this time xD

I know there is a Points Penalty of 50 points but what is the Time Penalty all about?

.

Educational CF Round and Div.3 Round have no points penalty. Instead, they have time penalty, which depends on the time when a participant submitted correct submission and the number of wrong submission. In detail, if you solved problem k minutes after the start of the competition, your solved problem number increases by 1, and your penalty increases by 10×(the number of wrong submission on that problem)+k.

Looks great! Maybe this is the round when I finally become rated. ;O

Why are you so eager to become green?

Because It is there.

you can't because this contest is only rated for trusted participants. And the criteria being trusted is

take part in at least two rated rounds (and solve at least one problem in each of them)do not have a point of 1900 or higher in the rating.and you didn't participate any contest till now.

Regardless of whether you are a trusted participant of the third division or not, if your rating is less than 1600, then the round will be rated for you.

I registered when I was cyan (during previous Div.2 contest) and now my Handle in registrants list doesn't have a star(*) next to it . Is it gonna be rated for me and people like me or not ? If yes I hope you fix it cause I don't think it's gonna be fair this way.

you can deregister yourself by going to the registants page and click the red x button :D

Come on！！！

Can my rating increase or decrease if I am an unofficial participant and I take part in this Div3 ?

nope

OK,I know. Thank you!

Div. 3!! So it is vovuh xD

Vovuh and Codeforces div3 rounds.

Please upvote my contribution lies in -30

)

i think anyone can't write div3

what about the score distribution?

Div 3 and Educational Rounds don't have score distribution.

They have penalties on time

What is score distribution?

All problems score is same. which is

A-B-C-D-E-F-G

1-1-1-1-1-1-1

I am late some minutes. Is it not possible to register after contest has started?

I am not able to submit :/

i overslept the registration...

A difficult one.

I forgot to register...

F

Can we hack any solution in this contest ? When does it start ?

The hacking phase starts after the contest ends.

How to solve E?

Solution for $$$E2$$$:

Firstly observe that the question asks to use minimum number of colors such that subsequence formed by each color is sorted.

Consider the longest decreasing subsequence (LDS) of the given array. Observe that no two elements of this sequence can be given the same color, hence number of colors must be greater than or equal to the length of the LDS.

Now, to find a coloring with number of colors equal to length of LDS, let $$$lds(i)$$$ denote the length of longest decreasing subsequence which ends at $$$i$$$ and includes the $$$i$$$th element. Observe that if $$$a_i > a_j$$$ with $$$i < j$$$, then $$$lds(j) > lds(i)$$$. Importantly, $$$lds(j) \neq lds(i)$$$. Thus, you can just assign the $$$i$$$th element the color $$$lds(i)$$$.

But LDS will take n^2 time right?

No. You can find LDS in $$$O(n \log{k})$$$ where $$$k$$$ is the size of the alphabet using binary search/fenwick tree/segment tree. Even a simple $$$O(nk)$$$ algorithm will work for this problem. Search online for LIS solutions.

Nice construction. Thanks!

By the way, how did you come up with this LDS construction. It seems so..... exotic. It's really very nice.

Had you encountered a similar problem before, or did you come up with the solution from scratch?

No, I just happened to stumble upon it.

You can also just check that a letter can't be assigned to the same color of any letter that has greater value and appears before (it is an inversion). I assigned bitmasks to every letter and every mask will have a bit of the corresponding color active if there is a letter that was already assigned to that color.

What's the reason 70267449 'Compilation Error' in C++17 but the same 70270849 worked on C++14 ?

Name collision with data function, which was added in c++17

There's a template function in c++17 names "std::data", which makes your data variable ambiguous

I signed up for this div3 before the score reached 1600.Can anybody tell me that Will I be rated in this situation?Thanks~(I didnt find the star '*' beside my name during the competition)

STLforces :)

Can someone explain to me how does the Test Case #1 for question-d is correct?

I keep finding 6.

You need 2 tricks for 10 and 50 (10-2-3-2-(?)-2-(?)-2), same mechanism for 50. So you can't have 50 and 10 simultaneously

Thanks.

Now it is clear.

first , fourth and fifth monster can be killed without secret technique . Last monster can be killed by using technique once and rest of the monsters can be only killed using technique twice .

GreedyForces

CodeGreedy

My rating is less than 1600 now, but why I'm not in the official standings of the contest?

May be you have not registered for the contest...

Maybe you have not registered for the contest... Sorry commented again

You were expert, the time you registered for the contest. So you are out of competiton.

hello I'm new to CF great problems! I like E2 and F very much

Fun fact: if you change statement of E2 so that you have to color all occurences of a fixed letter the same color and let alphabet size vary, you get an NP-complete problem by reducing to graph coloring.

UPD: no, that's actually wrong. Reduction I was thinking about was associating every vertex a single letter and then finding some permutation such that the graph is what you want. But that is wrong: there are $$$ n! \sim \sqrt{2 \pi n} \left(\frac{n}{e}\right)^n $$$ permutations but $$$ 2^{C_n^2} $$$ graphs and there is no way to have a surjection.

What is wrong with thislink for problem A(div3).

5

2 2 2 2 2

check this case

my solution to C

can anyone tell why this fails on test case 6? I transformed the string into integer array and used greedy approach to find the smallest sub array with 0 sum.

Using +2 for "UP" and +1 for "RIGHT" means that your program thinks "ULL" is a net-zero sequence of moves. You could do some approach like this, if you did +N for "UP" and +1 for "RIGHT", then there would be no ambiguity because it would be impossible for enough L's to cancel out a U. Or you could just keep track of the sum into two parts, a netVertical and netHorizontal.

but i am never considering odd sized subarrays, I am only checking for even sized subarray starting with 2, hence, I will never check for ULL.

See

nathan_drake's example, even if it is even, you can still fall into that situationgot it. I iz noob : (

1 6 UULLLL

just replace 2 with 10^6 but your code will still be tle, try hashmap, changed solution of yours it passes test case 6 my solution with hashmap with linear time complexity

Any good testcase for hacks ?

I didn't solved a single problem, I feel so dumb right now...

everyone didn't solved a single problem at the first time... cheer up man practice hard and get ready for the next contest.

@Ernis In the Codeforces Educational Round #81, I am also not able to solve a single problem. But in this contest, I performed decently. So just compete and don't give up.

Try to upsolve problems after contest has over ..its better for U

Yes, i try to do that

Are there some extra spaces in Test case 6 of problem C? Using s.length() in C++ was giving runtime error while replacing it with n gave wrong answer.RE WA

may be the run time error because s.length type is unsigned integer so when the length is 0

1 — length equal to unsigned integer max not -1

input string is not empty as n is greater than 1

i mean this s.length()-4 in your code

Print s.length()-3 and check the value then your questiom will be "how it passed 1st 5 cases?"

can we solve E1 by using bubble sort to generate a graph where there is an edge between two letters if we have to swap them, then check if this generated graph is a bipartite graph ?

Any hacks for D?

How to solve F?

Sort the query asked by passenger in increasing order of minimum distance in path.

now let for query(a,b,g) if i already assigned all edges with cost less g and assign all edge in path from a to b with g(if any edge is already assigned with less cost then reassign it with g) then minimum cost for a path can't be less than g. Since i am assigning the cost in increasing order then it might be the case that minimum cost in path from a to b can be greater than g(let after reassigning all edge with cost>g). So assign cost to all edges that come in path for every query in increasing order of cost and after processing all query check the minimum cost for every path in query if it doesn't match then there is no valid answer. if every query matches then we have the answer.

here is my submission

I solved it in O(n^2) but i am curious to know any soln with less complexity.

Check it here

in d) why ((x-a)+a-1)/a where x is remainder when divided by (a+b), please help?

tmwilliamlin168 solutions for div 3

super helpful!

How to solve C?

Store current location During iteration, you can start (0, 0) to increase the values according to L, U, R and D. Store the last locations viewed in a map or group, and when you reach a point you have seen before, store the difference between them and type the smallest distance

please give idea to solve C & D

For C

Store the current location while iterating you can begin at (0, 0) increase the values accordingly for L, U, R and D

Store the last seen locations in a map or set and when you reach a point you've seen before check if the distance between the current index and index of where you last met the point is minimum and save it as your result.

For D

Calculate the number of tricks (the secret technique) you will need to gain points from each monster ignore if 0 (add 1 point to the result since you already earned it) sort the other trick values and pick from the minimum while k is sufficient

You will need a trick if h mod (a + b) = 0, you need exactly ceil(b / a) tricks for that

Or if h mod (a + b) > a let's call the remainder rem you need exactly ceil(rem — a / a) tricks for that.

Can someone hack this

Round has ended recently and now I'm really can't explain why my E2 solution works

Interesting experience :D

where is the editorial for this round?? [contest: #617 (Div. 3)]

I've found few Guys Rampantly Cheating during Contests. Can Anyone please guide me, how to take this forward and make sure that this is seen by MikeMirzayanov , and there accounts are banned!

Manthan_144

and

rajan_ladani

Here are the Submissions they did in Codeforces Round #617 (Div. 3), and it clearly Shows that they are Big Cheats!

The Submission Of E1/E2 is clearly copied, and several redundant while loops have been added in order to escape from the copy-checker mechanism!

Manthan_144 :: 70282306

rajan_ladani :: 70294414

Apart From this they have also copied A,B,C,D

Guys please dont be cheats, and respect the community!

Tagging the Round Co-ordinators, so they can take some action

vovuh nooinenoojno awoo Neon BledDest

70254356 Why doesn't this solution end up in TLE? If we consider the number of operations it should be slow. I tried the same solution in GNU C++ 17 in custom invocation and this solution ends up in TLE but in MS C++ 17 it passes easily. Is there some kind of optimization in MS Visual C++? What am I missing here?

Interesting, if someone could throw a light it'd be great.

.

So someone replaced D with C .

so D is easier? :D

YUPP

Any ideas on how to solve C in C#? My 70280505 with Dictionary looks correct in principle but too slow.

So, it was a bad idea to use struct as a key in Dictionary because the hash generation is slow.

How to solve E using graphs ??

I feel that C was comparatively difficult than D.

but I felt D was slightly difficult

What is the hack case is F? pajenegod

UPD :It TLEedI was doing TLE hacks. In the end I was able to hack more than $$$100$$$ submissions with the same hack. My test was just to construct a tree in the form of a line, then do queries from one end to the other with weight $$$10^6$$$. To make the queries a bit heavier I made all the labels random and never asked the same query twice.

One fun thing to note was that my test case hacked the checker for the problem.

I've seen my hack take $$$46$$$ ms submissions to $$$1.3$$$ s, so my test was far heavier than the original test cases. Honestly the reason why my hack was so effective was because the original $$$267$$$ test cases were really sub-par. Not only did they not test the obvious max case, there were also obvious patterns in the data. For example if you made node $$$1$$$ be the root, then

`parent[i] < i`

in every single one of the original $$$267$$$ test cases. dorijanlendvaj noticed this pattern after I showed him a $$$46$$$ ms submission that I had made TLE. He figured out that the code got stuck in an infinite loop if`parent[i] > i`

, which never happened in the original test cases.Honestly, I did not expect such weak pretests.

When will the ratings get updated? I think i'll get a pretty good boost! xd

Don't know about you guys...For me this is the best contest ever...

Why are some experts getting rated ?

Proof

My submission was TLE on System test. https://codeforces.com/contest/1296/submission/70275201

I submitted same code and got AC. https://codeforces.com/contest/1296/submission/70355834

Does this happen often?

It happens often if your solution runs closer to the TL. Runtimes can vary quite a lot (maybe up to 200 ms), but usually 30-60 ms.

Just so you know, you could have just done

`c[x,y]`

instead of`c[str(x) + "," + str(y)]`

dantrag pajenegod

Thank you for your reply. I would like to write optimal code.

.

in question C for 3rd division cant we use prefix-sums and check for sum of 'L' & 'R' for size 2 and sum of 'L'+'R'+'U'+'D' in the string and print the index where we get it.... what is wrong in this approach!!! on which edge case it might be wrong!! please help

The cycles can be not only of length 2 and 4.

Correct answer is

`1 8`

.thankyou so much

Can anyone explain the tutorial of prob E2?

Well problem F is clearly overrated :|

Hello, could someone help me check my submission for problem F? It got time limit exceeded on test 271. I already check it in my computer with a line graph, and it is slow (took around 7 seconds). I have no clue why it happened. Submission link: https://codeforces.com/contest/1296/submission/71952020. Thank you!