### hloya_ygrt's blog

By hloya_ygrt, history, 4 years ago, translation,

Hello everyone!

This Saturday May 20, 21:05 MSK rated Codeforces Round #415 takes place.

As for our previous round 384, the problems were set by Kiril kefaa Gulin and Yura hloya_ygrt Shilyaev. And this time Daniil Melnik Melnichenko joined us! Many thanks to coordinator Alex netman Vistyazh for help in preparations of the round, and also to Mike MikeMirzayanov Mirzayanov for Codeforces and Polygon systems.

While everyone is waiting for second half of "SKAM" series season, we offer you to solve problems, main characters of which would be stunning girl Noora and well-known to you from 794F - Leha and security system hacker Leha!

As always, participants of both divisions will be given 5 problems and 2 hours to solve them. Scoring will be announced before the round.

We hope you'll like our round! I wish everyone good luck and high rating!

UPD: Please pay attention that round was rescheduled.

UPD2: Scoring in each division is standart 500 — 1000 — 1500 — 2000 — 2500

UPD3: We are extremely sorry about the issue with problem C, but since it affected not many participants, round remains rated. At the same time, we can remove your unnecessary submissions and if you were affected, we can make round unrated for you. Please contact KAN with this question.

UPD4: Congratulations to the winners! Editorial will be posted tomorrow.

Div1:

Div2:

UPD5: Editorial is available http://codeforces.com/blog/entry/52099.

• +289

 » 4 years ago, # | ← Rev. 2 →   +5 What about the reschedule? http://codeforces.com/blog/entry/52009edit: nvm
•  » » 4 years ago, # ^ |   +11 Round has been rescheduled to another time.
 » 4 years ago, # | ← Rev. 2 →   -7 Why isn't this on the front page ???UPD: nvm fixed
 » 4 years ago, # | ← Rev. 2 →   +4 Very very unusual start time !!! Too bad :(
•  » » 4 years ago, # ^ |   +6 that's right, in our country it's in 1:05 am
•  » » 4 years ago, # ^ |   0 Agreed
 » 4 years ago, # | ← Rev. 2 →   +7 Duration will be in the middle of night in east Asia, Will u stay up and burn the candle at both ends?
•  » » 4 years ago, # ^ |   +10 same here..participating anyways :D
 » 4 years ago, # |   +14 The start time is 2 am. it's so late. participating anyway...
 » 4 years ago, # | ← Rev. 2 →   -46 ...
 » 4 years ago, # |   0 Hope the contest will enjoyable, and spending night time for the contest will successful. :)
 » 4 years ago, # |   -14 participants were few in these last contests. in the usual cf time, there had been like an average 6K participants. btw there are some people who cheat in the contests. Like the guy who hacked 40 times in the last contest (hacked the same person). there should be consequences for people like them.
•  » » 4 years ago, # ^ |   0 that guy was disqualified :) (didn't know it till now as he was disqualified after the ratings change). he had a 397 up as far as i remember.
•  » » 4 years ago, # ^ |   -9 btw there are some people who cheat in the contests. Like the guy who hacked 40 times in the last contest (hacked the same person). there should be consequences for people like them.
•  » » » 4 years ago, # ^ |   +11 what a beautiful thing, what is it? :|
•  » » » » 4 years ago, # ^ |   +16 A Slowpoke.
•  » » » » 4 years ago, # ^ |   0 Cheating contestant should be transformed into this thing.
 » 4 years ago, # |   +20 MikeMirzayanov IF CF is down for today and round is gping to be unrated.Plz make Update before such things happen.
 » 4 years ago, # |   +6 CF server looks ok now =D Hopefully, it'll stay like this throughout the contest. And it would be really awesome if they can show the standings and the ratings change really quickly. It's already late in my region. :(
 » 4 years ago, # |   +53 I was wondering why the site wouldn't allow me to register for like 5 minutes and then I realized I was currently in div2 lol :D :D
 » 4 years ago, # | ← Rev. 3 →   -29 Another contest from Belarus :) Hope not be same as tourist's contest, that was veryyyyyy bad
•  » » 4 years ago, # ^ |   +26 Maybe instead of complaining you can practice both English and competitive programming?
•  » » » 4 years ago, # ^ |   -24 Can you explain what is wrong with english????
 » 4 years ago, # |   0 Leaving all my exams, I excitedly registered in the contest to celebrate my second year on Codeforces :)
 » 4 years ago, # |   0 15 minutes left. When is the scoring announced?
•  » » 4 years ago, # ^ | ← Rev. 2 →   +5 Maybe when the contest starts :D UPD : I was wrong.
 » 4 years ago, # | ← Rev. 5 →   +6 I dream there will be a day when my rating skyrocket to the moon just like bitcoin price :)P.S. Bitcoin just became candidate master at 1980.
 » 4 years ago, # |   +6 Does the rating predictor extension not work anymore?
•  » » 4 years ago, # ^ |   +4 https://cf-predictor-frontend.herokuapp.com/roundResults.jsp?contestId=810 shows nothing.May be its down or not working
•  » » 4 years ago, # ^ |   0 Sorry. It will be fixed before next contest.
 » 4 years ago, # | ← Rev. 2 →   +150 Russian Code Cup #2.... :'''))))))) (Not 100% sure it will pass though) EDIT: It passed.
•  » » 4 years ago, # ^ |   +6 Congrats!
•  » » » 4 years ago, # ^ |   +6 Thanks :)
•  » » 4 years ago, # ^ |   +5 Congratulations! You passed it :)
 » 4 years ago, # |   +3 How to solve Div2-B?
•  » » 4 years ago, # ^ |   0 If L <= K, you don't have to choose that day. Suppose L > K Let d = Math.min(L, 2*K) — d sort and choose the first f of such that contribute the maximum and sum the others as usual. This should work to give you what you want.
•  » » » 4 years ago, # ^ | ← Rev. 2 →   0 Could you please find mistake in my solution 27246120? Since I have also used same logic as yours. Thank you for reading.
•  » » 4 years ago, # ^ |   0 let add[i] be how much we can add if make a sale in day i. add[i] = max(0, min(l[i] — k[i], k[i])). Then to sell as many items as possible we just sort add and take f biggest values
•  » » 4 years ago, # ^ | ← Rev. 2 →   0 find out the added profit for each element if k is doubled using profit = final — initial where intial = min(k,l) and final = min(2*k,l). now sort these profits and take the f maximum values since you want your answer to maximum. code :- http://ideone.com/yDxz6l
•  » » 4 years ago, # ^ |   0 A[i] : Number of Products that can be sold if not sell out day. B[i] : Number of Products that can be sold if its a sell out day.C[i] : B[i]-A[i]. Sort C. Final answer will be Sum(Array A) + F Highest values from C.
•  » » 4 years ago, # ^ |   0 After sorting array for (Math.min(2*k,l))-(Math.min(k,l)), we take first F elements with sell-off, next without it.
•  » » » 4 years ago, # ^ |   0 what if we keep a vector having min(2*k,l),min(k,l) as pair and sort this vector.For first f values we can add first to the answer and for the rest second? what goes wrong with this approach ?got wa in tc 15.
•  » » » » 4 years ago, # ^ |   0 sorted in descending order.
•  » » » » 4 years ago, # ^ | ← Rev. 2 →   0 You should sort pair by value of difference beetween min(2*k,l) and min(k,l). My Java code of sorting: Long.compare(o2.getKey()-o2.getValue(),o1.getKey()-o1.getValue()); 
•  » » » » » 4 years ago, # ^ |   0 thanks..my logic was wrong.
 » 4 years ago, # |   0 How to solve Div2 C?
•  » » 4 years ago, # ^ |   +11
•  » » » 4 years ago, # ^ |   +12 I found this problem really similar to Kickstart Round B 2017 PROBLEM A
•  » » » » 4 years ago, # ^ |   +1 The only difference being you could solve Kickstart problem in O(n^2) complexity but not this one.
•  » » » » 4 years ago, # ^ | ← Rev. 2 →   0 I am getting WA in Kickstart Round B 2017 PROBLEM A.while the similar code gets accepted in CF.can you help me please to find out what is wrong?my submission:(https://ideone.com/vdTEOv)
•  » » » 4 years ago, # ^ |   +34 So basically people are rewarded for just Googling the problem instead of trying to solve it for themselves? That's just stupid...
•  » » » » 4 years ago, # ^ |   +5 well, i didn't googled it, i participated in kickstart round B, but i agree with your opinion, its stupid!
•  » » » » 4 years ago, # ^ |   0 There are problems which use the same set of principles.This problem belongs to that set.You don't need to google in order to solve it.
•  » » » 4 years ago, # ^ |   0 Whats wrong with my submission 27246547? I folllowed the idea above, but I got TLE... :-(
•  » » » » 4 years ago, # ^ |   0 In java for Arrays.sort you should use non-primitiv type, so you need to change long to Long: Long[] x = new Long[n]; Long[] pot = new Long[n + 5]; Also change nextInt() to nextLong(): x[i] = in.nextLong(); 
•  » » 4 years ago, # ^ |   +11
•  » » 4 years ago, # ^ |   +6 for each i sum += 2i * ai — 2(n - 1 - i) * ai
•  » » » 4 years ago, # ^ |   0 I did the same but it was failing
•  » » » » 4 years ago, # ^ |   0 You have to use mod power O(log(n))
•  » » » » » 4 years ago, # ^ |   0 https://pastebin.com/ghBYxEbDThis is my code . Can you tell the mistake?
•  » » » » » » 4 years ago, # ^ |   0 line 47: (index(i) — index(n — 1 — i)), index(i) could be less than index(n — 1 — i) under the mod
•  » » » » » » 4 years ago, # ^ | ← Rev. 3 →   0 pro += (index(i) - index(n - 1 - i)) * (a[i] % mod);  This seems to be wrong it should be:pro += ((index(i) - index(n - 1 - i)+mod)%mod) * (a[i] % mod); as (a-b)%m = (a-b+m)%m;
•  » » » » » » » 4 years ago, # ^ |   0 Oh..okay ..thanks for help nimxor and eagle93
•  » » » » » 4 years ago, # ^ |   +11 That's not necessary. It's simpler to just precalculate all needed powers of 2 modulo 109 + 7.
•  » » » » » » 4 years ago, # ^ |   0 Using bitwise operations... >D
•  » » 4 years ago, # ^ |   +1 when you write down the subsets and calculate a few values then you will notice a pattern that is highest value never gets subtracted and lowest value never gets added in answer. sort the array lets say a1,a2,a3,a4. now ans is a4-a3 + 2*(a4-a2) + 4*(a4-a1) + (a3-a2) + 2*(a3-a1) + a2-a1. derive this in terms of n and now make a table and note down how many times each element gets added in total and subtracted from total. you will notice that in sorted order element at index i gets added 2^i — 1 times (0 indexing) and gets subtracted 2^(n-i)-1 times. now you can simply iterate in the array and find answer taking care of mod. code :- http://ideone.com/4b4koZ
•  » » » 4 years ago, # ^ |   0 Please, may you explain deeply?
•  » » 4 years ago, # ^ | ← Rev. 2 →   0 Wow! Am I the only one who is stupid enough to use segment tree in Div2.C? 27247380
•  » » » 4 years ago, # ^ |   +15 yes
 » 4 years ago, # | ← Rev. 2 →   +8 Someone tell a clean approach for Div1B? It was easy to find position of one of the ball. But i couldn't get for finding other...Also, i expect lots of system failures (including mine)
•  » » 4 years ago, # ^ | ← Rev. 2 →   +10 Accepted Solution:If the position of the first ball is X, then I searched in the same way for the second ball in 1 => X — 1 & X + 1 => n
•  » » » 4 years ago, # ^ |   +6 getting wa with same approach :/
•  » » » » 4 years ago, # ^ | ← Rev. 2 →   +5 Did you ask if the leftAnswer is better than the rightAnswer or not at the end.
•  » » » » » 4 years ago, # ^ |   0 Yes I did the same, I also compared the leftanswer and right answer in the end. Still WAhttp://codeforces.com/contest/810/submission/27251869
•  » » » » » » 4 years ago, # ^ |   +5 printf("1 %d %d\n",l+1,r+1);I don't do that. I just compare the mid with min(mid+1, hi) to know if I should search to the left of the mid or to the right of it.
 » 4 years ago, # |   +3 What Was pretest 11 div 1 B
•  » » 4 years ago, # ^ |   0 I have wrong answer at it also. I found this test make my code fail 9 3 (2,4,8); I corrected my code and I waiting now to resubmit it. I don't know if it is the test or not.
 » 4 years ago, # |   +71 Are you insane? This round should be definitely unrated. At least for div.1
•  » » 4 years ago, # ^ |   -14 i performed badly hope so your words come true but whats the reason ??
•  » » 4 years ago, # ^ |   -47 ROUND SHOULD BE UNRATED FOR ALL. MikeMirzayanov
•  » » » 4 years ago, # ^ |   -10 Why is that?
•  » » » 4 years ago, # ^ |   +19 First tell me why are you using fake account
•  » » » 4 years ago, # ^ |   +17 The only reason to make the round unrated would be the need to rejudge Div1-C/Div2-E but, now, it has been announced that they can make it personally unrated for you if you have been affected by this issue. So, yeah... I can't see why this round shouldn't be rated.
•  » » 4 years ago, # ^ |   0 We can make it unrated for participants that were affected, if they ask to.
•  » » 4 years ago, # ^ |   +3 Just out of curiosity.Are u gonna make ur round unrated??
•  » » » 4 years ago, # ^ |   +15 Well, if I had +X rating it will be not fair. Since I got -6 it is OK.If authors say that spending 17 minutes trying to find a bug in AC code is OK then it is probably OK.
•  » » » » 4 years ago, # ^ |   0 Yeah in ur case U might have got AC on 2nd question if u had that 17 minutes time.
 » 4 years ago, # |   +15 IMO the difficulty is: A <<<< D <<<<<<<<<<<<<<<<<<<<< B,C << E
•  » » 4 years ago, # ^ |   0 B was easy only once U get the idea of binary search
•  » » » 4 years ago, # ^ |   +13 How could you do binary search? I thought bsearch as soon as I saw the constraint 60, but I couldn't make any ideas about it.
•  » » » » 4 years ago, # ^ | ← Rev. 4 →   0 We can binary search as if there was only one ball, and find a position x where we know that there is a ball.Then we can repeat the same procedure, but this time instead of searching over the region [1, n] we search [1, x - 1] and [x + 1, n].Edit: They are dishes not balls, but same idea :D
•  » » » » » 4 years ago, # ^ | ← Rev. 2 →   +5 Could you tell me how to "binary search as if there was only one dish to find a position x"?EDIT: They are dished not balls xD
•  » » » » » » 4 years ago, # ^ | ← Rev. 7 →   0 At every iteration in our binary search, we query 1 mid mid+1. Based on the answer, we know whether we need to look to the left or to the right for the closest dish, and set lo = mid+1 or hi = mid accordingly.Although this does not find the leftmost dish, it is guaranteed that this will give the location of one of the dishes. To see why, notice that there will always be at least one dish in the starting interval [1, n]. At each iteration of the binary search, the closest dish might change, but there will always be a valid dish in either [lo, mid] or [mid + 1, hi]. If we receive TAK for our query, then we know that there is a dish in the left interval, because if there wasn't, then there must be a dish in the right interval, and the query would have given NIE. The same logic applies for choosing the right interval if we receive NIE. Hope that helps!P.S. This approach is correct: 27248627
•  » » » » » 4 years ago, # ^ |   -8 I did the same as u have said. What is wrong with my code.Gave WA in pretest 11 http://codeforces.com/contest/810/submission/27252700
•  » » » » 4 years ago, # ^ |   +23 If you query (x, x+1), there definitely exists a dish at position <= x if ans is TAK and there exists a dish >= x+1 otherwise. Using this, keep querying (mid, mid+1) and find the position of the first dish. After that check if there exists a dish to its right and use the same procedure on some particular interval on its right. Otherwise do it on the left.
•  » » » » » 4 years ago, # ^ |   +24 Wow..... I thought the idea of querying (x, x+1) but never imagined to do binary search with that. 160 people who solved B must be geniuses!
•  » » » » 4 years ago, # ^ |   0 U can check here.I tried to first find one of the dishes by always taking that half which has closest dish(since it is guaranteed to have a dish).let it be k.Next again do same think for segments (1,k-1) and (k+2,n) and check for cases k-1,k+1,k+2 manually
•  » » » » 4 years ago, # ^ |   -8 The first observation you can make is that, if you assign a value to each dish, you will have an array D, where D[i] == 0 iff there is a dish he ordered. In addition if you imagine the graph, you are looking for 2 minimums of the function f(i) = D[i].Now you can binary search to find this minimums, if after a query the answer is TAK, it must mean there is a minimum to the left, in the same way, if the answer is NIE there must be a minimum to the right.
•  » » 4 years ago, # ^ |   +25 Even though idea on D is easy, splay tree was not a common subject for me (and most coders, I guess) TTI first googled for some splay tree resources, but soon I gave up and wrote N^1.5 solution
•  » » » 4 years ago, # ^ |   0 How can we solve D with Splay Tree? I'm not sure what the easy idea is.
•  » » » 4 years ago, # ^ |   +25 Me too. Actually this was the first time that I used the splay tree. I went to http://cubelover.tistory.com/10, copy-and-pasted, modified a little, and debugged and debugged and debugged. Really wanted to give up, but B and C were far harder, so....
 » 4 years ago, # |   0 What is wrong with my div2C solution ? http://codeforces.com/contest/810/submission/27252345
•  » » 4 years ago, # ^ |   +45 Your mod is 1e9+9 while it should be 1e9+7
•  » » » 4 years ago, # ^ |   -11 It doesn't matter. My previous submissions had 1e9+7 and still didn't pass
•  » » » » 4 years ago, # ^ |   +1 maybe sum < 0 ! sum=sum%mod;
•  » » » » 4 years ago, # ^ |   0 sum=sum+(x[i]*(modular(2,i,mod)-modular(2,n-i-1,mod)))%mod;should besum=sum+(x[i]*((modular(2,i,mod)-modular(2,n-i-1,mod))+mod)%mod)%mod;As (a-b)%m = (a-b+m)%m;as a-b can be negative alsoAlso mod value should be 1e9+7
•  » » » » » 4 years ago, # ^ |   0 Take array 1,2,3. Sum is 6 and it is ok when module is negative.If i change it to be always positive it will output 9 which is not correct
•  » » » » » » 4 years ago, # ^ | ← Rev. 3 →   0 no it gives 6 only.  sum += 1*(1-4+mod)%mod; -->> (1e9+4)*1 sum += 2*(2-2+mod)%mod; -->> (1e9+0)*2 sum += 3*(4-1+mod)%mod; -->> (1e9+10)*3 which comes out to be 6 only when added You shoud take mod with 1e9+7 not 1e9+9 as I said earlier. You are repeating the same mistake.
•  » » » » » » » 4 years ago, # ^ |   0 I'm sorry, my bad, but still my solution gives correct answer. :((
•  » » 4 years ago, # ^ |   0 I think the negative from sum=sum+(x[i]*(modular(2,i,mod)-modular(2,n-i-1,mod)))%mod; Screws up the modulo.CMIIW
•  » » 4 years ago, # ^ |   0 (modular(2,i,mod)-modular(2,n-i-1,mod) this line can be negative so should do:(((modular(2,i,mod)-modular(2,n-i-1,mod))%mod+mod)%mod
•  » » » 4 years ago, # ^ |   0 Consider array 1,2,3. it is -3*1+0*2+3*3 = 6 which is correct. So it doesn't matter i guess
•  » » » » 4 years ago, # ^ | ← Rev. 2 →   0 nono, I mean given i < j, 2^i%mod can be larger thak 2^j%mod.EDIT: imagine if one is 1e9+8, and the other is 1e9+6, the substraction would dive -(1e9+5) instead of whatever value you would need.
•  » » 4 years ago, # ^ |   +4 modular(2,i,mod)-modular(2,n-i-1,mod)) can be negative also and you cannot perform (negative numer) % mod which leads to wromg answer. you need to add multiple of mod to it to make it positive before applying mod opertion
•  » » » 4 years ago, # ^ |   0 Look above, tell me if i'm wrong.
•  » » » 4 years ago, # ^ | ← Rev. 2 →   0 I did not take care of negative modulo but passed the pre-tests. Do you reckon my solution will pass sys tests? I mean I'm pretty sure that negative modulo case would have occured in the pre-tests. How did it pass?
•  » » » » 4 years ago, # ^ |   0 It must work with negative module. And i don't know why it didn't pass.
 » 4 years ago, # |   +8 Div.1 D is quite similar with APIO 2016 Boat, or is it not?
•  » » 4 years ago, # ^ |   +11 The idea itself is completely different, but i was inspired by APIO task when thinking about my own one.
 » 4 years ago, # |   +15 How do you solve Div1 B?
•  » » 4 years ago, # ^ |   +38 I'm pretty confident of the following solution.The amazing trick is to always let a + 1 = b whenever we query. Thus, this gives us the following information: "there is a dish closer to the left" or "there is a dish closer to the right".We are able to find the first dish this way. We perform a sort of "binary search" on the range [1, n]. Each time, we will query two consecutive midpoints m and m + 1 (where m = (l + r) / 2 as usual), then if it tells us there is one closer to the left, we go to [l, m], otherwise [m + 1, r]. Once the range has been compressed to 1 or 2 elements only, we will have found one dish.The second dish can be found similarly. Let x be the location of the first dish. Then, we will perform two separate binary searches like the one above: [1, x - 1] and [x + 1, n]. The amazing thing here is that the first dish x will never conflict with any dish in those ranges; that is, if a dish in either range exist, our binary search will find that and not x.We start with [1, x - 1]. If the answer to the queries is always , and query [x - 1, x] is also , then we will know, that there is no dish in the range [1, x - 1]. Thus we can find the dish in the other range.Overall this takes queries which fits comfortably in 60 queries.
•  » » » 4 years ago, # ^ |   0 I did exactly as you have mentioned. Can you pls point out the mistake in my code. http://codeforces.com/contest/810/submission/27252700
•  » » » 4 years ago, # ^ |   0 I was doing this but wasn't sure about the conflict thing :(
 » 4 years ago, # |   +3 Missed submitting the Div. 1 C by 1 minute... horrible feeling ever! :(
•  » » 4 years ago, # ^ |   +61 Hope you will get WA :)
•  » » » 4 years ago, # ^ |   +1 Wasted too much time, could not spot this bug n && (1LL << k) instead of n & (1LL << k).Such silly mistake cost me like 20 minutes >_<
•  » » » » 4 years ago, # ^ |   +5 Maybe it will be easier for you when I say that once I had p ! = x, instead p|=x. I spent more than 15 x 15 minutes to see it :)
•  » » » 4 years ago, # ^ |   +11 I am depressed
•  » » » » 4 years ago, # ^ |   0 My mom is psychiatrist, so do not worry again :D
•  » » 4 years ago, # ^ |   0 Can you explain how to do it.I thought like we can subtract one from all then a[i][j]=i^j.Later I thought like f(x1,y1,x2,y2)=f(0,0,x2,y2)+f(0,0,x1,y1)-f(0,0,x1,y2)-f(0,0,x2,y1) something of this sort. But i couldnt compute f function.Is this the way to proceed.If not whats ur approach??
 » 4 years ago, # |   0 How to solve div2 C without using double for, which gives TLE for sure? :(
•  » » 4 years ago, # ^ |   0
 » 4 years ago, # |   +29 Problem C:I know that I placed a mistake somewhere OVER 9000 formulas. I know the WA test. I could not find in within 20 minutes of debug.Shit.
 » 4 years ago, # |   0 what is wrong with my Div2 D solution. I used Binary search to first find the 1st dish(let's say k). Then I applied Binary search on 1 to k-1 and k+1 to n to find another solution. http://codeforces.com/contest/810/submission/27252700 The code gives WA on pretest 11.
•  » » 4 years ago, # ^ |   +5 U should'nt do binary search from k+1 to n.U must do from k+2 to n And check for cases k-1,k+1,k+2 separately(this separate cases bcoz equality gives tak)
•  » » » 4 years ago, # ^ | ← Rev. 6 →   0 If I say that a is first ball, then if second ball is little greater than middle of a+1..N then there is a chance that I get TAK, TAK, ... again since a+1 is closer to a and I miss the correct ball which was in middle and shift my range wrongly?
•  » » » 4 years ago, # ^ |   0 Could you please clear my question?
•  » » » » 4 years ago, # ^ |   0 Yeah kind of similar thought since (x+y)/2 is always closer to x than y. So your thought process is right. There is chance of missing some point
 » 4 years ago, # |   +21 I believe for B div 1 better option was asking for one dish and having score 750 :)
 » 4 years ago, # |   +3 Is intended complexity of E O(n * log(n) * 35)?BTW, I was using Wi-Fi of Rushmore Plaza but in the last 30 minutes it started not working. So I couldn't do anything. Is there anyone having same problem?
•  » » 4 years ago, # ^ |   +8 You can improve that to O(n * log(n) * (2 ^ 5) * 5) (or simply O(n * log2(n) * 5) because sum of x 2 ^ d(x) is n*log(n)) by doing some dp trick
•  » » 4 years ago, # ^ | ← Rev. 2 →   +5 I have an solution.
•  » » 4 years ago, # ^ | ← Rev. 2 →   0 I passed it with . It actually should be less but I could only prove an upper bound.
•  » » » 4 years ago, # ^ |   0 Great work!
•  » » 4 years ago, # ^ |   +13 Intended solution has complexity .
•  » » 4 years ago, # ^ |   +8 Till the editorial is not published, everyone can look through the author's solution 27254027 :)
 » 4 years ago, # |   +33 Am I the only one in the world who doesn't like interactive problems :\
•  » » 4 years ago, # ^ |   0 no
•  » » 4 years ago, # ^ |   -11 They should mention in the blog that there are going to be interactive problems at least. -_-
•  » » » 4 years ago, # ^ |   -19 We wanted to, but as it wasn't noticed in VK cup round 3 announce, we decided not to do that.
•  » » » » 4 years ago, # ^ |   0 http://codeforces.com/blog/entry/49376 had it so I thought it was always announced. Nvm then.
•  » » » 4 years ago, # ^ |   +2 Why should they?
•  » » » » 4 years ago, # ^ |   +8 Because some people don't know what an interactive problem is.
•  » » » » » 4 years ago, # ^ |   +5 Do you realize how stupid this actually sounds? Some people will never know what a DP problem is, should this be announced, too? It's been a long time since interactive tasks were introduced by CF, not to mention that the statement makes everything clear.
•  » » » » » » 4 years ago, # ^ | ← Rev. 2 →   +3 I don't think that your comparison is valid, you compared an algorithm (dp) to a technical term ( interactive problem, you should know about flushing, which has nothing to do with CP )
•  » » » » » » » 4 years ago, # ^ |   +2 I don't see how that matters. Flushing has nothing to do with CP? Not sure how you define "has sth to do with CP" but many things had nothing to do with CP until they were used for first time. And even "you should know about flushing" is wrong since the statement tells you what to do. I will once again say that this type of problems were introduced a long ago and the announcements of the first few rounds which used them had a link to the detailed guide.
•  » » » 4 years ago, # ^ |   -10 I am sorry .But do people prepare any template or anything for interactive problems??
•  » » » » 4 years ago, # ^ |   +33 No, they should prepare Aspirin :D
•  » » » » 4 years ago, # ^ |   +27 Something like this does the job for me: #include using namespace std; int main() { } 
•  » » » » 4 years ago, # ^ |   +5 Nope, I just don't like them so I tend to avoid the contests that have them. And I guess there are a lot like me.
 » 4 years ago, # |   +57 It usually sucks when authors put boring stories thinking this will make statements more interesting. But it sucks a damn sight more when their English sucks as much as the stories.
 » 4 years ago, # | ← Rev. 4 →   0 can this problem be solved?shift [l,r] to rightadd to [l,r] 1q,l,r <= 1e5
•  » » 4 years ago, # ^ |   +5 Shifting is just erasing element at position r and inserting it before l. I think it can be done with sqrt decomposition.
•  » » » 4 years ago, # ^ | ← Rev. 2 →   0 How?it is easy to solve D1 with this problem
•  » » 4 years ago, # ^ |   +13 Yes, it can be solved with the help of the data structure called treap. Furthermore the complexity will be about logN on one query.
•  » » » 4 years ago, # ^ |   0 Can you please explain your approach.
•  » » » » 4 years ago, # ^ |   +13 I hope, these two articles and my code may help you.
 » 4 years ago, # |   0 Aren't the value of cells equal to abs(x-y)+1 if((x+y)%2)==0 and equal to x+y-1 otherwise where x and y are the row and column number respectively. I m talking about DIV 1C /DIV2 E
•  » » 4 years ago, # ^ |   +5 They are equal to (x — 1) ^ (y — 1) + 1
•  » » » 4 years ago, # ^ |   0 all the diagonal(1,1 to n,n) elements are 1. it does not satisfy.
•  » » » » 4 years ago, # ^ |   +5 Why? For each a, a^a is equal to zero. So, this condition is statisfied.
•  » » » » » 4 years ago, # ^ |   +4 i thought ^ is pow. my bad thanks
•  » » » 4 years ago, # ^ |   +5 Apart from observation, does there exists any way of proving it?
•  » » » » 4 years ago, # ^ |   +13 Yes, It is equivalent to calculating grundy numbers for a two pile nim of sizes (i-1) and (j-1) and adding one to it.(Nim idea comes from fact that we are taking mex of row and column )
•  » » » » » 4 years ago, # ^ |   0 Thanks, got it
 » 4 years ago, # |   +73 Can somebody explain me, why in B there were "TAK" and "NIE" ("YES" and "NO" in Polish)?
•  » » 4 years ago, # ^ |   +28 It is not fair, you had advantage at the beginning :P
•  » » 4 years ago, # ^ |   +8 Maybe it's cultural appropriation :)
•  » » 4 years ago, # ^ |   +41 3/3 authors and coordinator are from Belarus and this words are the same in belarussian language. Also we are fans of main.edu.pl site and already get used to such answers to queries. :)
 » 4 years ago, # |   +43 Waiting for system testing to start ...
 » 4 years ago, # |   +11 problem C (Do you want a date) link : https://code.google.com/codejam/contest/11304486/dashboard I have submitted the same solution.
•  » » 4 years ago, # ^ |   +3 That contest is old (from 2017) so probably nobody who took part of the contest remembered it...
•  » » 4 years ago, # ^ |   +5 Sorry about that, but we proposed our contest much earlier than kickstart 2017 happened.
•  » » » 4 years ago, # ^ |   0 but how this justifies to keep the round rated as more than 50% of DIV1 people soved only 1 problem which is same to an old problem.
 » 4 years ago, # |   +9 Waiting for System testing
 » 4 years ago, # | ← Rev. 2 →   0 How to solve Div1 C? I only found that dat[i][j] = ((i-1) ^ (j-1)) + 1.
•  » » 4 years ago, # ^ |   0 I couldn't solve it yet so don't take this as a solution but probably you have to solve 4 queries that are query(1,1,x2,y2) — query(1,1,x1-1,y2) — query(1,1,x2,y1-1) + query(1,1,x1-1,y1-1) and then solving queries with x1 = y1 = 0 is easier.Then you can see that there are some squares (of sizes powers of two) that can be calculated easily, but I don't know what happens when the area is too big in one dimension but not in the other one, probably there's something to do with some rectangles that I couldn't calculate but I don't know.
•  » » » 4 years ago, # ^ |   +18 You can calc answer for query(0, 0, x, y, k) with dp (code will desribe it better than words): 27247417
•  » » 4 years ago, # ^ | ← Rev. 4 →   +3 We will solve the problem for queries with x1 = y1 = 0, it's obvious how to solve the actual problem afterwards.Notice that you can create the grid by starting with a 1x1 cell with a 1 in it. Then, to go from size 2k to size 2k + 1 you take four copies of a 2k grid in a square and add 2k to all values in the two 2k cells on the antidiagonal (you may want to print the grid for small values to visualize this).We can use this generation process in reverse: initially the query is contained in a square of some size 2k. We can split it into four subqueries on grids of size 2k - 1. Specifically, if we are querying for ((x, y), M) (where M is the upperbound) on a grid of size 2k, then this is identical to adding together the following four subqueries: ((x, y), M) on a grid of size 2k - 1 ((x - 2k - 1, y), M - 2k - 1) on a grid of size 2k - 1 ((x, y - 2k - 1), M - 2k - 1) on a grid of size 2k - 1 ((x - 2k - 1, y - 2k - 1), M) on a grid of size 2k - 1 This recursion is quite expensive, but it turns out that in a lot of cases we can directly compute the answer. We can also see that the square of size 2k contains all numbers from 1 to 2k, each 2k times each. So if x, y ≥ 2k, i.e. we query the entire square, we can simply add 2k times each of 1..min(2k, M) to the answer. For the case when only one of x, y is larger than 2k you'll have to think a little harder, but that too has a closed form solution.Finally, note that when coming out of the recursion for subqueries on the antidiagonal (where you subtract 2k from M), you actually have to add 2k to the answer for each number that you added 'down there'. So not only should you return the sum of the query from your recursive function, but also the amount of numbers in the sum.EDIT: Here is my accepted solution. It contains some idiosyncracies, I'll post a more compact solution once upsolving is possible.EDIT2: Simpler solution.
•  » » » 4 years ago, # ^ |   0 Thank you! Far better explanation than editorial!
 » 4 years ago, # |   0 Rating of most of the DIV1 users will change on basis of one question today which u can find by googling moreover it was a recent problem so many of the DIV1 users must had participated in that contest too which gives them a super edge over others. This is just not right for CF :(
 » 4 years ago, # |   +133
 » 4 years ago, # |   +4 please start system test.
 » 4 years ago, # | ← Rev. 5 →   +10 I was cheated by the "int".....Though it was hacked for some other reasons. someone's solution for div2/C
 » 4 years ago, # |   0 What was the hacking case for DIV 2B?
•  » » 4 years ago, # ^ |   0 2 1 1000 1001 2 4 
•  » » 4 years ago, # ^ | ← Rev. 2 →   +1 I hacked your solution with this test:2 13 1050 51
•  » » » 4 years ago, # ^ |   0 I got it! Had the algo but wrote a buggy code! :( ans for this is 56, right?
•  » » » » 4 years ago, # ^ |   0 Yes :)
 » 4 years ago, # |   +10 So what is test 47 in D1 A?
•  » » 4 years ago, # ^ |   0 I feel like it must be something bizarre, because running my solution locally against Lewin's on randomly generated cases there is no difference. If anybody is bored here is my submission, 27240358, I can not for the life of me figure out why it is wrong.
•  » » » 4 years ago, # ^ | ← Rev. 2 →   0 Could it be int overflow? (Edit: scratch that, looks fine)
•  » » » 4 years ago, # ^ |   0 I see your solution as running on test 1
•  » » » » 4 years ago, # ^ |   +10 Yeah it seems it is being rejudged. But it originally showed for me as "Wrong answer on test 47".
•  » » » » » 4 years ago, # ^ |   +23 Oh now it shows the issue as: "Can't find file C:\Contesters\Work\invoker-prod\work\codeforces2\4375ab888520facceff67c17abfbd1cf\check-e1271c8a6a57f31648a43d4032fc0bbe\run\output.fd0138e687.txt."On test 47. WTF.
•  » » » » » » 4 years ago, # ^ |   +16 Maybe it is tested on WinXP and the output got encrypted?
•  » » » » » » » 4 years ago, # ^ |   0 Hm yeah I have no idea. But it got rejudged as AC thanks to hloya_ygrt :)
 » 4 years ago, # |   +21 System tests seem to have started and paused...
 » 4 years ago, # |   +33 system test like
•  » » 4 years ago, # ^ |   +6 Is that an IQ-test?
•  » » 4 years ago, # ^ |   -6 I don't understand. What does it mean?
•  » » » 4 years ago, # ^ |   +4 Yeah, I googled that image. It means "to be continued".
 » 4 years ago, # |   0 For Div2 D,First I applied binary search. Stopped the loop when both left and right pointers became equal, that was 1 of the ordered dishes, say k.Then I applied binary search from 1 to k-1, and k+1 to n. At least 1 of these segments had an ordered dish, so finally queried once for the answers obtained in the above 2 binary searches.What is wrong with that?Code
 » 4 years ago, # |   0 Anyone knows why I'm getting WA on test 15 Div2 B?Solution(yes I know my solution is a total overkill...)
•  » » 4 years ago, # ^ |   0 I think what is wrong with your solution is the following: you have to check in the for at line 55 if you have already used the products for that index, because sometimes 2 * products_i could be less than products_j for some i,j, let me know if you need a more detailed explanation
 » 4 years ago, # |   +88 Will ratings be updated today or we'll have to wait until the problem with the people who wants to be unrated is solved?
 » 4 years ago, # |   0 What is the meaning of N=1 in C. Do you want a date?
•  » » 4 years ago, # ^ |   +3 There is one subset, {x}, maximum distance is |x-x|=0.So, answer is zero.
 » 4 years ago, # |   0 Div 2C/Div 1A. Test 69 doesn't accept java's Arrays.sort. So frustrated...
•  » » 4 years ago, # ^ |   +3 Arrays.sort uses modified QuickSort (which is O(n^2) in worst-case) for primitive types. So I don't know how hard to create worst case, but test#69 obviously that case.On other side, Arrays.sort uses TrimSort (which is O(nlogn) for worst-case) for objects. So all you need to do is change x from array of ints to array of Integers.
 » 4 years ago, # |   +58 BANG BANG!
•  » » 4 years ago, # ^ |   0 Congrats!!
•  » » 4 years ago, # ^ |   0 Congrats man!! Back to LGM :D
•  » » 4 years ago, # ^ |   +17 Tasks with polish words in statements && Radewoosh wins.Coincidence?
•  » » » 4 years ago, # ^ |   0 Don't think so
•  » » » 4 years ago, # ^ |   +5 illuminati confirmed
 » 4 years ago, # |   +21 Will div2 rating going to update or not?Its too late
•  » » 4 years ago, # ^ |   0 Still waiting......Div 1 ratings already updated...this time too late!
•  » » 4 years ago, # ^ |   0 Ratings are updated now.
 » 4 years ago, # |   +3 Hi,Can you please help me understand why the following solution exceeds the time limit for div 2 problem C: http://codeforces.com/contest/810/submission/27252557 ? It seems like most accepted solutions have the exact same approach.Thanks
•  » » 4 years ago, # ^ |   +3 People have been complaining about Java sort: http://codeforces.com/blog/entry/52092
 » 4 years ago, # | ← Rev. 2 →   +8 So, what happened with moejy0viiiiiv and jcccccccccccccccccccccsb?Edit: never mind, they probably requested to be excluded due to the issues on problem C.
 » 4 years ago, # | ← Rev. 2 →   0 Hi! In div2 C, I did exactly what I am supposed to but it didnt pass. Can anyone help me please. http://codeforces.com/contest/810/submission/27247180 ____I don't understand whats wrong with this.
•  » » 4 years ago, # ^ |   0 Hi Naruto, my opinion is so. You are using "iter" long long int variable to hold powers of 2. It is signed. Overflow of signed int is not specified. So, probably it overflows and becomes negative.
•  » » 4 years ago, # ^ |   0 iter *= 2 should be by modulo http://codeforces.com/contest/809/submission/27262433
•  » » » 4 years ago, # ^ |   +1 Danm man! I could have got it correct. Thanks a lot.
 » 4 years ago, # |   +1 editorial?
•  » » 4 years ago, # ^ |   0 Waiting too……
 » 4 years ago, # |   +6 Excuse me, where is the editorial?
 » 4 years ago, # | ← Rev. 2 →   0 Hey friends,I was trying to solve problem C of this round in C++, but I've just been getting 'wrong answer' on test 6. I get right answers when there are small values to deal with, but when the numbers get bigger, like in test 6, things go wrong. I feel like the algorithm itself is fine, but I'm not handling the data properly. I'm also new to C++, so that's totally possible. I tried a lot to fix the error, but nothing seems to work. Anyone out there to help me out? I would really appreciate it. Here's my code (http://codeforces.com/contest/810/submission/27260339):include include include using namespace std;int main(){ long long mod = 1000000007;int n; cin >> n;long long arr[n];for (int i = 0; i < n; i++){ cin >> arr[i]; }sort(arr, arr + n);long long ans = 0;for (int k = 0; k < n; k++ ){ ans += (long long)((pow(2, k) — 1)*arr[k]) % mod; ans -= (long long)((pow(2, n-k-1) — 1)*arr[k]) % mod; if(ans < 0){ ans += mod; }} cout << ans%mod << endl; }
•  » » 4 years ago, # ^ | ← Rev. 2 →   +5 This is an overflow issue. You have to typecast the variables inside the brackets, that is, before the multiplication. You are typecasting them after the multiplication.A short trick for this to avoid writing long long everywhere is to just multiply 1LL to the expression which might cause an overflow, which makes the execution of that particular expression in 64-bit. 1LL is an inbuilt long long 1.
•  » » » 4 years ago, # ^ |   0 That doesn't seem to work either:( I implemented the exact same algorithm in python (without all the 'long's and 'int's) and was able to pass test 6. I think it just some data type thing in C++ that I'm not seeing. Can anyone please help me out? Here's my code:27270625
 » 4 years ago, # | ← Rev. 2 →   0 Can anyone say what is wrong with my solution Div 2 B
•  » » 4 years ago, # ^ |   0 People often get WA16 because sorts Math.min(2*k,l), but it should be sorted by difference between Math.min(2*k,l) and Math.min(k,l). So you need sort increasing of profit.
•  » » » 4 years ago, # ^ |   0 Thanks for the help finally got an AC!
 » 4 years ago, # | ← Rev. 2 →   0 How to solve div1 D better than O(n sqrt n)
•  » » 4 years ago, # ^ |   +13 I'll write it here too :) You should use a special data structure called treap. You can read about it somewhere on the Internet (I don't know sites on English, which can help you to understand this data structure) or just look at my code.
•  » » 4 years ago, # ^ |   0 How to solve it in nsqrtn?
•  » » » 4 years ago, # ^ |   +15 The task can be reduced to some queries on an array: delete one element from the array add one element increase all elemets [l,r] by 1 shift segment [l,r] to rightSo sqrt-decomposition may help you to process these queries. And if you want to understand, how it can be reduced to such queries, please, wait the editorial. It will be published in a few hours.
 » 4 years ago, # |   0 A great contest for me! +228, Rank 42 :) It is always 42 indeed! :)
 » 4 years ago, # |   0 Hi,I've tried a method for 809A but its not working. Can anyone help me why it isn't not working. It is failing on the 6th test itself.http://codeforces.com/contest/809/submission/27281025
 » 4 years ago, # | ← Rev. 2 →   0 I am getting WA in Kickstart Round B 2017 PROBLEM A.while the similar code gets accepted here for problem C.can you help me please to find out what is wrong? my submission:(https://ideone.com/vdTEOv)