### Vovuh's blog

By Vovuh, history, 2 weeks ago, ,

UPD: Special thanks to Mikhail PikMike Piklyaev for help with translation and problems discussing, Maksim Ne0n25 Mescheryakov for problems discussing, Artem Rox Plotkin, Daria ZeroAmbition Stepanova and Tommy STommydx Li for testing the round!

UPD2: Editorial is published!

<almost-copy-pasted-part>

Hello! Codeforces Round #590 (Div. 3) will start at Oct/01/2019 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 Mikhail PikMike Piklyaev, Maksim Ne0n25 Mescheryakov and Ivan BledDest Androsov for help in round preparation and testing the round.

Good luck!

I also would like to say that participants who will submit wrong solutions on purpose and hack them afterwards (example) will not be shown in the hacking leaders table.

</almost-copy-pasted-part>

• +279

 » 2 weeks ago, # | ← Rev. 3 →   +28 I can’t register for the contest unofficially. Is something wrong? Edit: Can now.
•  » » 13 days ago, # ^ | ← Rev. 3 →   -60 maybe delete this contest? if you agree upvote me
 » 2 weeks ago, # |   -28 rtd?
 » 2 weeks ago, # |   +17 what factor decides the number of problems ? Planetory motion?
•  » » 2 weeks ago, # ^ |   +72 We increase the number of problems by adding some new problems or subtasks of existing problems to smooth some gaps in difficulty.
 » 2 weeks ago, # | ← Rev. 2 →   0 Don't give up, Learn from your mistake I've made some mistake on Vovuh's previous contest Educational Codeforces Round 73 (Rated for Div. 2) and Codeforces Round #587 (Div. 3), It's my high time to apply what's I learn from that mistake. Thanks Vovuh for giving us another chance to improve our skills (and rating ;-) )
•  » » 2 weeks ago, # ^ | ← Rev. 2 →   -37 Lolololollolollllll, who asked you to divulge the story of your life??
•  » » 2 weeks ago, # ^ | ← Rev. 2 →   +32 Never give up. One day we 'll change our colour.
 » 2 weeks ago, # | ← Rev. 3 →   0 This contets is 1234 contest in codeforces Good luck to everyone.Codeforces Round #590 (Div. 3)https://codeforces.com/contests/1234
•  » » 2 weeks ago, # ^ |   +26 Thanks for the billion dollar information. You saved the world.
 » 2 weeks ago, # |   +9 Will Vovuh surpass PikMike
•  » » 2 weeks ago, # ^ |   +87 I don't think it becomes true someday :(Div.3 are much less useful for most participants so I gain less contribution than this tiny anime girl.
•  » » » 13 days ago, # ^ |   +18 Yes and Educational rounds are also as frequent as div3 rounds. But you are only 2 points behind him. Maybe it will happen some day.
•  » » » 13 days ago, # ^ |   +37 I think they're more useful. Div. 3 taught me a lot of standard tricks and quicker implementation back when I was a beginner. Educational rounds serve a similar purpose, but require a contestant to have a fair amount of familiarity with the aforementioned standard tricks. Since there are many more beginners in competitive programming, Div. 3 contests are far more valuable to introduce people to problem-solving.Keep up the good work, man!
•  » » » 12 days ago, # ^ |   +18 TRUE NOW!Congrats Vovuh
•  » » » » 11 days ago, # ^ |   +20 Spoiler
•  » » » » 11 days ago, # ^ | ← Rev. 2 →   +36 And now I can finally say thank you and deliver a message to PikMike: Spoiler
•  » » » » » 2 days ago, # ^ | ← Rev. 2 →   0 Now PikMike's contribution is higher than Vovuh again :XD.
 » 2 weeks ago, # |   0 I really like your contests, hope it doesn't get like Codeforces Round #579 (Div. 3) that the judge was so slow. good luck in the future contests Vovuh :)
•  » » 13 days ago, # ^ |   +7 Well guess div3 always gets a judging queue that ruins the contest.
 » 13 days ago, # |   -9 GOOD LUCK!
 » 13 days ago, # |   +8 I_love_Vovuh
 » 13 days ago, # |   +9 I will AK this contest !!! And I will AK IOI2020 in just 3min with Denverjin !!!
•  » » 13 days ago, # ^ |   +9 Yes, I will.
•  » » 13 days ago, # ^ |   +13 As you see, I have AKed the contest. It means that I will AK IOI soon.
•  » » » 12 days ago, # ^ |   +8 HYHAKIOI!
 » 13 days ago, # |   +6 I know that it is out of topic, but will the Technocup Elimination Round 1 be rated?!
•  » » 13 days ago, # ^ |   0 Well, I guess that Technocup Elimination Round 1 announcement would be a better place for such question.
•  » » 10 days ago, # ^ | ← Rev. 2 →   0 Yes,It is ! :)
 » 13 days ago, # |   -41 Hope to become blue after this round.
•  » » 13 days ago, # ^ |   -28 you downvoted me.... but I still will show my strength in the contest!!! (angery smiley)
•  » » » 13 days ago, # ^ |   +3 Think you'll become blue)
 » 13 days ago, # |   +7 Can anyone please tell me which problem has two subtasks? @Vovuh
•  » » 13 days ago, # ^ |   -27 problem A
 » 13 days ago, # |   -20 Hopefully problems won't be bad like last contest!
 » 13 days ago, # |   +57 QueueForces?
•  » » 13 days ago, # ^ |   0 exactly!
 » 13 days ago, # | ← Rev. 2 →   -12 What is the reason behind giving ~50 test flies for problem D?
 » 13 days ago, # |   +9 Why always this problem -> Queue
 » 13 days ago, # | ← Rev. 5 →   0 More than 5 minutes testing queue :(
 » 13 days ago, # |   -6 The queues are annoying.
 » 13 days ago, # |   -6 this queue affected me really more than 15 minutes !
 » 13 days ago, # |   0 Look at rank 17 (Alex_____Wei) and rank 18 (AIex_Wei). Are they the same person?
•  » » 13 days ago, # ^ |   +6 NO , I'm just another account of Alex_WeiAnd AIex_Wei is a FAKE one , he is chenxiaoyan
•  » » » 12 days ago, # ^ |   +1 So, in total how many accounts you have? 1 or 2?
•  » » » » 12 days ago, # ^ |   +1
•  » » » » » 12 days ago, # ^ |   +1 Why you do this?
•  » » » » » » 12 days ago, # ^ |   +1 In order to compete in Div.3
•  » » » » » » » 12 days ago, # ^ |   +5 You can always do that unofficially like lot of reds and oranges. Wouldn't new accounts affect ratings of normal div 3 people. Not sure how cf treats new user.
 » 13 days ago, # |   +7 Is F a well-known problem?
•  » » 13 days ago, # ^ |   0 How to solve F? I tried solving it using trie greedily but later figured out that greedy won't work.
•  » » 13 days ago, # ^ |   +5 Yeah an application of SOS(sum over subsets) dp. Link to the blog is :Link
 » 13 days ago, # |   +76 :(
•  » » 13 days ago, # ^ | ← Rev. 2 →   +13 Drake no: ScreenshotDrake yes: Photo of screen
•  » » 13 days ago, # ^ |   0 lol
•  » » 13 days ago, # ^ |   0 this legit happened to me today
•  » » 13 days ago, # ^ |   0 nice :)))))))))
 » 13 days ago, # |   0 I tried to solve D using fenwick tree but I failed coding it terribly anyone can tell what's wrong in my solution link
•  » » 13 days ago, # ^ |   0 there are 26 lowercase characters I used bitwise OR segment tree then count the number of bits for the L,R range
•  » » » 13 days ago, # ^ |   0 I know but it can be done with fenwick tree also but I did something wrong
•  » » 13 days ago, # ^ |   0 Your n is not initialized anywhere in the code. int BIT[100002][26], a[1000],t,n;string s; void update(int x, char ch) { int ind=int(ch-'a'); for(; x <= 100001; x += x&-x) BIT[x][ind] ++;//,cout<
•  » » » 13 days ago, # ^ |   0 in update I made the limit to 100001 and forgot to make it in delet but that's not the problem
•  » » » » 13 days ago, # ^ |   +4 One more bug  for(; x > 0; x -= x&-x); sum[i] += BIT[x][i]; What's that semicolon doing at the end of for loop
•  » » » » » 13 days ago, # ^ |   0 Also you need to re-initialize x again, you are depleting it for a itself void query(int x) { for(int i=0;i<26;i++)sum[i]=0; for(int i=0;i<26;i++){ for(; x > 0; x -= x&-x) sum[i] += BIT[x][i]; } Fix all these and try
•  » » » » » » 12 days ago, # ^ |   0 thx bro got accepted
•  » » 13 days ago, # ^ | ← Rev. 2 →   +2 You can solve it easer. Just take a 26 sets of $i$th character positions ($i$th set contains positions of $i$th alphabet char in string). So, when you've got a update query, just delete $pos$ from $lastc$th set, and add $pos$ to $c$th set. When you've got a count request, for each of 26 charactes find any index in set, where $i\geq l$ and $i\leq r$, if it exists, just add one to answer.
•  » » » 13 days ago, # ^ |   +4 Here is the code for the above approach : https://codeforces.com/contest/1234/submission/61643240
•  » » » » 13 days ago, # ^ |   0 Hey can you explain your approach a bit so that i can understand your code easily?
•  » » » » » 13 days ago, # ^ |   0 Same as explained by MrLolthe1st. 26 sets that maintain the indices of the 26 alphabets.
•  » » » » 13 days ago, # ^ |   0 The problem became so easy with your solution. Thank you dude
•  » » » 13 days ago, # ^ |   0 That's easier damn but I still want to know wth is happening in my code it didnt make any sense to me all values are 0 even though im updating
•  » » » » 13 days ago, # ^ |   0 You also missed to update s else { cin>>xx>>c; delet(xx,s[xx-1]); s[xx-1] = c; // i added update(xx,c); } But I guess there is still more bug
•  » » » » » 13 days ago, # ^ |   0 that's not necessary what matters is BIT array and all of it is zero and I can't figure out why
•  » » » » » » 13 days ago, # ^ |   0 that's not necessary really? Wouldn't you delet some other character if same xx comes later on?
•  » » » » » » » 13 days ago, # ^ |   0 yeaaah yeah that's right but as you said there's another bug
•  » » » » » » » 13 days ago, # ^ |   +3 me in this round
•  » » » » » » » » 13 days ago, # ^ | ← Rev. 2 →   +18 Drake no: Debugging own codeDrake yes: Create meme on self
•  » » 13 days ago, # ^ | ← Rev. 3 →   0 I tried to solved D by simply map and string. I thought it will got TLE but I got AC. Here is my code. Can anyone suggest what is complexity for my code?
•  » » » 13 days ago, # ^ |   0 Its $O(Q*N)$
•  » » » » 13 days ago, # ^ |   0 So How do I got AC instead of TLE?
•  » » » » » 13 days ago, # ^ | ← Rev. 2 →   0 Some optimizations in C++ language itself.From docs: Complexity of substrUnspecified, but generally linear in the length of the returned object. The unspecified part is interesting, will need to check the source of C++ to know more.Same for find.
•  » » » » » 13 days ago, # ^ |   0 Pretest is a little bit weak. Some submissions in $O(QN)$ can pass the pretest.
•  » » » 13 days ago, # ^ |   0 i solved D by hashing and string, then i got TLE...after i changed string to char array i got AC
 » 13 days ago, # | ← Rev. 2 →   0 Sorry, but don't know the purpose of problem D unless there exist a solution without log(n) factor. C was far better than D. How to solve E?
•  » » 13 days ago, # ^ | ← Rev. 7 →   0 First of all,if we know p(k) we can answer pos(p(k),x[i]) instantly:1)x[i] == k- pos(p(k),x[i]) = 12)x[i] < k — pos(p(k),x[i]) = x[i]+13)x[i] > k — pos(p(k),x[i]) = x[i]its true,because p(k) means that in first position k,in 2nd-1,3rd-2,...,k- k-1,k+1 -k+1,...(k,1,2,3,...,k-1,k+1,...,n)so now we want to answer abs(pos(p(k),x[i])-pos(p(k),x[i+1])),there will be 8 possible cases,like: x[i] > k && x[i+1] < k...the main thing what we just go through all the m-1 elements and say which k will increaselike if x[i] < k && x[i+1] < k than we should increase every k bigger than max(x[i],x[i+1]) to abs(x[i]-x[i+1])and we can do it with prefix sums( to add x from l to r we pref[l]+=x and pref[r+1]-=x).So now answer for f(p(k)) will be sum from 1 to k,we just go from 1 to n and every time add pref[i]Hope it will help,sorry for my english Here is my submissoion 61661243P.S I just hope what i wont be hacked after this XD
•  » » » 13 days ago, # ^ | ← Rev. 2 →   0 if u have spare time could u help me to debug my Ecode please? i got a TLE but i dont know how to change it.submission
•  » » » » 13 days ago, # ^ |   0 You get TLE,because its O(n*m) that can be very big(m <= 10^5 and n <= 10^5).I cant write anything more to you than i wrote above,your algorithm is just too slow
 » 13 days ago, # |   +38
 » 13 days ago, # |   0 How to solve C?
•  » » 13 days ago, # ^ |   0 There is one way from $(1,1)$ to $(2,n)$ in any dataset, for which answer is "YES", only .
•  » » 13 days ago, # ^ |   +1 I have used the simulation strategy to solve this problem:start from column 1 and row 1 :if(pipe of type 1 or 2): you have to just move to next column with the same row else if(pipe of type 3,4,5 or 6): ... check the other row with the same column should have pipes(3,4,5 or 6), if(check = true): just change the value of row i.e from row=1 to row 2 or from row=2 to row 1 else if(check = false): you should print no as final answerat last if row == 1: you should print 'NO' else The final result remains as it is what you get from the previous steps
•  » » 13 days ago, # ^ |   0 You can understand better with my code: q=int(input())for _ in range(q): n=int(input()) s1=input() #column 1 s2=input() #column 2 r=1 #value of row ch=1 #variable to check the results during simulation for i in range(n): if(r==1): if(s1[i]=='1' or s1[i]=='2'): ch=ch r=1 else: r=2 if(s2[i]=='1' or s2[i]=='2'): ch=0 else: if(s2[i]=='1' or s2[i]=='2'): ch=ch r=2 else: r=1 if(s1[i]=='1' or s1[i]=='2'): ch=0 if(ch==0 or r==1): print("NO") else: print("YES")
•  » » » 13 days ago, # ^ |   0 I used the same logic but there was a small mistake which I could fix only now :(( while(q--){ int n; cin >> n; int arr[2][200002]; string s; cin >> s; for(int i = 0; i < n; ++i) arr[0][i] = (s[i]-'0'); cin >> s; for(int i = 0; i < n; ++i) arr[1][i] = (s[i]-'0'); int row = 0;// 0th row; bool done = false; for(int i = 0; i < n; ++i){ if((arr[row][i] == 3) || (arr[row][i] == 4) || (arr[row][i] == 5) || (arr[row][i] == 6) ){ if((arr[1-row][i] == 1) || (arr[1-row][i] == 2) ){ cout << "NO\n"; done = true; break; } row = 1-row; } } if(row == 1 && !done){ cout << "YES\n"; } else if(row == 0 && !done){ cout << "NO\n"; } 
•  » » » » 13 days ago, # ^ |   0 What is the mistake?
•  » » » » » 13 days ago, # ^ |   0 No mistake in this code. But earlier I was missing one thing. It's just to tell I thought the same :)
•  » » 13 days ago, # ^ |   0 I solved C using recursion, but was able to submit after 20 min of contest(my bad was not able to figure out one error)Usually during contest, i coded with comments so i don't get lost for what i need to do.You can check my submission here: https://codeforces.com/contest/1234/submission/61665005
•  » » » 13 days ago, # ^ |   0 simpler recursive approach: https://codeforces.com/contest/1234/submission/61629368
 » 13 days ago, # | ← Rev. 2 →   0 Can anybody tell me test case 4th in problem E? EDIT Forgot to take long long :(
 » 13 days ago, # |   0 Why unordered_map fails for Problem B2? I got TLE using unordered_map, but I got AC using map.
•  » » 13 days ago, # ^ | ← Rev. 2 →   -9 lol same wasted 2 hours over this. All solution on B2 should be rejudged everyone knows unordered_map is faster than map . It costed me almost 1000 rank due to this shitty issue.
•  » » » 13 days ago, # ^ |   0 SAME HERE BROTHER
•  » » » 13 days ago, # ^ |   0 Well ordered_map is always LogN Unordered_map isn't always O(1). It's usually O(k) where k is the size of buckets. Since in many cases k is small we take it as O(1). However when there is alot of collisions then it is O(n)
•  » » 13 days ago, # ^ |   0 me too.o(╥﹏╥)o .So I didn't solve B2 in the contest .And I want to know why the unordered_map is less efficient than map this time.
•  » » » 13 days ago, # ^ |   0 unordered_map has a biiiig constant. sometimes, it doesn't works better, than map. And use there deque, not maps.
•  » » » » 13 days ago, # ^ |   0 I used map (to save # of displaying ids) AND deque (to save displaying ids and their order). Can we use deque instead of map?
•  » » 13 days ago, # ^ |   +3 Even I wasted almost 30 min on this to recall that the worst case complexity of unordered map or hashmap is O(n) i.e. linear time...Kudos to B2 problem to refresh my basics. But unfortunately I'll be afraid of using it in future
•  » » » 13 days ago, # ^ |   0 Can you tell me why unordered_map was going to the complexity of O(n) ? In a past contest I was getting TlE because I used map and got AC after changing it to unordered_map . Now I am just confused what to use because of this .
•  » » » » 13 days ago, # ^ |   0 It's linear because of collision. I suggest you to read about hashing and collision.And when you got AC earlier with unordered_map, it must be because the test cases were such that the collision was minimum
•  » » » » » 13 days ago, # ^ |   0 I have no idea how you managed to get TLE just because of the unordered_set. For me it is faster than the set on the given test data...unordered_set:61684841set:61666722
•  » » » 13 days ago, # ^ |   0 I used unordered set in D and got TLE. I'll also be afraid of using it in future :(
•  » » 13 days ago, # ^ |   0 unordered_map has worst case complexity of O(N^2). For map it's O(logN). read here — https://codeforces.com/blog/entry/62393
 » 13 days ago, # |   +1 Hi all I tried to solve problem D using segment tree , but gets TLE at test 4. What's wrong with my submission ?
•  » » 13 days ago, # ^ |   0 Do not solve D with segment tree.
•  » » » 13 days ago, # ^ |   0 I solved D using segment tree. https://codeforces.com/contest/1234/submission/61635269
•  » » » » 13 days ago, # ^ |   0 I also can solve a * b problem with segment tree, and what ?
•  » » » » » 13 days ago, # ^ |   0 What? You can easily implement segtree and get AC, why not?
•  » » » » 12 days ago, # ^ |   0 Can you explain you solution please ?
•  » » » » » 12 days ago, # ^ |   0 Build a OR segtree and print popcount(number of 1s in the result)You can understand this easier by reading my code.
•  » » » 13 days ago, # ^ |   0 what's the alternative approach??
•  » » » » 13 days ago, # ^ |   +1 $O(Q\times\log{n})$
•  » » » » 13 days ago, # ^ | ← Rev. 2 →   +2 26 binary searches for one query
•  » » » 13 days ago, # ^ |   0 why ?
•  » » » 13 days ago, # ^ |   +1 I solved D using binary search based on data structure set. So, the complexity is $O(q*log(n))$. Firstly, I stored all positions of character c ('a' <= c <= 'z') which occurs in s in set list[c]. After that, each query, if type 1 I erase pos in list[s[pos]] and insert pos in list[c]. If type 2, I check all characters (maximum 26 characters) if range [l:r] covers atleast 1 charater c (using binary search in set), i increase answer.My solution
•  » » 13 days ago, # ^ | ← Rev. 2 →   0 your query function works with O(26*log(26)*log(N)*Q) it is about 10^9 operations
•  » » 13 days ago, # ^ |   0 You merge 2 sets in each node of your tree. It's something like O(q * n * log(N) * log(N))
•  » » 13 days ago, # ^ |   0 Just change set to a vector it'll pass
 » 13 days ago, # |   0 Can anyone please tell me the difference between these 2 codes for problem B2 — https://codeforces.com/contest/1234/submission/61663199 (AC code)
•  » » 13 days ago, # ^ |   0 dont use unordered map without custom hash or else you'll get tle.
•  » » » 13 days ago, # ^ |   0 Yes my mistake I should have read about custom hash earlier didn't know unordered_map could got to O(n^2).
 » 13 days ago, # |   +13 something wrong with the problem tags
•  » » 13 days ago, # ^ |   0 Also, lot of problems are tagged something but there is no reference solution (in tutorial) which uses that tag. So, the tag is more or less useless.
•  » » 12 days ago, # ^ |   0 its becuas dp is double important :)))
•  » » » 12 days ago, # ^ |   0 and also bitmask
 » 13 days ago, # |   0 I registered but didn't manage to enter the contest in time. Is my rating going to get affected ?
•  » » 13 days ago, # ^ |   0 Your rating won't change unless you submit any solutions.
 » 13 days ago, # |   +1 In Problem A, those who used ceil() function directly in cout, got WA.. Could you please explain why??
•  » » 13 days ago, # ^ |   +1 ceil returns a double/float. you can make that: int ceil2(int a, int b){ return a / b + !!(a % b); } 
•  » » 13 days ago, # ^ |   +1
•  » » 13 days ago, # ^ | ← Rev. 2 →   +10 U can use a well known trick to divide n by k rounding up. This value is a (n + k — 1) / k.
•  » » » 13 days ago, # ^ |   0 Very Interesting..
•  » » » » 13 days ago, # ^ |   0 I didn't understand the proof [here]. (https://math.stackexchange.com/questions/356168/prove-the-following-ceiling-and-floor-identities) \begin{align*} &(1)\quad \left\lceil {\frac{a}{b}} \right\rceil \le \frac{a + b — 1}{b}\\ &(2)\quad \left\lfloor {\frac{a}{b}} \right\rfloor \le \frac{a — b + 1}{b} \end{align*}
•  » » » 12 days ago, # ^ | ← Rev. 2 →   0 Note though that this only works well if $n$ and $k$ are both non-negative.
 » 13 days ago, # | ← Rev. 2 →   0 Can Anyone tell me what's wrong with my code for D. I'm getting TLE for this Sol link — https://codeforces.com/contest/1234/submission/61662523
 » 13 days ago, # |   +21 haha, this div3 was more educational for me than all educational rounds.
 » 13 days ago, # |   0 Admin please rejudge the solutions of problem B2 for those who get TLE for using unordered_map and got AC by changing it to map . It wasted valuable time trying to figuring this out and I thought it was problem with my logic.
•  » » 13 days ago, # ^ |   0
•  » » » 13 days ago, # ^ |   0 Wish I had seen this post earlier.
 » 13 days ago, # |   0 I did D by using a segment tree where I used ith bit to represent ith character is present or not in subarray. For Query I took 'OR' of left and right interval and then the popcount for unique. For Update first reset the previous value then set the new value. But I got WA on test 8. Can anyone find bug in my code or give small case where I am failing. Submission
 » 13 days ago, # | ← Rev. 2 →   0 is there any way we can use binary search on TreeSet In Java. In problem D was adding all the indexes of every character in TreeSet but don't know how to use binary search on TreeSet.
•  » » 13 days ago, # ^ |   0 Few useful functions of TreeSet that resembles binary search: tree.floor(int), tree.ceil(int), tree.higher(int), tree.lower(int)
 » 13 days ago, # |   +4 How to solve F??
 » 13 days ago, # | ← Rev. 2 →   +1 Why do I get TLE here? It is simple segment tree working in q * 26 * LOGN https://codeforces.com/contest/1234/submission/61659331
•  » » 13 days ago, # ^ |   0 My solution with IT: https://codeforces.com/contest/1234/submission/61659385 350ms
•  » » » 13 days ago, # ^ | ← Rev. 2 →   0 What is IT? indexed tree?
•  » » » » 13 days ago, # ^ | ← Rev. 2 →   0 Interval Tree
 » 13 days ago, # |   0 I came up with the ideal of problem C early but I can't implement it quickly. It took me more than 1 hour to implement C. So, I have about 30 min left for problem D, I also came up with the solution but I can't debug on time. Now I solved D, very funny experiment =)))
 » 13 days ago, # |   +2 I used segment tree, stored set in each node, i think the complexity should be O(q*log(n)*27). And i got TLE, Any idea why?
•  » » 13 days ago, # ^ |   +1 My solution with IT: https://codeforces.com/contest/1234/submission/61659385 350ms
•  » » 13 days ago, # ^ |   +1 Your solution works O(26*log(26)*log(N)*Q) it is about 10^9 operations
•  » » » 13 days ago, # ^ |   +1 https://codeforces.com/contest/1234/submission/61659331 This is q * 26 * logN....but still TLE ...any idea what's wrong?
•  » » » » 13 days ago, # ^ |   0 I don't prefer your realization of segment tree, but does you sure that here if(l > en || l < st) return; // don't go beyondall ok?
•  » » » » » 13 days ago, # ^ |   0 We only need to update nodes for which l lies in range [st to en] ....so i don't think that should be a problem
•  » » » 13 days ago, # ^ |   0 Log(26) because of the insert in the set, that's right?
•  » » » » 13 days ago, # ^ |   0 yes
•  » » 13 days ago, # ^ | ← Rev. 2 →   +1 your solution working in O(q*logn*n*log27), may be that so, because each of node you merged 2 two set. sorry my bad english
•  » » » 13 days ago, # ^ |   0 In "O(q*logn*n*log27)", Why there is 'n'? I think it should be "27" instead of n, Because the size of the set will not exceed "27". And even if it's "27", it is about 10^9 operations.
•  » » » » 13 days ago, # ^ |   +1 I'm Sorry. Your solution working in exactly O(qlogn*27*log27) time. sr
 » 13 days ago, # |   +1 Pathetic Contest
 » 13 days ago, # | ← Rev. 2 →   0 the best hacker link
•  » » 13 days ago, # ^ |   0 He very humorous =))
 » 13 days ago, # |   0 Can anyone explain why unordered_map solution is getting TLE and map solution is getting accepted for problem B2. Is there any specific case where unordered_map is slower than map.
•  » » 13 days ago, # ^ |   0 dependent on data type, umap is faster than map when you can sort large arr
•  » » 13 days ago, # ^ |   0 Yeah when there is alot of collisons then unordered_map isn't O(1). However ordered_map is always o(1)
•  » » » 13 days ago, # ^ | ← Rev. 3 →   0 I think ordered map is O(logn) in general case... Also I think there is a very similar and famous problem like problem B2 presented today where unordered map can give TLE, it's on codeforces only, — Molly's Chemicals, if anyone want to try it out...
 » 13 days ago, # |   +2 how to solve C??
•  » » 13 days ago, # ^ | ← Rev. 3 →   +1 First you can start with the idea that there is only a single path that can allow flow of water from (1,1) to (2,n+1),because if you receive water from one side of pipe, another end can only face a fixed direction if you are getting water from fixed and unique direction (except for the case when you have tilted pipe and receive water from left side to that pipe, so it could continue flow in up or down direction ). So simulate that flow till either an out of bounds occur, otherwise if you reach (2,n+1) before, your answer is "YES", otherwise "NO". Hope it helps
•  » » 13 days ago, # ^ |   0 There is an easier way: if both squares in the same column are one of the four states 3, 4, 5, and 6, then water can flow from the current line to another line. Otherwise, you can only let the water continue to flow on the current line. Finally, judge whether the water can flow to the second line of the Nth column.
 » 13 days ago, # |   0 I see people complaining that unordered_map gets TLE, then why didn't I get TLE during contest, even I didn't get it after the contest. (Just submitted 2 min ago)
•  » » 13 days ago, # ^ |   +5 It's because you are erasing the elements. AC with erase: https://codeforces.com/contest/1234/submission/61669672 TLE without erase: https://codeforces.com/contest/1234/submission/61648570
•  » » » 13 days ago, # ^ |   0 But still if someone set k = n and throws distinct numbers , wouldn't the first and second be same ? , what makes unordered_map TLE ? (More elements or same elements frequently ? )
•  » » » » 13 days ago, # ^ |   0 Not sure, This might help : https://codeforces.com/blog/entry/62393
•  » » » » 13 days ago, # ^ |   0 what makes it go O(n) is that the numbers entered get hashed to the same hash value, i.e. if internally a poor hash function is being implemented;Generally it has no effect but here I think the test cases were such that unordered_map could not hold good.
•  » » » » » 12 days ago, # ^ | ← Rev. 2 →   0 Not quite "same hash value" (though that is a factor when dealing with things like strings); the more pertinent issue is bucket collisions. For example, even if there are $2^{32}$ possible hashes, the actual number of buckets in the map is often much less (stepping up as more values get added based on something called the "load factor"), so if the hash modulo bucket-size is equal you'd get a bucket collision. In such cases C++ unordered_maps would store a linked list in each bucket, making access potentially $O(n)$ time for adversarial cases.Java's HashMaps handles this problem better since Java 8, as if too many items are put into the same bucket, the internal linked list gets converted into a tree, thus worst case access is $O(\log n)$ time.
•  » » 13 days ago, # ^ |   0 Well, you must hack this submission then. He used unordered_set and still got AClink
•  » » 13 days ago, # ^ |   0 Just submitted 2 min ago Hacks are not added yet..
 » 13 days ago, # |   +1 My question might be stupid but I gotta ask. What's the point of having a hacking phase in Div3 and Edu rounds if hacks aren't counted in the score?
•  » » 13 days ago, # ^ | ← Rev. 2 →   +1 The point is to let others find the error of your program, improves yourself on a certain level, to reduce unnecessary errors.(Or it's just for fun?)
 » 13 days ago, # | ← Rev. 2 →   +3 I tried to solve D using sqrt decomposition but didn't manage to implement it right, can someone spot the error in my code? IdeaLink
•  » » 13 days ago, # ^ |   0 There is also the issue of time limit, it runs in $O(Q* nlog(n))$ due to sorting all the time. So, sqrt decomposition did not help much.
 » 13 days ago, # |   +7 After quiting codeforce contest for about 3 years, I participated in 590 and 589.It seems the problems have become harder than that of 3 years ago, problem E and F of 590 div3 has similar difficulty of typical div2 E 3 years ago. I thought I had been more skilled, but the problems have been harder...
•  » » 13 days ago, # ^ |   0 The future is now old man.jpg
 » 13 days ago, # | ← Rev. 4 →   +13 For Problem F ; You can use SOS DP. Question Statement changed : We need to find out 2 substrings such that they contain different letters and are non overlapping.If we were to consider the strings as integers, where each character represents a bit ( where in set bit means that, the character is present ). For eg : binary for ac would be 101. Now you need to form all such numbers(strings which cannot have length more than 20, as then it would for sure contain a repeat).So insert all the strings starting at one position without having any repeated character. And then you need to check for each number whether it has a subset of its complement. We will consider the subset having the maximum number of set bits, which can be found out by simple SOS DP. Link to the solution : Using long long int (not required) : it may give tle as this solution : https://codeforces.com/contest/1234/submission/61652445 Using int : https://codeforces.com/contest/1234/submission/61743609
 » 13 days ago, # |   0 Can anyone please tell me what's wrong with my code for B2? 61673618
•  » » 13 days ago, # ^ | ← Rev. 2 →   -7 I believe this part freq[arr[st]]=0; st++; is wrong, what you want to do is freq[brr[st]]=0 because you need to remove the start of brr not the start of arr.
•  » » » 13 days ago, # ^ |   0 Thank you so much. I made a very silly mistake.
 » 13 days ago, # |   -26 WTF!!!!How the Editorial published before end of the hacked phase?!!
 » 13 days ago, # | ← Rev. 2 →   0 The long queue really spoiled the contest to be honest With B2 not working for unordered_map i had to make three wrong submission(equivalent to 45 min long queue wait) to finally realize the error. :\ Could have solved c and d had the queue not been so long :(Changed my dp cause the contest has really spoiled my rating
 » 13 days ago, # |   0 how to solve C problem?I have no idea.
•  » » 12 days ago, # ^ |   0 If both squares in the same column are one of the four states 3, 4, 5, and 6, then water can flow from the current line to another line. Otherwise, you can only let the water continue to flow on the current line. Finally, judge whether the water can flow to the second line of the Nth column.
 » 13 days ago, # |   0 My code for B2 got hacked (time limit exceeded) and i really can't understand why. I made a simple solution with a set and a deque. I have seen this kind of solution at everybody and they still got accepted. 61660949. What can be the problem?
 » 13 days ago, # |   +1 A moment of silence for my fallen brothers and sisters who got TLEd/hacked in B2 because they were innocent enough to trust the default hash in unordered_map and unordered_set instead of using a custom hash. You were too pure for this cruel world filled with hackers.You shall be honoured, your sacrifice shall not be in vain. Fear not, you shall rise stronger than ever, and ascend to your rightful place in this world !
•  » » 13 days ago, # ^ | ← Rev. 2 →   0 I'm one of those brothers. But i still can't fully understand what is the problem with unordered set/map in this problem.
•  » » » 13 days ago, # ^ |   0 Worst case complexity for default hash is $O(n)$. So in everyday cases using it might be okay, but if an adversary knows your hashing scheme they might design a hack that will take linear time, causing hack/TLE. Either use set or use a custom, randomized hash.Check out this post.
•  » » » » 13 days ago, # ^ |   0 Oh, this is really, really painful :))))). Thank you a lot. From now on, i will be really skeptical when using unordered sets/maps. :)))
•  » » » » » 13 days ago, # ^ |   0 No problems, I too got hacked by the same guy, in fact.
•  » » » 12 days ago, # ^ |   0 You can check out this entry. You can always use unordered_set or unordered_map but with a custom hash function. Read the article, and you will understand.
 » 13 days ago, # |   -24 Is it fair that a single person hacks 50 B2 questions with the same test case? The lack of test cases and the long queues made the contest worse!
•  » » 12 days ago, # ^ |   +5 wrong submissions will anyway fail system tests.... even if he sits silent and doesn't hack anyonee....the final result will be same
•  » » » 12 days ago, # ^ |   0 These were Accepted submissions.
•  » » » » 12 days ago, # ^ | ← Rev. 5 →   +12 no they just passed pretests that doesn't mean they are right hacking is done before system test so if a solution is hacked...it would have failed system tests as well if we write a correct solution then nobody can touch it .... if we write a wrong solution nobody can save us
•  » » » » » 12 days ago, # ^ |   0 well, that logic certainly doesn't work for non-deterministic solutions (hashes for instance).
•  » » » » » » 12 days ago, # ^ |   0 yes (:
 » 12 days ago, # |   +4 Getting aged by waiting for system testing.
•  » » 12 days ago, # ^ |   0 Will there be an extra system testing? It says the results are final, hacking phase complete.
•  » » » 12 days ago, # ^ |   0 There will be a final system testing.
 » 12 days ago, # |   +3 When will the ratings be updated for this contest ?
•  » » 12 days ago, # ^ |   +1 waiting for it too.
•  » » 12 days ago, # ^ |   0 After the system testing.
 » 12 days ago, # |   0 i have given the div-3 contest no-590 my rating has not updated yet...Although its not showing that contest in my recent contest history.I had also given div-3 contest earlier but it also not shown.What is the problem can anybody help
•  » » 12 days ago, # ^ |   0 Its undergoing system testing now, after that ratings will be updated.
•  » » » 12 days ago, # ^ |   0 ok thanks
 » 12 days ago, # |   0 Hello, EZZZZZZZZZZ Contest AC in one go.
 » 12 days ago, # |   0 System testing is taking more time than the actual contest.
•  » » 12 days ago, # ^ |   +3 System testing is run on mobile phone instead of servers
 » 12 days ago, # |   +1 Round was cool, especially problem D and E. Hope in future will be rounds like this! Thanks for Vovuh for the nice div3 round.
 » 12 days ago, # |   +1 Hello all! How can I find my position after a contest? (if I haven't a history)
•  » » 12 days ago, # ^ | ← Rev. 2 →   0 Yeah, its weird that one has to keep scrolling the standings. One way I use, go to your user page, click on contests and at the top you will see it https://codeforces.com/contests/with/__Andrewy__
 » 12 days ago, # | ← Rev. 7 →   0 unordered_set let me down on B2 :(Nice tests!This post helps, in case anyone who used unordered_map or unordered_set needs it.
 » 12 days ago, # | ← Rev. 3 →   +1 My Solution to Problem D was skipped . According to the rules , there is no problem to use third party code if it was published before the contest. The problem is a reduced version of the problem DISTNUM . So , i used this as template and changed accordingly , This is my solution . I guess this solution also did something like that . It is a coincidence that both used the same source . So , can you please put me back to the contest ? MikeMirzayanov
 » 12 days ago, # |   -28 I used segment trees for problem D. Each node of the tree was an unordered map of type < long long int, bool >. I am not able to understand how it is showing TLE for test 4. Any help would be highly appreciated. Down below is my code #include using namespace std; #define ll long long int #define rep(i,n) for(i=0;i<(n);i++) #define pb push_back #define mp make_pair #define ff first #define ss second #define all(c) c.begin(),c.end() #define endl "\n" typedef pair< ll, ll > lpair; string s; vector< unordered_map< ll, bool > > tree; void combine(unordered_map< ll, bool >& fin,unordered_map< ll, bool >& s1, unordered_map< ll, bool >& s2) { fin.clear(); unordered_map< ll, bool > :: iterator it; for(it = s1.begin(); it!=s1.end();it++) fin[it->first] = true; for(it = s2.begin(); it!=s2.end();it++) fin[it->first] = true; } void build(ll v, ll t1, ll t2) { if(t1 == t2) { tree[v].clear(); tree[v][s[t1]] = true; } else { ll mid = t1 + (t2 - t1)/2; build(2*v + 1 ,t1,mid); build(2*v + 2,mid+1,t2); combine(tree[v],tree[2*v+1],tree[2*v+2]); } } unordered_map< ll, bool > query(ll v, ll t1, ll t2, ll left, ll right) { map< ll, bool > ch; if(left > right) return ch; if(left == t1 && right == t2) return tree[v]; ll mid = t1 + (t2 - t1)/2; unordered_map< ll, bool > ans; unordered_map< ll, bool > s1 = query(2*v+1,t1,mid,left,min(right,mid)); unordered_map< ll, bool > s2 = query(v*2+2, mid+1, t2, max(left, mid+1), right); combine(ans,s1,s2); return ans; } void update(ll v, ll t1, ll t2, ll pos, char c) { unordered_map< ll, bool > ch; if(t1 == t2) { tree[v].clear(); tree[v][c] = 1; } else { ll mid = t1 + (t2-t1)/2; if(pos <= mid) update(2*v+1,t1,mid,pos,c); else update(2*v+2,mid+1,t2,pos,c); combine(tree[v],tree[2*v+1],tree[2*v+2]); } } void solve() { cin>>s; tree.clear(); tree.resize(4*s.length()+1); build(0,0,s.length()-1); ll q,type,x,y; ll n = s.length(); cin>>q; while(q--) { cin>>type; if(type == 1) { char temp; cin>>x; cin>>temp; update(0, 0, n-1, x-1, temp); } else { cin>>x>>y; cout<
 » 12 days ago, # |   -8 epic contest for epic programmers i congratulate you!1
 » 12 days ago, # |   -8 WHY did you add anti-unordered set tests in B2? I could've become expert in this round https://codeforces.com/contest/1234/standings/participant/28564088# unordered set https://codeforces.com/contest/1234/submission/61718932 usual set
•  » » 12 days ago, # ^ |   +9 Well, educational rounds are educational in this painful way too.
•  » » » 12 days ago, # ^ |   +5 Yep. Lesson learned :-)