Recent actions
On KANVK Cup 2018 — Wild-card Round 1, 101 minute(s) ago

You can add these problems to a mash up in the gym and then you can solve them without the language restriction.

On KANVK Cup 2018 — Wild-card Round 1, 30 hours ago

you have to think positively,bro.

I do .

On KANVK Cup 2018 — Wild-card Round 1, 43 hours ago

Could we submit these problems by any language now? It's difficult for me to translate C++ to other language and I really want to have change to slove these problem...


I think Dozebear doesn't want to have same colour as you


Just Boring :(


To solve J, I maintain a set of disjoint ranges. For example: if I insert the range [2, 4] and then [3,6], my set will contain only {[2, 6]}. But if I insert [5, 6] instead of [3, 6], the set will be {[2, 4], [5, 6]}.

You can see that the answer will be the amount of elements in the set, because the points that belong to different elements of the set will never coincide.

You can see my implementation, but if you don't understand something, please feel free to ask!

PD: this kind of set can be very useful, you should implement your own! :)


Just asking, who are you talking to?


if ( comment.evaluate() == content.bad ){


} else {




These guys are the best :





ok, but it's strange


Well,as an OI-participant,I can only use C/C++ and Python 3.

Fortunately, a friend of mine can coding in java and I tried to use pascal and C# for I think they are similar to C.

Finally, we solved 6 problems. I have to say that it's an excellent round!


how can i get the editorial of this round ..???


E's approach is quite straight-forward:

Use a stack to store the new array. Iterate through the original array, and for each element, push it to the stack, and while the stack size is greater than 1, and its top element has the same value with is nearest element below, merge these two elements.


In the previous year authors said you shouldn't discuss it until hacking phase is finished. I think, the same rule this year.


how to solve J,E ?


I think you can, because you can see others' solutions


can we discuss the problems now in the comments or should we wait until the hacking phase is finished?


Same here, except it's because I don't know that many languages :(


As the contest is finished, can we submit in same language?


Get it


It was fun


i solved 5 problems :) nice


I think the language restriction should be removed in practice mode. Maybe I want to solve every problem in all languages lol.


Congrats, nice result! We used C#, Java, Python, C, Kotlin, Go and D. Without C++ it was really funny :D


I used the same strategy and only passed my C++ problem in the last 24 seconds


I used javascript, C#, PHP, Ruby, Python 2, D, Java, C and C++ . It was fun like last year.


Colorful, Colorful and Colorful!!!


I solved 8 problems in 8 languages I have barely seen and used, and I didn't have enough time to solve a problem in C++ (my main language).

The contest was fun anyways.


Just 1 minute late ;(

We kept C++ for the hard problem and couldn't use it :D LOL


Hi, could you please add the problems to problem-set so that we could submit them in any language we want? there were some really good problems...... I would really love to get a chance to submit them..... thanks.


Very nice opportunity to try new languages.For me I used :

Java8 — Python — C — D and C++ (my main)

Was a very good experience.


I wish We had the same color :p :p




The rules are the same for unofficial participants ?


new ChallengeDay().execute();


it is time to learn something new (Forced) ..


we will have some problems with compiling today (10 unique programming languages )

we can use online compilers :)


Why the rules are the same as last year? I expect something new and interesting .QvQ


Posted above.

Created or updated the text

and where are the rules?


We've got the same photo, bro!


For Div1 users there are lots of unrated contests.


But, virtual is virtual, it's not real!


All virtual contests are unrated ;)


The detailed rules will be added to this post around 30 minutes before the start.


Finally, unrated contest. It's becoming difficult to find such contests in Codeforces.




contest duration ?


Wild-card Round 1 who has been last year is very pretty. One programming language for one problem. Js, perl, c++, python, java, pascal — all of this languages try use everyone!


Why I'm unable to select team when registering in the Official Round?


After the contest we will solve the first 2 problems in 2 vedios


Are these problems similar to those in Codeforces rounds?

The main problem with D is that most cases are not difficult to spot. It seems like the solution is: reduce it to BC-s followed by A-s, the number of B/C-s monotonically increases by 2-s in operation 1, the number of A-s monotonically decreases by 3-s in operation 4, then check how these operations can affect the other number. This translates to a lot of conditions, but the rules they check can be described very clearly, it doesn't look like case bashing at all if you think and then code, as I did.

Then there's the special case I missed: a string containing the right number of A-s at the end and no B/C-s, changed to something containing B/C-s.

Note that I started with D and solved it fairly quickly; failing the first problem I tried cost me quite a lot in score. That E/F were practically unsolvable and I didn't expect there would be many hacks (see above: I didn't see D as casework) didn't help.

a reasonable strategy is to revisit problem D, perhaps try to come up with a more formal proof or write a brute force solution to compare with

I had a formal proof shortly after the contest started. The problem is you can miss something no matter how many times you go through the same thought process because, well, it's the same thought process. I had something of a bruteforce (bruter force, O(N2)). Writing a test generator, fully bruteforce solution, stresstesting, finding this bug by picking random cases and fixing it takes a lot of time, probably more than 20 minutes. I sure didn't manage it that fast.

Some problems have a small element of randomness. Some problems are nasty and have a huge element of randomness, either because you need to think weird to find a solution or because there's something that's very easy to miss. Some problems are geometry. There isn't always a way to do better other than farming luck in advance...

Anyway, the choice of pretests for F is much worse. If a bogo-algorithm works (bogosort: randomly permute while not sorted) on the first 95 tests, then you should make test 96 one of the pretests or use no pretests. This way, you don't have people making blind submissions.

The difference is that you sometimes get a wrong answer on systest few years after submission.

If you can conceal your failure for years, that's pretty damn successful. That's not comparable to systests, but to someone running stresstests for fun and noticing an obscure bug nobody thought about a week after a contest.

Or you can be sufficiently powerful, in which case you get a taxpayer-funded bailout. But I digress.

I find my real world experience isn't nearly as harsh as people say. Not in the sense that failure is terminal. "Your submission to a vendor test didn't do well? Here are some statistics, compared to your previous submissions; we're accepting submissions again in a month." "A wild bug has appeared! We should fix it ASAP and get back to what we were doing." The various catches in (not only programming) competitions are unique in that regard. Competitions are harsh compared to ["real world" activity here] and so few people do them precisely because of that harshness.


looks like we cant talk about the legend of Unrated contest in CF with the Users registered after 23 NOV


Well, “should” is improper here.
Cf doesn’t have any obligations of holding a round per week.


There are other sites too that you can enjoy.

Atcoder is having a contest tomorrow.


Oh, I missed that. Anyway, they should have a rated round on every weekend. Some people like me who enjoy coding only on CF quite enthusiastically wait for weekends for rated contests :)


"The rounds will use special rules"


Why unrated? Codeforces should have at least one rated round every weekend.

Only tourist can lose 290 points and still have 300+ points above Legendary Grandmaster line.

Answered on PM. On Flash — it's been told many times, nothing happened and nothing is going to.

About the strategy — I've done exactly what you are saying. But it turned out I'm so stupid that couldn't fix my solution till the end of the contest even having the bruteforce and 20 minutes. I've spent another half an hour after the contest to make it work.

With your first paragraph you're barking up the wrong tree here. To be honest, I've not seen any complaints about the Flash interface. Note that I'm not implying that they don't exist nor am I saying that it is ideal. I'm positive that it's not productive to complain about it on a random post three layers deep in discussion of a random round that intentionally used both of the ways of gaining points to decide the ranking. I have not noticed you saying the above in a more appropriate discussion. Perhaps you would gain more support over there and things could actually happen. I know that I would join the bid.

Regarding your second paragraph — I already know that some of the tasks were more difficult that they should have been (even though having a task with 3 or fewer correct submissions is not that uncommon) and I will do my best to avoid that situation next time.

they should agree that the contest is imbalanced as hell as don't try to solve the last two tasks

No, I am saying I hoped they would adjust their strategy to the circumstances and assess how to act to maximise their score. If on task E you got nowhere 20 minutes prior to the end of contest, it may be a good idea to do something else. Perhaps hack other people.

Everyone was, however, able to look at the scoreboard 20 minutes before end of contest and see that it is full of hacks.

It's especially convenient to click on some participant having 6 successful hacks to see which problems he hacked and look at an infinitely loading page with their list. Codeforces hacking system is 20th century artifact. To be honest, I'd send more money to codeforces crowdfunding campaign being guaranteed that hacking system will be rewritten using some modern technologies.

On the subject: making so much random in the last solvable (ha-ha) task is definitely the best way to ruin the contest. You are saying people can stress test their solutions with a bruteforce — OK, so they should agree that the contest is imbalanced as hell as don't try to solve the last two tasks, which were supposed to arrange participants at the top?

Ya Got Accepted no need of help

Since a long time, I have the opinion that the pretest system is un necessarily extremely harsh at times.

There are situations where I have declared wrong array size, and lost as much as 1600 +  points in multiple contests for it.

Sometimes, this is not good.


No one cares :-"

Update: I seem to have fixed it by removing "remove node" function and lowering the node count while traversing the trie. Still not sure why the original function didn't work, though.

Could anyone find out what is wrong with my program for Div. 2 D? I used a trie like the editorial, but I seem to be off by one for some answers and I have no idea why. Could someone help me out? thanks 36214710

I meant "Does intended solution use randomized algorithm?". Forgive my hastiness and English :P

Can you please tell me what do you mean when you say the intended solution was random?

Thanks ! :) majk

Thanks for your kind and honest opinion. I often say these to other people. But reality is a little different. I do enjoy competitive programming but i know that there will be a time soon in the future when i have to quit and focus on my livelihood. But I wanted to become CM as soon as possible for a different reason (not related to programming). The fact is sometimes you can change a system when you go a higher position. I want to do something like that for my situation.

Honestly multiset does the job quite nicely, but c++ priority_queue is slightly faster, as it uses Fibonaccy Heap, which i have seen is better in practice, and also the code is simpler with pqueue. But i would say use whichever you feel confortable with.

Haha, yes. But I was just pulling OP’s leg — I guess kids are too bored with that joke.

I think you are in a good position now to see for yourself. :P

No offense taken. I'm glad for the discussion!

Wish you luck in next contests!

Hi majk, I completely understand that. I did not mean offence to you. I made that comment out of frustration. Thank you for hosting a contest :)

but leave the tricky one for systest and or hacks.

What for? I hate hacks because it depends on your room. For example, some rooms doesn't have any wrong solutions of the problem B, but in some another rooms there are teams who have made 4-6 hacks on it. It's like extra problem for them. I also think that making weak pretests are very bad idea for div1+div2 contests because people from div2 often submit naive solutions and it will make a lot of hacks and disbalance in scorboard.

If you have twenty minutes left and are nowhere near finishing E or F, a reasonable strategy is to revisit problem D

Another problems also have weak pretests. I saw how a lot of people passed pretest of problem F and it was very quickly. So I thought it's real to solve it faster than 15 minutes. But it was not true because these solutions were wrong. I tried to solve it and my solution of problem D was hacked 30 seconds before the end of contest.

I think hacks are the best way for tasks when autor's test can't cover all cases for all solutions(for example tasks with hash), but hacks should not be in every problem.

on AIM Tech Round 4, where I got WA on systests

Unfortunately, a lot of rounds on codeforces have weak pretests and a lot of hacks recently. But I think it's not a reason to make weak pretests again and again.

Anyway, I think problems were intresting and with good pretests this round would be very good. Thank you for the round and I hope next your round will have less hacks.

You might need to slightly reevaluate your priorities. We are in surprisingly similar situations (I solved B in pretests, and if it passed sys tests, I would have become CM, but it didn't and now I am almost exactly the same rating as you, and I have an exam on Monday, so while it isn't Friday, it's similar), but after my performance on this contest, my first thought wasn't disappointment, it was just "My consistency with solving Div2C/D during contest has been increasing a lot; I'll become CM on the next contest".

Perhaps you have something going on in your life that you can't compete on CF anymore, but if that's the case, the fact that you are not CM is almost completely irrelevant to anything. If you don't have any such thing, then compete again. If you're good enough to get within 10 points of CM, you're surely good enough to do well on a contest again.

But I would seriously rethink your motivations for doing competitive programming if you are making noticeable sacrifices in other areas of your life. Ask yourself if your end goal for competitive programming will really be more helpful than, say, focusing on your grades, and try to be completely honest with yourself. You may find that doing competitive programming is worth sacrificing grades, but you also might find that the opposite is true.

Just some friendly advice from someone in a similar situation.

I am sorry you feel that way. I am especially not happy that you came back to CF after such a long time and got beaten this way.

I've read the discussion about the problem D and hacks in general, and I have sympathy for the cries. I fell victim to pretests a few times as well. Most notably, on AIM Tech Round 4, where I got WA on systests because std::random_device was deterministic on MinGW. That night I though I don't have what it takes to be red and would never become one.

The problem was initially suggested as somewhere between Div1A and Div1B. During testing we realised that some of the cases are really difficult to spot, and hence it navigated all the way to Div1C (I purposefully do not call it D, as the intention was that Div1 has an extra problem at the beginning, not at the end). The idea was to put the main cases in the pretests, but leave the tricky one for systest and or hacks.

Depending on whether I would notice the tricky case in D myself or not, and was hacked or not, I might have been upset too. It was an unusual problem, but I don't consider it to be a mistake the put the problem in the set.

Sure, some people took the risk. They locked the problem that evidently had a lot of cases without having a proof that their code is correct. Later they realised that there was a case they didn't cover, either by noticing it in someone else's code, or getting hacked themselves. Risks sometimes don't pay off.

Some people were lucky to get hacked early enough. Everyone was, however, able to look at the scoreboard 20 minutes before end of contest and see that it is full of hacks. If you have twenty minutes left and are nowhere near finishing E or F, a reasonable strategy is to revisit problem D, perhaps try to come up with a more formal proof or write a brute force solution to compare with.

I view competitive programming a challenging leisure activity that gives us a balanced mix of two feelings — frustration that I cannot solve a problem, and happiness that I was able to solve one. It's okay to be upset if you do badly, it's okay to be mad at the problemsetter who caused this. You'll do better in next contest.

Remember that there is also another goal of CP for many people, and that is to prepare themselves for future employment. In the software engineering world, you also have pretests and system tests. The difference is that you sometimes get a wrong answer on systest few years after submission. And the consequences may be much more severe than a few rating points.

It actually has happened before. But honestly speaking we should stop this sensationalising tendency of ours.

it feels so good

Thanks for giving me another problem which can be solved with trie.

Problem D was beautiful, respect to majk for it

if(a[i][j-1]=='S' || ...

When j = 1 you compare 'S' and not initialized value. Not initialized value is usualy a random value. So the result of this compare is random too. When you are lucky your random solution gets AC :)

Me :P

i got plastic glasses thinking they were harder to break but it didn't help, instead of the glass breaking the frame broke. LOL

I like the volatile formula. Imagine being gone for two months, then doing well on a contest, only to find you gained 15 rating...

Nobody really assigns that much weight to ratings anyway. Everyone still agrees tourist is the best in cf.

But now the same code is getting AC. Why?

cjtoribio, Thanks for taking time in explaining me...
P.S: Your solution is beautifully coded. :)
Update1: Is there benefit of using priority queue over multiset?

Maybe because you defined the array "a" in the main function.

Arrays defined in functions may not be initialized.

Try memset(a,0,sizeof a); Or you can define arrays out of main function (they'll be initialized by 0).

948A — Protect Sheep

The code that i submitted during contest got WA on case 49.But the same code got AC when i submitted it after contest.


I always believe that old rating formula was much better than new rating formula. Before this round everyone agree that he is the best in CF — but he falls to the 4th place just because he fails a single round? In one round everything can happen. It puts too much weight on the newest round.

hope for him.

It's amazing to see the fall of tourist.

OMG, I know why!

When using the multiset, the "erase" function does not act like the set.

multiset b;
b := {3,3,3,5,6,6,7} // just a example, do not mind the grammar..
And then : b := {5,6,6,7}

erase a number in the multiset will actually erase all of them.

It's my first time to use multiset. Maybe I still have some problems. But finally I learned something useful.