### MrPaul_TUser's blog

By MrPaul_TUser, 18 months ago, translation,

Hello, Codeforces!

I'm glad to invite you to amazing (we've tried to make it such) Codeforces Round #734 (Div. 3) which will start on Jul/23/2021 17:35 (Moscow time). This round is the first "trial of the pen" of me (MrPaul_TUser) and it seems to be hard to make it alone — a significant contribution was made by MikeMirzayanov, BledDest and DK318.

The round contains 6-7 problems. The difficulties of the problems are expected to compose an interesting competition for participants with ratings up to 1600. However, all of you who wish to take part and have a 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-7 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 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 WolfBlue, BlueDiamond, harlequen, -is-this-fft-, le.mur, Bench0310, Reiva5, Golovanov399 and Sho for testing the round and improving tasks.

Good luck and have fun!

UPD

Editorial

• +237

| Write comment?
 » 18 months ago, # |   +47 First time being unofficial :)
•  » » 18 months ago, # ^ |   +26 Reached 1600 yesterday...
•  » » 18 months ago, # ^ |   0 Why? This round will be rated for you since your rating is less than 1900.
•  » » » 18 months ago, # ^ |   +21 No, its rated up to 1600, not above."However, all of you who wish to take part and have a rating 1600 or higher, can register for the round unofficially."
•  » » » » 18 months ago, # ^ |   +3 So... then what does "only the trusted participants of the third division will be included in the official standings table .... do not have a point of 1900 or higher in the rating." mean?
•  » » » » » 18 months ago, # ^ |   +4 That means that those people will be included in the official standing table. In conclusion that means, not everybody in the official standing table will be rated.
•  » » » » » » 18 months ago, # ^ |   +4 Ah, okay, thanks.
•  » » » » » » » 18 months ago, # ^ |   +21 If you want to be rated in Div3 you can refer to my rating graph how to do that ;)
•  » » 18 months ago, # ^ |   0 hey! i saw your profile and i'm pretty curious as to how did you become expert in such a small timespan, if possible could you share some tips, tricks or advises? and like what all topics did you practice to reach where you are right now?
•  » » » 18 months ago, # ^ | ← Rev. 4 →   +1 I was training kind of hard maybe :) when I was newbie I trained 1600 difficulty problems until I become pupil, after that I started to train 1k8 problems until I reach specialist and expert. Upd: I think the best way to do it is your rating point + 400. (Sorry for my bad english)
 » 18 months ago, # |   +17 Now finally my exams are over. I can once again participate in contests.
 » 18 months ago, # |   +1 Very glad to see another Div3 in small interval! good luck everyone!
 » 18 months ago, # |   0 Why is it showing registrations completed, does it mean I cant register for the contest now?
•  » » 18 months ago, # ^ |   +1 chill :) you have been registered to the contest that's why it is showing !
•  » » » 18 months ago, # ^ |   0 i wand problems like this one...
 » 18 months ago, # |   -37 expert i'm coming
•  » » 18 months ago, # ^ |   +16 newbie, you're going
 » 18 months ago, # |   +67 I appreciate that the testers are arranged such that their usernames' colors form a palindrome.
•  » » 18 months ago, # ^ |   +3 If you had not mentioned that I would have never noticed that. Thanks for informing.
•  » » 18 months ago, # ^ |   +8 Maybe a hint for the contest...XD
 » 18 months ago, # |   +13 SpoilerCodeforces Round #734 (Div. HOPE)
•  » » 18 months ago, # ^ |   +1 "..just like you will be upset if many solutions fail after the contest is over."
 » 18 months ago, # | ← Rev. 2 →   +5 hope there will be strong pretests as last contest was ruined by weak pretests
•  » » 18 months ago, # ^ | ← Rev. 2 →   +9 The contest hasn't even happened yet...Edit: as you edited, I hope so too...
•  » » » 18 months ago, # ^ |   0 he said "as last contest"
 » 18 months ago, # |   +2 "I tried to make strong tests — just like you will be upset if many solutions fail after the contest is over."phew, unlike last contest ;)
•  » » 18 months ago, # ^ |   +3 Congratulations for becoming an expert for the first time :)
 » 18 months ago, # | ← Rev. 2 →   0 see my profile I will never give div 3 I dont know how so many people solve so fast and ACM-ICPC rules sucks too.
•  » » 18 months ago, # ^ |   +13 The way people solve it fast is practice. I did the last div 3 contest just like you and you spent 1:30 hours on D, which isn't particularly hard if you're familiar with this type of idea. Blaming the ruleset is kind of dumb imo because on different rules the difference is that the problems would be much harder to balance out a longer submission window
•  » » 18 months ago, # ^ |   0 You'll never be as fast if you never participate though.
•  » » » 18 months ago, # ^ |   0 yes you are right brother.
•  » » 18 months ago, # ^ |   0 Speed is an acquired skill.
 » 18 months ago, # |   +15 Liked the thanking section!! where he used symmetric colour combinations.. :)
 » 18 months ago, # |   +9 I registered for the contest before today's one (Specialist -> Expert) and it still says I'm in competition. Just to confirm this contest won't be rated for me right.
•  » » 18 months ago, # ^ |   +7 I don't think it will be rated for you. Enjoy solving problems from the end XD
•  » » 18 months ago, # ^ | ← Rev. 2 →   0 it will be rated, if you registered as cyan, I've experienced it recently and lost 80 points of rating)
•  » » » 18 months ago, # ^ |   0 Looks like it says I'm out of competition now?
•  » » » » 18 months ago, # ^ |   0 i haven't seen posts from mike about the fix, but maybe he already fixed it
 » 18 months ago, # | ← Rev. 3 →   +5 Hope pretest will be strong, not like last contest
 » 18 months ago, # |   0 Hi everyone, I would like to know whether I can start 8 hours following the competition starting time since the starting time is past midnight for me. (I am new to competitive programming).Thanks very much. Cheers
•  » » 18 months ago, # ^ |   0 No , if you give contest at later time than the mentioned time it wouldn't be considered for ratings . It will become a practice contest . For having yourself in official standings you must give contest at the mentioned time only then only you would be considered for standinds and rating change
•  » » 18 months ago, # ^ |   0 You can start a Virtual participation whenever you want after the contest but if you want to make your rating update you have to follow the starting time.
•  » » 18 months ago, # ^ |   0 I guess you cant participate later, but if you don't need rating, you always can participate virtual. It will be just like normal participation, but without rating. Cheers and good luck.
 » 18 months ago, # | ← Rev. 2 →   0 Now, finally before my exams, I am gonna compete. And can anyone please spare a minute and tell me in which division do I belong, my rating being 814. Thanks.
•  » » 18 months ago, # ^ |   0 You can participate in any contest except those rated solely for Div. 1. This means that you can participate in Div 3 , Div 2 and combined Div 1+2 rounds
 » 18 months ago, # |   0 Is there any chance of arranging these contests so they are in the evening or weekends. Anyone who has a job can't enter as they will be working.
•  » » 18 months ago, # ^ |   +3 If you prefer weekend contests, then AtCoder may be a good choice for you.
 » 18 months ago, # |   0 If I know it early, I'll not get to expert:)
 » 18 months ago, # |   +3 So we penalty of 10 min on the wrong submission and not of 50 points. Right?
•  » » 18 months ago, # ^ |   +9 For every minute, 5 point decreases from the main point. Like, 500->495->490. So, penalty of 10 minutes and 50 points are same
•  » » » 18 months ago, # ^ | ← Rev. 2 →   +1 it's not 5 points depends on how many points the problem has the higher points the problem has the more points decrease with time
•  » » » » 18 months ago, # ^ |   0 Your cf graph orz
•  » » » » » 18 months ago, # ^ |   0 What does orz mean i read it all the time
 » 18 months ago, # |   0 Good Luck to Everyone
•  » » 18 months ago, # ^ |   0 Well,you too!
 » 18 months ago, # |   0 o sweet lords of coding, help me reach 1200.
•  » » 18 months ago, # ^ |   0 ++
 » 18 months ago, # |   0 Last minute tip ! Open this to side : CF Notifications So that you don't need to wait to see AC's
 » 18 months ago, # |   +5 After so long time i'm missing a CF rated contest for my Covid. :'( Hope to come back soon.keep me in your prayer. :(
 » 18 months ago, # |   +1 Oof.
 » 18 months ago, # | ← Rev. 2 →   +2 A,B1 == div 3 B2,C.. == div 2 
 » 18 months ago, # |   +16 A perfect div2 round.
 » 18 months ago, # |   +7 A divison 2 contest with Divison 3 participants.
 » 18 months ago, # | ← Rev. 2 →   0 you should have said to check D2 before D1 instead of B2 before B1 I didn't get how dominoes are placed until i checked D2
•  » » 18 months ago, # ^ |   0 hey can u tell me the logic behind b2, i got what the maximum number of single colour used would be but i could not figure out how to colour them without going against the rules.
•  » » » 18 months ago, # ^ |   0 any number that exists k or more times must be colored with all k colors and what's left of that number occurrences are zeroed so you need map with vector of positions of that number to do that and other numbers that exists less than k just gather their positions in one vector and color them any way
•  » » » » 18 months ago, # ^ |   0 Maps are not required for this problem.You can see my code for details.Code: 123477048
 » 18 months ago, # |   +1 Thanks for the great contest :)
 » 18 months ago, # |   +13 lovely problems!
 » 18 months ago, # |   0 When can I check the testcases?
 » 18 months ago, # |   +2 Problem C was incredibly similar to this problem, so much so that I copied over my solution almost verbatim...
 » 18 months ago, # |   +22 Perhaps you should read the problem B2 before you start solving B1.Was this meant to be a troll?
 » 18 months ago, # |   +1 This round was too hard for Div. 3
 » 18 months ago, # |   +17 Well I found that pretty tough and it wasn't even meant for me
•  » » 18 months ago, # ^ |   +18 Solved all but D2. Why is problem D so hard?(or maybe I'm being dumb)
•  » » » 18 months ago, # ^ |   +10 I decided to focus on completing D2 instead and that deprived me of the time to attempt E or F. D2 was conceptually fine but the casework and construction is very fiddly.Even prior to that, B2 was fine but not Div 3 problem B fine.
•  » » » » 18 months ago, # ^ |   0 I implemented it by assigning different integers to each domino (so casework was on integers, without considering which letter should be used for which domino). Later I processed the integer table as follows: create a graph of neighboring dominos IDs (so that we know which colors are forbidden — if two IDs are connected, we can't assign them the same color); notice that no domino has more than 6 neighbors; this means that you can simply select any color for your domino that is not yet assigned to any of your neighbors in the graph and you will never run out of letters; Submission 123498750 containing the color assignment at the end of st() function.Changing D1 into D2 took slightly less than 20 minutes.
•  » » » » » 18 months ago, # ^ |   +8 I did something pretty similar except it was just a row-by-row construction where I incremented a value (mod 26) while it matched any of its above or left neighbours.Not conceptually too difficult for sure, but with the different cases (N odd, M odd) I found it a pain, and the kind of implementation that isn't great for a 2 hour contest except for the most efficient coders. But I was too committed by that stage to stop and move on. I have since seen that E in particular was a much cleaner question and had I realised what D2 entailed I would have skipped and solved E.
•  » » » » » » 18 months ago, # ^ |   0 Makes a lot of sense, thanks for the reply ;)
•  » » » » » » 18 months ago, # ^ |   0 I did something to make the casework easier-We know at least one of n and m is even. So we have two cases-1. n(rows) is even2. n is odd => m(cols) must be even In case 2, we can rotate the table by 90 degrees => n and m are swapped, and all horizontal dominoes become vertical and vice versa, ie. in the rotated configuration, k becomes m*n/2-k. So we only need to solve for case 1, and that's it. (Oh, and we rotate the matrix back before printing)For filling the table, filling from left to right and from top to bottom at all times worked cleanly for me. (Had only to check the top, left, and bottom-left dominoes) submission
•  » » 18 months ago, # ^ | ← Rev. 2 →   +4 I was chatting with other people at the same time so I didn't focus. But seriously I wasn't ready for this. Without turning on my brain before the contest, I just wanted to quit the moment I saw B and D.
 » 18 months ago, # |   0 someone please hack my submission.123523305
•  » » 18 months ago, # ^ |   +1 It looks fine, in my opinion it should pass the system tests ;) I tried to hack you based on the fact that you allocate large arrays statically but it passed ;) Good job :D
•  » » » 18 months ago, # ^ |   +1 i hope it will pass the tests
 » 18 months ago, # |   +4 what is pretest 2 of B2 ? I was not able to figure out till the end
 » 18 months ago, # |   +29 The problems were really interesting. Kudos to the authors involved! Would have been much better if this round was half an hour longer though
•  » » 18 months ago, # ^ |   +1 Exactly, would have been better if it was longer.
 » 18 months ago, # | ← Rev. 2 →   0 How to solve D1? I tried 3 cases. Got WA on Test 3. Cases If both rows and columns are even, then $k$ can't be odd. If columns are odd, then, $(2k/(col-1))$ must be even. If rows are odd, then $(2k/col)$ must be odd. Did I miss anything?
•  » » 18 months ago, # ^ |   +2 If rows are odd, then you need atleast m / 2 horizontal dominoes.
 » 18 months ago, # |   0 I submitted my solution with 22 seconds remaining. I couldnt see the verdict because the page was just loading. Now when i check in my submissions, there is no submission showing. And guess what, when i submitted it in practise it was accepted. Can i be helped??
 » 18 months ago, # |   -12 B2 felt misplaced, for me B and D shoud have been swapped. Or C and B swapped. Or B, C, D reversed... whatever, I worked much to long on B2, and finally was not able to solve it.
 » 18 months ago, # |   0 How to solve B2?? I am not able to solve it
•  » » 18 months ago, # ^ |   0 I binary searched for the number of elements for each type and then reconstructed the coloring according to it. I think I overkilled it though.
•  » » » 18 months ago, # ^ |   0 I don't see where binary search was required. I didn't think it was as difficult as the comments mention, but perhaps It was and I was just in form.I really liked problem $B2$, tbh.You can look up my code: 123477048Incase something isn't clear in the code you can ask me. But, mind you, I'm terrible at explaining.
•  » » 18 months ago, # ^ |   +1 After having read the solution it is not very complecated.Consider f[i] to be the freq of i in a[].Then foreach f[i]>=k color the positions of the i in a[] with the k colors. Then put all other numbers in one big group and do the same in that group.
•  » » 18 months ago, # ^ |   +2 Maintain count and position of each character in hash table, for example if array is 1 1 2 1, the count[1] = 3 and position[1] = 0 1 3.Create an array result filled with 0 of size n.Next iterate through each unique character in the hash table, now there are two cases: If count of any character >= k then that means you can paint each position containing that character with paints from 1..k, so iterate over position[character] from 0..k and fill each entry in result at position in incremental fashion, so result[ position[character][i] ] = i + 1 If count of character is < k then push the positions of position[character] in an new array say leftPositions Now, at last, pop positions from leftPositions in size of k, and fill the popped positions in with paints ranging from 1..k, while popping in size of k, if at any time the size of leftPosition < k then stop and print result.Here is code to this approach: https://codeforces.com/contest/1551/submission/123471900
•  » » » 18 months ago, # ^ |   0 I am doing something similar to this but failing on testcase 2, can u check it out if u can?123490522
•  » » » » 18 months ago, # ^ |   +3 In your code, two same numbers might end up with same color, your case handling for when count >= k is fine, problem lies in your handling of when count < k.Consider this small case (it is not a valid test case just taking it to show whats wrong)a = 10 11 12 10 .....k = 3Your code may produce output like this: 1 2 3 1 ..., you see both 10's have same paint 1, that's the problem.
 » 18 months ago, # | ← Rev. 2 →   0 :(
•  » » 18 months ago, # ^ |   0 Why attend only virtual contest? I say, you should attend the on-going-contests as well, I suggest you not to care about ratings. Also, during the virtual contests you don't get that feel when you solve more problems than your level. Overall I say that its a different atmosphere when giving on-going-contests vs. virtual contests.
 » 18 months ago, # |   0 i got a WA on test 185 can anyone provide me with a counterexample 123529703
•  » » 18 months ago, # ^ | ← Rev. 2 →   +1 Maybe try :n=6 k=3a = 2 3 1 2 3 1This case helped me to identify my mistake :)
 » 18 months ago, # |   +9 My construction for D2Main idea is for every 2x2 block, I assign it a color pair based on which diagonal it's on. Technically I don't need two new colors for the ones on the very right but it made implementation slightly easier. Submission
•  » » 18 months ago, # ^ |   0 Can you plz. elaborate your solution little bit more.
•  » » » 18 months ago, # ^ |   +3 The main idea is we partition the grid into as many 2x2 blocks as possible, with each 2x2 block being able to hold two horizontal or two vertical dominoes. If $n$ or $m$ are odd (only at most one of them can be per problem constraints), then we will have an extra strip on the end (the purple and brown region in the diagram). That extra strip can only be populated with dominoes in the same direction as the strip (so horizontal if the strip is horizontal, and vertical otherwise). Now, since we don't have as many letters as dominoes, we will have to reuse some, and I make sure two touching dominoes don't share the same letter by encoding same letters on diagonals, as shown in the diagram.I don't have the most rigorous proof for why this construction covers all cases, but the main idea is you have the wrong parity of $k$, then there's no way to evenly fill the grid without having a gap in the end that a domino of the opposite orientation cannot fill. On the other hand, if the parity is correct, this construction covers it.
 » 18 months ago, # |   0 Isn't this output that my code generates for B2's sample input correct? Showing WA on test 1 1 1 2 3 0 1 2 2 3 3 1 2 3 4 1 1 1 1 0 1 1 1 1 0 0 0 1 0 1 1 1 2 1 1 1 2 2 2 0 2 2 1 1 1 2 1 2 2 2 3 3 3 3 0 
•  » » 18 months ago, # ^ | ← Rev. 2 →   0 No, there are two 5's with color 3 in test case 6.
•  » » 18 months ago, # ^ |   0 case 6
 » 18 months ago, # | ← Rev. 13 →   0 why is this submission for E giving WA 123523281 on test case 5 I constructed a $dp[i][j]$whose states describe that we have arrived at i th point in the prefix with j moves done. To do that I first precalculate the $pre[i][j]$which says the number of elements in the suffix $i,i+1,...,n$such that the elements after the ith index (including i) have $a[i]-(i-j)=0$, i.e. we have done j moves and after that j moves the number of elements which are now standing at the required index. Now we can iterate over the moves done and check if $dp[n][j]>=k$and return the minimum j . please help if you can? The transitions are as follows $dp[i][j]=max(dp[i-1][j],dp[i-1][j-1]+pre[i+1][j]-pre[i][j-1])$second transition is as follows you deleted at the ith index. so $pre[i+1][j]$calculates the new sum that should be added now that we have made j moves and only the index after i is affected as the left shifts happen from these indices. Final number of elements which are equal given that we have made j moves are in $dp[n][j]$and now we can simply iterate over j from 1 to n
•  » » 18 months ago, # ^ | ← Rev. 2 →   +3 I did exactly the same, except my dp[i][j] is the maximum good indices considering a prefix of length i with j elements kept.The transitions are much easier:$dp[i + 1][j + 1] = max(dp[i + 1][j + 1, dp[i][j] + (A[i] == j))$and$dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])$(A is 0-indexed and every element is subtracted by 1 beforehand).
•  » » 18 months ago, # ^ | ← Rev. 2 →   0 Also I don't think the pre thing is needed.
•  » » 18 months ago, # ^ |   0 Hey I have exact same solution as yours. You can look at the implementation here. 123524901
 » 18 months ago, # |   0 happy thing: accepted (during contest)sad thing: accepted (1 minute after the contest)worse thing: unfortunately, your solution of problem X has been hackedworst thing: wrong answer/time limit exceeded in test set X (main test)
 » 18 months ago, # |   0 Did anyone solve D with DP ? I used dp on columns for each two columns c and c + 1 I may put [0, 1, 2, .., min(n, k)]they will be placed greedily from top to bottom on column c and c + 1 and the remaining cells on c and c + 1 will contain only vertical dominos, if c == m — 1 i can only place vertical dominos on c;I really don't know why this works, but I have intuition that when placing the horizontal dominos they can form some kind of connected block, and hence I can try different shapes for this CC
 » 18 months ago, # |   +4 Is it only me Or B2 was harder for it's position?
 » 18 months ago, # |   +5 In today's contest , problems were great but time was less and problems were more.
 » 18 months ago, # |   +7 Trollforces
 » 18 months ago, # |   +7 Two contests ago I reached expert so this was unrated for me, yet I was only able to solve A and B1. Clearly I still don't deserve my rating
 » 18 months ago, # | ← Rev. 3 →   0 Help needed! There is something wrong with my lambda expression below, but I have no idea why it turned out this, from my point of view, both a & b is in the range of [0, n), but it can be some invalid value, more exactly in this code, when n >= 17, it would be a mess. I would appreciate it if anyone could help! #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; vector sz(n), r(n); for (int i = 0; i < n; i++) { r[i] = i; } sort(r.begin(), r.end(), [&](int a, int b){ // cout << "a = " << a << " b = " << b << '\n'; if (a < 0 || a >= n || b < 0 || b >= n) { cout << "@" << a << ":" << b << ":" << n << '\n'; return false; } return sz[a] <= sz[b]; }); } return 0; } 
•  » » 18 months ago, # ^ |   +3 I have no idea about "invalid values" but you should never use <= or >= in custom sort comparator.
•  » » » 18 months ago, # ^ |   0 Thank you so much! I change the '<=' to '<', the annoying value disappeared! But why? Is it a property of the lambda expression?
•  » » » » 18 months ago, # ^ | ← Rev. 3 →   +3 No, it is not related to lambda.Take a look at the parameters part of https://en.cppreference.com/w/cpp/algorithm/sort and the requirements of a comparator https://en.cppreference.com/w/cpp/named_req/Compare .Always keep this in mind. I have no idea what will happen exactly if you use <=, (I assume it is a UB — undefined behaviour?) but UB always leads to disaster.
•  » » » » » 18 months ago, # ^ |   0 Got it, thank you for your reply! :-)
 » 18 months ago, # |   +12 Problem D2 reminded me of this problem if anyone wants to try.
 » 18 months ago, # |   0 Problem E was very similar (though not identical) to task from XIV Polish Olympiad in Informatics: statement in Polish
 » 18 months ago, # |   +12 Hi ! I encountered something weird in my submission for todays 'C'.Firstly I have made a 'vector of vectors' which store the property of each string i.e. the number of a's,b,c,d,e. Then while checking for character 'a', I am sorting this 'vector of vectors' according to the difference between count of a's and rest of characters. Driver codefor(i=0;i>s[i]; vector> v; for(i=0;i cnt(5,0); for(auto x:s[i]) { cnt[x-'a']++; } v.pb(cnt); } ll ans=0; sort(v.begin(),v.end(),comp1);But this is getting RTE in the comparator function: Comparatorbool comp1(vector &v1, vector &v2) { cout< &v1 only idk why it's showing vector&v1 here. Also my complete code is very ugly, so that's why am only putting snippets here !!
•  » » 18 months ago, # ^ |   +16 You may want to check this
•  » » » 18 months ago, # ^ |   +6 Oh my my !!!!
 » 18 months ago, # |   0 How are the multiple answers tested?, like in today's B2
•  » » 18 months ago, # ^ |   0 Put every colored element in a set. Let's say that in correct solution the size of each color's set is n, now check for the given output if the size of set is equal to n and there are no repeated elements.
 » 18 months ago, # |   0 How to solve C ?? I am not able to solve it.
•  » » 18 months ago, # ^ |   0 Let's define how interesting a given letter in a string as follows: The number of occurrences of a given letter $-$ the number of occurrences without that letter. Let's call this value $x$. For example, in the string $bac$, $x_a$ would be $-1$ because $a$ occurs once and the number of non-$a$ letters is two. $1 - 2 = -1$.Another example is $aaada$, $x_a$ would be $3$ because $a$ occurs four times and the number of non-$a$ letters is one. $4 - 1 = 3$. We can find how interesting a given letter is for each letter $a, b, c, d, e$ and find the longest subsequence with a sum greater than $0$.This is equivalent to finding the longest subarray with a sum greater than zero when sorted.
•  » » » 18 months ago, # ^ |   0 Why is that equivalent? Any intuition?
•  » » » » 18 months ago, # ^ |   +3 Well, greedily, we're trying to find the maximum subsequence sum, and when we sort it (in descending order), the largest elements in the array come first (obviously).
 » 18 months ago, # |   0 Can problem A be solved using binary search?
•  » » 18 months ago, # ^ |   +3 No, you have to implement fenwick tree for it and then build sparse table.
 » 18 months ago, # | ← Rev. 2 →   0 can someone kindly tell me why am I getting a TLE in this code for problem B2 ? It will be very appreciated..thx 123532079
•  » » 18 months ago, # ^ | ← Rev. 2 →   +9 You are getting TLE because it is taking a long time to parse such big preprocessor statements. Upd: Oh you removed your unformatted code from the comment lol. The actual reason is allocating array of size 2e5 in each test case and there can be upto 1e4 testcases. So you're taking time for allocating arrays of size 2e9. This will TLE.
•  » » » 18 months ago, # ^ |   0 then it should get tle in test case 1 but its getting in test case 2
•  » » » » 18 months ago, # ^ |   +8 Having irregular font size is undefined behaviour in C++
 » 18 months ago, # |   +1 This is not the div.3 we wanted but this is what we needed.
•  » » 18 months ago, # ^ |   +2 I wanted this
 » 18 months ago, # |   0 Is there any way to get all test cases? My program for B2 constantly crashes on test 2 case 3901 and I have really no clue what's going wrong. 123544433
•  » » 18 months ago, # ^ |   0 You have to use if conditions, its not pleasant but it works if the input is not too large. run your solution for test case 1, then for test case 2 print the input for T=3901 for others just take input and don't print anything.
•  » » 18 months ago, # ^ | ← Rev. 2 →   +1 Check my submissions for B2 where i printed the failing tc for 3901 ( using your code )8 44 5 4 3 5 3 3 3Your Ans: 1 1 2 2 3 3 4 0
 » 18 months ago, # |   0 Can anybody helps me with my code in E it gives WA on test 4
 » 18 months ago, # |   0 Any ideas for F?
•  » » 18 months ago, # ^ | ← Rev. 3 →   +28 If k = 2, you can pick any 2 nodes so answer is nC2. For k>2 — Let's say we can pick k nodes such that each node has a distance D with the other. Since all of these nodes are equidistant from each other, and the number of nodes is >=3, this has to be a star formation with one "unselected" node at the centre, and all the selected k nodes are equidistant from this centre (distance of D/2 to be precise, D can never be odd). Let's call the centre X. Let's root the tree at X.Also note that, any 2 selected nodes will have LCA equal to centre (meaning any path from one selected node to the other must go through centre, otherwise their distance will become shorter). What this means is that from the subtree of each child of X, only one node can be selected. If the number of children X has is 
 » 18 months ago, # |   -11 Finger crossed,for not to repeat last round hacking drama & to be specialist for the first time which missed yesterday due to hacking drama
•  » » 18 months ago, # ^ |   +13 It's not a drama. You had an incorrect solution for which you were rightfully penalized!
 » 18 months ago, # |   0 Only 4 different characters are needed in D2: 123522856 Idea:vertical: use aa and bb abab... abab... baba... baba...then change to horizontal using cc and dd ccab... ddab... baba... baba...
 » 18 months ago, # |   +1 editorial?
 » 18 months ago, # |   0 Can someone kindly tell me why am I getting TLE in this code for problem B2? 123566277. I really don't know why it get TLE T_T
•  » » 18 months ago, # ^ |   0 in every testcase you are initializing 2e5 memory ..may be thats why..you don't need to because ai<=n
 » 18 months ago, # |   0 How long does it take to update the rating?
•  » » 18 months ago, # ^ |   +8 Come on, man. We can literally see that this is not your first Div.3 round. Why these useless comments?
 » 18 months ago, # |   +3 i must say this wasn't div3 contest , problem C was tough for me.
 » 18 months ago, # | ← Rev. 2 →   -13 Thanks for Round!
 » 18 months ago, # |   +10 To not keep you waiting, the ratings are updated preliminarily. In a few hours/days, I will remove cheaters and update the ratings again!
 » 18 months ago, # |   0 Can anybody help in memoizing this recursive code for problem E since I get TLE: Problem E
•  » » 18 months ago, # ^ |   +3 I don't think it is memoizable considering the recursive function has 6 dimensions. Try optimizing this and bring that 6 down to a 2.
 » 18 months ago, # |   0 please share hint for C.