The round couldn't have been realized without efforts of KAN and our testers: cyand1317, demon1999. Thanks for your help to the contest. Also, thank MikeMirzayanov for the fantastic Codeforces and Polygon platforms.

The contest will consist of five problems and it is rated for both division contestants.

The background of problems will be about Lunar New Year. (Yes... Not Valentine's Day...)

Hope to see you in the contest! Good luck and have fun, wish you a high rating!

We suggest that those who already have Valentine's Day plans should not participate... You can always upsolve a contest, but there is only one Valentine's Day ;)

Can you call it "Lunar New Year" instead of "Chinese New Year"? This festival is also meaningful for all East Asia countries (Vietnam, Nouth/South Korea, Japan, Taiwan, Hong Kong, ...), not just China. The background of the festival is based on the orbit of the moon (instead of the sun in the normal Julian calendar), then we call it "Lunar New Year". So if you change the phrase, you can support more programmers in Codeforces where there are so many programmers come from the East Asia countries. Thank you.

I think up votes for this post raised so high cos the writer mentioned the line "We suggest that those who already have Valentine's Day plans should not participate... You can always upsolve a contest, but there is only one Valentine's Day ;)" :P ;LOL

Imagine , your crush made an anonymous CF handle only for you and knocked you in CF to surprise you on valentine day . But you are finding yourself so much closer to solve the problem on your hand that you u can't reply despite seeing it .

The main part of the problem is not doing the base representation itself, but figuring out how base representation helps for this problem. For people like me who are not that smart, it takes time for us to figure out that the solution for B is just to represent p in base (-k). Although it may seem trivial for you, I think that the problem is interesting.

Well, what I did was, taking points from (-21, -21) to (21, 21). Since you can't take all of them, I magnified the grid by 100*100, and took all lattice points there. And for each point, find in what circles it lies in.

after months of participating in codeforces contests i ve come to the conclusion that the problems are generally trash with weak pretests and badly translated statements , written by sad weeaboos calling themselves programmers and problem setters so i will leave forever this site here is my passowrd : codeforcesistrash . bye

You are like a girlfriend that you are breaking up with, and she like "I'm leaving and never will write you again" and then writes you like 9000 messages about how she hates you and how she won't ever write you again. Just leave, omg, nobody gives a shit.

Yes, substitute x=-k into the polynomial and you will find that f(x)=q(x)*(-k+k)+p=p. Thus, the coefficients of f(x) are just the base (-k) representation of p, and the coefficients will always be smaller than k since it's base k.

I am surprised to see a lot of C++ submission for B. It seemed that people would rather implementing big number than writing this problem in a different language.

For C, what is the easiest (fastest to implement) method to find intersection of two circles? My idea is to divided the grid into k2 point, and for each point find the set of circles that this point is in (represented by a bitmask), and then the answer is the number of distinct bitmask. It seemed that setting k = 2000 is not enough (higher k will not run in time). So I thought about considering each circle center and points near the intersection of any two circles, and got stuck and the intersection thing.

In the last moment before submitting I changed 36 to 34. Locked the solution briefly after. The next moment I realized I'm f***ed. The right thing to do was to hack myself, but I lost that opportunity.

Contest time was too dificult for me to participate, because it was 7:05 AM in my country, toooooo early ;-(, I was in REM 27 at that time. I think contests need to be scheduled in an hour more accesible to all the world.

Div 1 C is the worst problem that can be proposed for a cf round, not only it can be found in various sources but also it only requires to just check some cases instead of the general case. D and E are good on the other side...

This problem is prepared by me and I must apologize that this problem coincide with some problem elsewhere.

I came up with this idea these days and found it hard to discuss all the cases even if n = 3. So I think it is interesting to leave it as a problem with some hacks, instead of a problem in general case (seems luckily that I haven't did so). However, none of us writers or tester realized that this problem is a special case for an original problem.

When I saw you passed this problem in 3 mins, I knew things go wrong but can do nothing. But I am still so sorry for that.

Actually you do not need to worry about it :) It is important only for 30-40 users, for all others that is not big deal ( it is true that is the 40 users with highest rating, but still it is not so big disaster ).

Well... thanks for your approval. But for me it is really an issue, which makes me feel upset instead of delighted for such an interesting(?) task. It seems that my hard works, especially generating some tricky cases by hand, for this problem are in vain.

But... It's harmful for other participants. Because it's just after two very simple problems, a lot of people solved A and B in about twenty or thirty minutes.

You see, div.1 D is super easy to code, and not difficult to think(just a few sigmas). But when I saw a lot of people passing C in 5 min(even 2), I spent one and half an hour thinking problem C. So I don't think it's good to make this round completely rated. Maybe unrated or semi-rated is a good choice?

As you can see, all of us writers and tester didn't notice that. I must admit that it is also a part of ability to realize the original problem. Making this round unrated or semi-rated will be unfair to those who solved the problem by copy-pasting.

Not only for reds, for example 6 people from my country solved it without even knowing the solution (the judge from the link above has public codes). I don't want to blame the author, it's just that codeforces needs testers from different regions.

My approach for Div2C:It is easy to identify that, all the possible non-decreasing subsequences will be one of the following type:1. Starting with 1 and ending with 12. Starting with 1 and ending with 23. Starting with 2 and ending with 2.

Now for each pair (i, j), we want to find the length of each type of non-decreasing subsequence and we can keep the length of the largest.

In the last for loop, we are taking subarray A[i...j], and we are finding length of largest subsequence of each type in A[0...l - 1], reverse of A[l...r] and A[r + 1...n - 1]a0, a1, a2 store length of largest [Type 1] subsequence, [Type 2] subsequence and [Type 3] subsequence respectively for A[0...l - 1].Similarly, b0, b1 and b2 store length of each kind of subsequence in reverse of A[l...r].Similarly for A[r + 1...n - 1], in c0, c1, c2

Now we want to calculate maximum length of each type of subsequence in d0, d1, d2 in A[0...l - 1] + reverse(A[l...r]) + A[r + 1...n - 1].We can create [Type 1] and [Type 2] subsequence easily. Look at the explanation above for how to calculate d1, and then we take the maximum of these three length.

I have to say, this wasn't a nice cf round. It's understandable that pretests in Educational rounds are weak, because those problems are a little bit easier and the main purpose of that kind of rounds is the hacking phase. But making such weak pretests in a normal cf round? Why? I love this kind of contests, but this one is the exception...

You can do a dp using current element, value of last, and the current state (non decresing, non incresing and non decresing again) [n][2][3]. This part that we'll reverse is the part that we consider non incresing

Your solution is not O(n2), it goes to O(n3) as for each pair (i, j) you are swapping times. So each pair will be O(n2) and for this you are going at max on average n/4 times, hence O(n3). Correct me if I am wrong.

For Div. 2 D, I could reach the conclusion that p must be in the form of a0 - a1 * k + a2 * k2 - a3 * k3..... + ( - 1)n * an * knHow do I move ahead from this conclusion? Is there a theorem or property that I am missing? Please guide. Thanks.