### Vovuh's blog

By Vovuh, history, 15 months ago, translation, ,

Hello!

Codeforces Round #494 (Div. 3) will start on July 3 (Tuesday) at 14:35 (UTC). You will be offered 6 problems with expected difficulties to compose an interesting competition for participants with ratings up to 1600. Probably, participants from the first division will not be at all interested by this problems. And for 1600-1899 the problems will be too easy. 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 problems and 2 hours to solve them.

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 Mikhail PikMike Piklyaev, Maksim Ne0n25 Mescheryakov and Ivan BledDest Androsov for help in round preparation and testing the round.

Good luck!

UPD: Editorial

UPD2:

Congratulations to the winners:

Rank Competitor Problems Solved Penalty
1 peanutpedo20 6 194
2 Sakurak 6 363
3 Mr.HP 6 404
4 CrownJJ 6 417
5 ProgrammingCanBeHard 5 153

Congratulations to the best hackers:

Rank Competitor Hack Count
1 Osama_Alkhodairy 32:-3
2 Marcel_Ib 26
3 SovietPower 23:-1
4 neelbhallabos 22:-2
5 Milkdrop 20:-3

419 successful hacks and 670 unsuccessful hacks were made in total!

And finally people who were the first to solve each problem:

Problem Competitor Penalty
A ProgrammingCanBeHard 0:00
B Rinne 0:08
C vjudge101 0:10
E peanutpedo20 0:39
F peanutpedo20 0:55

• +108

 » 15 months ago, # |   +10 Thanks for another div 3 contest!
 » 15 months ago, # | ← Rev. 2 →   -6 I am new here,please somebody give me some info/links on these rounds so that I can explore the site. thanks
•  » » 15 months ago, # ^ |   +4 Hi, you can go to the contest section.
•  » » » 15 months ago, # ^ |   0 Thanks i looked into it. Please clear what are systests.
•  » » » » 15 months ago, # ^ |   +3 System tests are the exhaustive test cases which are fed to your solution. They cover much more corner cases which are not usually shown in the sample test cases. One must design his/her solution keeping every possible corner cases in mind to pass the System testing phase.
•  » » 15 months ago, # ^ |   0 there rounds to solve problems and to your Score will be your rateex : If you didn't solve any problem your rate on website will be lower and vice versaAfter rounds There's Systests So Probably Solve Problem and Got Wrong Answer in Systest and There's in this Contest Hacking phase that You Can See Other Codes and if you found something wrong you can Hack him.You Can find previous Contests in contests Section
•  » » » 15 months ago, # ^ |   +3 yes thanks. i found the virtual contest mode very interesting. it's just live as you really attempting the original contest. loving codeforces.
 » 15 months ago, # |   0 very thanks for the Div 3 Contest!!!!!
 » 15 months ago, # |   +6 Every time you prepare a CodeForces Div3 round, I feel that you always copy paste this blog :| Anyway thanks for the round.
 » 15 months ago, # |   +8 Hope this time we get all questions of expected difficulty.Best of luck to all participants :)
•  » » 15 months ago, # ^ |   -43 Oh Asshole!
 » 15 months ago, # |   +56 How many of you agree that the phase of open hack must be reduced to 6 hours as most of the hacking happens in this time and also the penalties on wrong submission to +10 mins instead of +20 mins which I think for a 2 hr round is too much.
•  » » 15 months ago, # ^ |   0 Yeah that will be great! (p.s. 3 hours is enough)
•  » » 15 months ago, # ^ |   0 it should be just during the contest as i see div 2 rules
•  » » » 15 months ago, # ^ |   0 in regular Contests Hack is during ContestBut This contest with Eduacational round rule So There's hacking phase
•  » » » » 15 months ago, # ^ |   0 ok,my bad. people on other contest links on home page are quite active as compared here.
 » 15 months ago, # |   +2 I love div 3
•  » » 15 months ago, # ^ |   +2 what is so special in it,it should be taken as a challenge to move up.
•  » » 15 months ago, # ^ |   0 There is nothing special in it, IT has been started just to increase the speed on logical questions. But i think they should give more easy DS questions rather than logical questions to enhance DS skills.
 » 15 months ago, # |   +8 hope this contest has strong pretests... :)
•  » » 15 months ago, # ^ |   +17 Aren't you a guy who wrote about "a lot of hacking stuff" on previous contest and got a lot of downvotes? ;)
•  » » » 15 months ago, # ^ | ← Rev. 3 →   +9 yes...i realized that people don't want that....and so my hope changed..xd plus i wish my contribution is positive as it had become negative due to previous comment..also i don't like this type of hacking phase where the questions trip down after the contest..hacking phase should be through the running contest with points being awarded for corresponding hacks, so that people may come to know that there solution is incorrect and at least resubmit correct solution after hack.
 » 15 months ago, # |   0 Educational div. 3 Codeforces round. Gosh pretest's are going to be crucial.!!
 » 15 months ago, # |   0 To practice acm questions click here
•  » » 15 months ago, # ^ |   0 It is a matter of taste, yes, it is a large ACM archive, but there are a lot of other)
•  » » » 15 months ago, # ^ |   0 I just wanted to be resourceful for the community and there are many for whom the link might be useful for practicing for the future codeforces contests.Here the testcases are quite well!
•  » » » » 15 months ago, # ^ |   0 Depends on a problem: some problems were rejudjed because of bad initial testcases, but yes, it looks more like an exception, not a rule
 » 15 months ago, # |   -32 bbbbbbbbbboooooooooooooorrrrrrrrrrrrrriiiiiiiiiiiiiiiinnnnnnnnnnnnnngggggggggggggg
•  » » 15 months ago, # ^ |   -35 world cup is more interesting than last div3
•  » » 15 months ago, # ^ |   +1 Why you comments so Stupid!
•  » » » 15 months ago, # ^ |   +2 people should respect a person competing regularly and is so active from war trodden syria
 » 15 months ago, # |   +8 My rating of 1596 is quite embarrassing... Maybe I can be Expert after this round!
•  » » 15 months ago, # ^ |   -7 Nooo! You rating will be downgraded!
•  » » » 15 months ago, # ^ |   0 you too
•  » » 15 months ago, # ^ |   +5 avtahovfarit's rating point is even more embarrassing, so is the rating change.
•  » » » 15 months ago, # ^ |   0 sto yyf
 » 15 months ago, # |   0 Div. 3 contests are really awesome! But I think, if the difficulty level between 'C' and 'D' is made more balanced then the participants( specially the beginners ) would get more motivated :). Best of luck to all.
•  » » 15 months ago, # ^ |   -7 r U smart?
•  » » » 15 months ago, # ^ |   +5 r U smart?
• »
»
»
»
15 months ago, # ^ |
0

Is it you mind can understand thing !!!

# dontfollowme

»
15 months ago, # |
Rev. 3   -25

# Isitunrated?

•  » » 15 months ago, # ^ |   -6 R u retarded??
•  » » 15 months ago, # ^ |   +11 Yes unrated for unrated
•  » » » 15 months ago, # ^ | ← Rev. 2 →   +6 unrated for unrated but unrated is rated. fallacy
•  » » » » 15 months ago, # ^ |   0 What shit is you have write!
 » 15 months ago, # |   -38 I request Mike to increase Number of div3 contests coz number of div2+div3 guys are more than div1
•  » » 15 months ago, # ^ |   -20
•  » » » 15 months ago, # ^ |   0 I am excited to see div2 + div3 contest someday :)
•  » » » » 15 months ago, # ^ |   +3 the div3 was introduced for seperating div2 into 2 divisions. no need
•  » » » » 15 months ago, # ^ |   0 All Div2 contests are actually Div2+Div3
•  » » 15 months ago, # ^ | ← Rev. 2 →   0 It's Div.2
•  » » » 15 months ago, # ^ |   0 what is tba
•  » » » » 15 months ago, # ^ |   0 To Be Announced.
•  » » » 15 months ago, # ^ |   +1 its div 2
•  » » 15 months ago, # ^ |   0 No,Div.1 is very few,It's hard for red and orange coder to take part in the contests And Div.1 always appears with Div.2, the number of Div.2 is enough.
 » 15 months ago, # |   0 Guys can anyone tell me how to automatically generate tests ?, I read something about that long time ago but I can't find it right now.
•  » » 15 months ago, # ^ |   +5 If you want to generate random test cases of your own, use this website to do so
•  » » 15 months ago, # ^ | ← Rev. 6 →   0 Polygon has its own test generation system. Check (EDIT: for some reason, the link isn't working, so instead go to https://codeforces.com/testlib and on the right you'll see one of the blogs has a russion title; that's the one you're looking for.) to see how the generators work. Note: it's in russian, so you'll probably need to use google translate to understand it.
•  » » 15 months ago, # ^ |   0 Thank you guys
 » 15 months ago, # |   0 Thanks ♥
 » 15 months ago, # |   0 Hopefully, problem set will be an interesting and short description. Good luck with the high rating.
 » 15 months ago, # |   +1 Cant submit anything
•  » » 15 months ago, # ^ |   0 true
 » 15 months ago, # |   +2 Bad Gateway 502 again and again :( Such was not expected
 » 15 months ago, # |   +2 Hello, I have been getting 502 error and codeforces unavailable for 8 minutes now, and not sure when this is going to end. Can you please make this round unrated for me, i feel this time penalty is unfair to me.
 » 15 months ago, # |   +1 500 / 502
 » 15 months ago, # |   0 Fix the server lag & bad gateway issue
 » 15 months ago, # |   +1 WTH??? Contest page hasn't been working for past 3 minutes..Lost my ratings too :(
 » 15 months ago, # |   +15 Sorry for 502 on the first 10 minutes of the round. I think I investigated the reason. It is fixed now. I think it is because of filter for trusted participants. I've temporarily disabled it.
•  » » 15 months ago, # ^ |   -41 Site is not opening on my computer. I am unable to make submission for the last 45 minutes. The round should be made unrated. I wrote this from mobile phone site.
 » 15 months ago, # |   0 There is no score distribution?? :o
•  » » 15 months ago, # ^ |   +1 Div 3 is based on ACM ICPC RULES (Extended). So there is no score distribution. Each problem is of equal weightage with a time penalty according to submission time and no of wrong answers.
 » 15 months ago, # | ← Rev. 3 →   0 the predictor isn't working in Div3 contest again ![UPD] it is working now .
 » 15 months ago, # |   0 So, I lowered the rating, but the tasks were very good, especially D, thank u, Vovuh, for this contest!
•  » » 15 months ago, # ^ |   +12 In my opinion it was the best div3 contest)
 » 15 months ago, # |   +1 Can we submit multiple times?
 » 15 months ago, # |   +6 how to solve E ?
 » 15 months ago, # |   +9 Very interesting problems this time!
 » 15 months ago, # |   +8 Div 2 Round .. Solves A,B,C. Div 3 Round Solves only A and D.. What madness lol.
 » 15 months ago, # |   0 Nice problems, thank you!
 » 15 months ago, # |   +12 I suggest having an announcement right after updating some mistakes . In problem F , it shows(j1 > i1) at first , and I thought the number of words must be exactly bigger than 1 . However it changes and I haven't update my webpage , which leads lots of WA on test4 , and I don't have enough time finding the rest bugs .
•  » » 15 months ago, # ^ |   0 Another sad thing , my bug is using "srand" , can anyone explain why it may gets wrong by using srand and rand ? PS:I used time(NULL) as the seed
•  » » » 15 months ago, # ^ |   0 Same with j1>i1 :D Strange that they haven't made clarification.
•  » » » » 15 months ago, # ^ | ← Rev. 2 →   +17 I'm really sorry about it. I personally can not publish global announcements, they can be published by Mike or Ivan (BledDest), but they were very busy, and I just fixed this mistake and forgot to ask Ivan to publish this fix in the global announcement. I'm very sorry for my terrible mistake and I apologize to RDDCCD, ___tutis___ and the others who were affected by this bug.
 » 15 months ago, # |   0 Could any one help me by pointing out my mistake?code link-http://codeforces.com/contest/1003/submission/39925516
•  » » 15 months ago, # ^ |   +4 j<(i+3) Really?
•  » » » » 15 months ago, # ^ |   0 k can be between k <= i <= n, you only considering segments of size 'k' and 'n'
•  » » » » » 15 months ago, # ^ |   0 oh yeah right,thanks a lot :)
 » 15 months ago, # |   +14 Div3: a wolf in sheep's clothing.
 » 15 months ago, # |   +3 When will editorial get uploaded??
•  » » 15 months ago, # ^ |   +3 May be after hacking phase ends.
 » 15 months ago, # |   0 I'm unable to understand whats wrong in my submission on problem D .can anyone help me ? http://codeforces.com/contest/1003/submission/39928159
•  » » 15 months ago, # ^ |   0 Try lli (aka long long int) rather than li (aka long int, it is actually the same as int).
•  » » » 15 months ago, # ^ |   0 thanks! but can u tell what is causing this mistake ? as if I'm running in my pc system it gives correct answer but on codeforces system, it is giving dump value.
•  » » » » 15 months ago, # ^ | ← Rev. 4 →   0 it is cause of long long( just change (li ans=0) to (lli ans=0)
 » 15 months ago, # |   0 Can we use greedy approach in D??
•  » » 15 months ago, # ^ |   0 Yes Greedy will work.
•  » » 15 months ago, # ^ |   0 Yes. Greedy approach always works when the numbers in the sorted order are the multiples of numbers before them in the array.
 » 15 months ago, # | ← Rev. 2 →   +10 I think there was a problem on the problem C ! I tried an O(n²) in python but i got a time limit error while the same code in cpp passed the pretest... Could you make little changes please for that all the .py code passed the pretest such as the ccp code please ?
•  » » 15 months ago, # ^ |   +3 The same code is judged as correct in PyPy and judged as wrong in python 3.6 !I hope that my submission and the others like mines are going to be corrected...
•  » » » 15 months ago, # ^ |   0 I'm more curious as to why the latter submission took almost 13 times more time to execute
•  » » » » 15 months ago, # ^ |   0 I don't know. There is absolutely no differences between my 2 codes (39929248 and 39929354) so i can't explain the problem. I just can tell that i'm gonna loose rating while I should theorically increase my rating =(
•  » » » 15 months ago, # ^ |   0 first of all there is a difference between wrong and TLE. And pypy is an optimised intime python interpreter. so you should always submmit your sol. in pypy because it is fast. although there is a disadvantage to it, that it consumes a lot of memory, so only if you get MLE submit it in python. It is very rare to see python working faster than pypy
•  » » » » 15 months ago, # ^ |   +1 Now i won't continue to use python 3.6 as interpeter but i'm very dissapointed. I will loose rating (probably such many other persons) juste because i used python 3.6 s interpreter. I think that's not normal and I really hope that Codeforces Admin will make something to change that.
•  » » » » » 15 months ago, # ^ |   0 Dude python is not a recommended language for competitive. But yeah it is quite useful in some questions. By the way in this question python also passes, you should try optimizing your code
•  » » » » » » 15 months ago, # ^ |   +1 but where is the egality if the O(n²) passed in other language ?
•  » » » » » » » 15 months ago, # ^ |   0 Then use the other language. Language equality is an illusion. Join the cult of C++
•  » » » » » » » 15 months ago, # ^ | ← Rev. 2 →   +12 Some languages are faster than others. Also, some compilers/interpreters are faster than others. It's not the fault Codeforces and it's up to participants to know these things and to be able to judge which language/compiler/interpreter is approproate for which task.
•  » » 15 months ago, # ^ | ← Rev. 3 →   0 You may done this in O(n) time.code
•  » » » 15 months ago, # ^ |   +1 Can you tell a little more about the O(n) approach?
•  » » » » 15 months ago, # ^ | ← Rev. 3 →   0 Let us denote .And Let yi = S[i - 1], xi = i - 1 then what we want is to maximize the slope of lines that cross two points (i, S[i]), (Xj, Yj) This is an ordinary model, which we can simply maintain a convex hull, and a deque to solve the problem.
•  » » » » » 15 months ago, # ^ |   0 Doesn't maintaining a convex hull take O(n*log(n)) complexity? And hence the total complexity of the above would be O(n*log(n)). Please correct me if I am wrong CelesteLight.
•  » » » » » » 15 months ago, # ^ |   +6 The decision is monotonous.(my English is poor)Because we know that Xi, Yi are both increasing. And we can prove that if then So we can pop the last point of convex hull if the next one is better. And it is $O(n)$
•  » » » » » 15 months ago, # ^ |   +3 Ohk, that was good.Can you give pseudo code or the AC submission of this algorithm and similar to this
•  » » » » » » 15 months ago, # ^ |   0 http://codeforces.com/contest/1003/submission/39957991Here is the code.
•  » » » » » 15 months ago, # ^ | ← Rev. 2 →   0 CelesteLight I am trying to understand your solution without looking at your code implementation. Sorry I am not very good at Math, especially the Math term in English, can you help me understand the following:1) what do mean by "ordinary model"? Do you mean degree 1 polynomial?2) I understand your explanation up to the point of finding the slope of (i, S[i]), (Xj, Yj). So, the naive solution is to find the slope of every pair (i, j) , which will take O(n2) . How does convex hull algorithm helps reducing it to 0(n)? a) To clarify my confusion, when we build the convex, we will go from point to point: (i, Si), (i + 1, Si + 1). How will that reflect on (i, Si), (i + k, Si + k) which is the range that we are interested in?
•  » » » » » » 15 months ago, # ^ |   +3 My English is far too poor to explain it further. If you want to know more, searching in the Internet for "slope optimize DP" might help.
 » 15 months ago, # | ← Rev. 4 →   +1 Website issue cost me rating
•  » » 15 months ago, # ^ |   +6 After submitting A, I had to wait around 8-10 minutes to read the problem statement of B.
•  » » » 15 months ago, # ^ |   0 same here bro!
•  » » 15 months ago, # ^ |   +3 This happened to everyone, and I think now noting can be done.And further questions B,C,D were also good. 10 minutes does not matter in that if you solved B,C,D also.
•  » » » 15 months ago, # ^ |   0 Yes but there will be a gap between people who submitted A right before the server issues and right after, while in a normal contest its a few second/1 minute off but in this contest is can be over 10 minutes apart.
 » 15 months ago, # |   0 I'am solve first problem in 1 minute, But the site did not work so I was very late in sending it, It is unfair that unofficially registrars can act on the site's lack of responsiveness while official registrants lose points because of it.
•  » » 15 months ago, # ^ |   0 All Had The Same Problem....And There's Ranking for official registrants only
 » 15 months ago, # |   0 Can someone tell me when CF-Predictor will update the rating for this contest.I am so excited so Its hard for me to wait 12 hours to see my new rating. :p CF-Predictor: https://cf-predictor-frontend.herokuapp.com/contestSelector.jsp
•  » » 15 months ago, # ^ |   0 use NBHEXT https://codeforces.com/blog/entry/21302
•  » » 15 months ago, # ^ |   +2 you can try chrome extension of cf-predictor, it is working!
 » 15 months ago, # |   +42 Are current #2 and #3 cheating?http://codeforces.com/contest/1003/submission/39911751http://codeforces.com/contest/1003/submission/39926904Their solutions for F, other than the template and variable names, look identical.
•  » » 15 months ago, # ^ |   -19 this often happens, nothing can be done about it.
•  » » 15 months ago, # ^ |   +37 http://codeforces.com/contest/1003/submission/39925428 also looks suspiciously similar to the 2 submissions above.
•  » » 15 months ago, # ^ |   +36 Their solutions to E are also similar (and both got hacked :) ):http://codeforces.com/contest/1003/submission/39924725http://codeforces.com/contest/1003/submission/39919595
•  » » » 15 months ago, # ^ |   0 And some guys use other’s resolution to skipped themselves to make themselves unrated.So their rating are increase.
 » 15 months ago, # |   0 For Problem C , the answer shouldn't vary by more than 1e-6. I see that some solutions are printing solution till 6th place precision, something like %.6f. This could lead to rounding off at 6th digit after decimal at times, depending upon test cases.Does anyone have a test case to break this? I tried generating tests, but have no success uptil now :(
•  » » 15 months ago, # ^ |   0 U tried generating test cases by taking help of any tool? OR on your own. If u used tool can u plz share
•  » » » 15 months ago, # ^ |   0 No, I just wrote a program to generate tests for the problem.
•  » » 15 months ago, # ^ |   +9 I think printing %.6f would be fine and can not be hacked.
•  » » » 15 months ago, # ^ |   0 See this, for example. If your answer was 1.3333337, it would print 1.333334 as answer, which has difference of 1e-6.
•  » » » » 15 months ago, # ^ |   0 No it actually has difference 1.3333337 — 1.333334 = 0.0000003(3e-7) which is smaller than 1e-6
•  » » » » » 15 months ago, # ^ |   0 The difference would be between actual answer (1.333333) and our rounded off answer (1.333334), ie 0.000001
•  » » » » » » 15 months ago, # ^ |   +1 by statement of problem C,... is the answer given by the jury's solution.and the jury's solution is printing more than 6 decimal points.
•  » » » » » » » 15 months ago, # ^ |   0 Damn, didn't realize this. Thanks for correcting :)
•  » » » » » » » » 15 months ago, # ^ |   +4 My pleasure. Actually I thought just like you at first :)
•  » » 15 months ago, # ^ |   0 if u .6%,The answer will be rounded.So it is wrong
 » 15 months ago, # |   0 can anyone plz explain problem B to me its not clearThanks
•  » » 15 months ago, # ^ |   0 It is really clear.A string S consists of 0 and 1.Number of 0 is a,number of.1 is b.U need to find a S content the situations
•  » » 15 months ago, # ^ |   0 add sth. there are x index that s[i]！=s[i+1]
 » 15 months ago, # |   0 Will the points deduct in case of unsuccessful hacking attempt in this round?
•  » » 15 months ago, # ^ |   0 No. Hacking after the contest is over does not change the hacker's rating.
•  » » 15 months ago, # ^ |   0 No
 » 15 months ago, # |   0 Fix a bug in the last 30 seconds, so close :p
 » 15 months ago, # |   +4 What is the main idea of the problem E? I solved A, B, C, D, F and thought for a long time about E
•  » » 15 months ago, # ^ |   +9 Create a chain with d+1 nodes that has length d. Just repeatedly add new nodes, making sure that each node still has degree <= k and the diameter doesn't increase.
•  » » » 15 months ago, # ^ |   0 peanutpedo wow ._. you on #1
•  » » » 15 months ago, # ^ |   +2 Thanks, now I solved everything. Code for E
•  » » » » 15 months ago, # ^ |   0 Thanks buddy, ur code made me realise my mistake
•  » » » 15 months ago, # ^ |   0 I did exactly same, but still, I'm getting WA on 8, I'm unable to get my mistake, help needed http://codeforces.com/contest/1003/submission/39926411
•  » » 15 months ago, # ^ |   +6 I solved E using BFS. Here my approach: First let our base tree is the chain tree which length is equal to d (If d >= n -> answer is No) Second let try to put more vertices into that base tree, we can observe that we can actually put some 'forest' into these vertices and the maximum height of each vertices is calculatable Let H[u] is the maximum height if we add 1 forest into vertex u, then H[u] should look like this 0,1,2,3,.. d/2,d/2-1,... 0 . Thirdly we know that each vertices has its maximum degree k, then we just greedily add forests into these nodes until >= k
 » 15 months ago, # | ← Rev. 2 →   0 nice contest .. problem E is similar to this problem
•  » » 15 months ago, # ^ |   0 E had an extra constraint of maximum degree for any vertex. I believe this constraint is (more than) enough to differentiate between the two questions.
•  » » » 15 months ago, # ^ |   0 that's right .. I was pointing to the general idea which is building a tree with some given diameter
 » 15 months ago, # |   0 For D, Can someone sketch a proof for why greedy works. First, how can we be sure that greedily removing values would not make it possible to get the sum. How does a local optimum of removing the next maximum power of 2 as much as possible result in a global optimum.
•  » » 15 months ago, # ^ |   0 This might be a useful hint. Think about the binary representation of numbers
•  » » » 15 months ago, # ^ |   +1 Yeah that was my first idea. Since the numbers are powers of 2 , they would have only a single bit set in their binary representation. But that didn't get me anywhere substantial.
•  » » » » 15 months ago, # ^ |   0 I meant the binary representation in the queried numbers, this should help you with the first part of your question. For the second part does the fact that 2^i= 2^(i-1)+2^(i-1) help you get further?
•  » » » » 15 months ago, # ^ |   0 Converting decimal to binary is greedy (take the biggest you can until number becomes 0)Which means that if you use powers of two (numbers you consider taking when forming a binary number) you can use the same greedy process.Also, you can think of it as coin problem where each number is the divisor of the next, if you have 2i and i coins you would always take a 2i-coin instead of 2 i-coins. Apply that logic recursively until you hit 1. Only issue with this is that there is a limitation on amount of coins you can use, not sure if this affects it
•  » » » » » 15 months ago, # ^ |   0 Exactly, without the limitation on the number of coins we can show that it's optimal. But what about this case.
•  » » » » » » 15 months ago, # ^ | ← Rev. 4 →   0 Let's assume our greedy works given no limitations, which it does. Also note that the greedy solution is the only optimal solution, any other arrangement is worse.Now we can think of a case with limitations.During our greedy process, we hit a scenario where we need the coin with value 2^a but we don't have the coin.Now assuming the greedy method is optimal, it is also optimal to use the greedy algorithm to find the solution to 2^a given coin values 2^(a-1) and below (to replace the coin).This is what our general greedy algorithm does, except we process the whole thing in one go instead of running a separate greedy every time we don't have a coin 2^a. When we are lacking 2^a we greedily replace it with lower value coins, which we already know is optimal.
•  » » 15 months ago, # ^ | ← Rev. 3 →   +1 Let there be two coins, X and Y, such that Y = (2^k) * x. (k >= 1)If you want to get an amount Z of money given in those coins, it is always optimal to take as many Y coins as you can, before you take any of value X. That is the best you can do, because let's suppose you used only X coins instead of using X and Y. Then, it is clear that you needed at least (2^k) times more coins to make up for the value you could have made using Y, but chose to use only X. So, if you want to have as minimum coins as possible, you need to start from the higher-valued coins, no matter how many of them you have in comparison to the lower-valued ones.And if you can't form the sum using a X coin, you wouldn't be able to do it with Y either, because using Y means using (2^k) * X. The opposite is also true, only difference is the amount of coins you would need to use to make the sum.
 » 15 months ago, # |   +8 why not, round extended for 10 min
 » 15 months ago, # |   +1 Any tough/tricky cases for E?
 » 15 months ago, # |   0 What's wrong with this solution for F? 39922956
•  » » 15 months ago, # ^ | ← Rev. 2 →   +3 You got the problem wrong. problem says atleast 2 such segments.
•  » » » 15 months ago, # ^ |   0 Oh ok, thanks
 » 15 months ago, # | ← Rev. 2 →   +48 My first ever hacking attempt against srand(time(0));!The way I did it: 1) printed time(0) at a certain time 2) Seeing as time(0) was 1530644xxx, I decided to make a code which finds a counter-case for every time(0) between 1530644950 and 1530644969 and puts them all into 1 test case. Code: https://ideone.com/SQ2AAb 3) I went to their submission, selected the hacking window and selected the test case in the form of a text file. 4) I refreshed Custom Invocation code for time(0) until it became >=1530644950.(took about a minute of waiting) 5) Once it was >=1530644950(1530644953 at the time of invocation), I pressed the hack button. 6) Profit!
•  » » 15 months ago, # ^ |   0 Can u hack again, he submitted in practice mode, by changing some values? xD
•  » » » 15 months ago, # ^ |   +20 Done!
•  » » 15 months ago, # ^ | ← Rev. 3 →   0 Hack me! 39934835
•  » » 15 months ago, # ^ | ← Rev. 2 →   0 My solution uses random generation of mod > 1e9 and base for hashing, I think it's not hack, it's true?
•  » » » 15 months ago, # ^ |   0 I probably couldn't hack it because finding a collision among 1027 possible combinations is extremely unlikely. On Akul's code, there were only 109 possible combinations, so I could find a collision pretty quickly.
•  » » » » 15 months ago, # ^ |   0 Thanks for your reply. What can you recommend in problems with polynomial hashes? Will this solution be safe in other problems?
•  » » 15 months ago, # ^ |   0 We can use std::chrono::high_resolution_clock::now() which tick faster than std::time()
 » 15 months ago, # |   0 F can be solved in O(map * n^2) using hashes. For every length of iterate through interval of this length in increasing order, then using map + hashes store how many intervals you can match, and there is the rightmost one. 39934835
•  » » 15 months ago, # ^ |   0 But you must randomize the hash value otherwise your code will be hacked like mine.
 » 15 months ago, # |   0 What can be causing the RTE in this codeIm losing my mind :D
•  » » 15 months ago, # ^ | ← Rev. 2 →   -8 I think it's a stack over flow because of too many recursions try this test case:5 1 1 2 4 8 16 10000answer is -1 your code is giving RTE
•  » » » 15 months ago, # ^ |   0 Thank you :D
•  » » 15 months ago, # ^ |   0 Stack is getting overflowed by repeated calls here long long add=go(pos); Try on this :- 1 1 1 2
•  » » » 15 months ago, # ^ | ← Rev. 2 →   0 Yes the issue is caused when i call the function giving it a parametre number with only 1 set bit which make an infinite recursive calls .
 » 15 months ago, # | ← Rev. 2 →   0 Is there any way to implement hash so that I won't be hacked?
 » 15 months ago, # |   0 Hello, I'm new here and I want to know if there is any article describing the whole process of a complete round. Could anyone help me?
•  » » 15 months ago, # ^ |   0 Yes editorial will come out probably by tommorow.
 » 15 months ago, # |   0 Can someone give a nice approach for div2 B problem other than spamming if-else statements? Either way do explain the solution you all submitted, it'll surely help me. The way I thought the solution was as follows: for x such characters in the final string we need (x+1) groups of consecutive 1's and 0's with any number of 1's and 0's in them( obviously there should be more than 1 in each group). But I found the solution difficult to implement. Can someone help me with it?
•  » » 15 months ago, # ^ |   0 I also found awkward to implement.So you need x+1 groups of consecutive 1's and 0's.The way to do that using minimal amount of digits is just10101010... or 01010101...Depending on the constraints one of might fail, but one of them HAS to work.Not this solution already fits the x constraint, now you need to match it to a and b.Actually there's an easy way. Insert a bunch of one's next to a prexisting one and zeros next to a preexisting zero.Like this:1010101 ---> 11111010101notice how this doesn't affect the amount of switches now we do the same with zerosatleast one of our solution will work, we just have to test which one39905965
•  » » » 15 months ago, # ^ |   0 Note:f() creates 10101010 g() creates 01010101count(v) counts the amount of "01" and "10" in v (should be x)fits(v) checks if v used less than a and b zeros and ones
•  » » 15 months ago, # ^ | ← Rev. 2 →   0 First, we implement a sequence which is always flipping like "01010...". Specifically, we set the initial sequence to be "01" if A >= B, or "10" otherwise.Then, we put the rest of the 0s and 1s into any of the position of 0 or 1, which does not change the flipping number. You can see this implementation 39904229 for details.
 » 15 months ago, # |   0 I have tried an approach to problem F involving string hashing mod 1e9+7 and then picking intervals to shorten greedily (interval scheduling) but it fails on test case 54.Now, I changed the modulus to 1824261409 for the hash and it still fails, I think there might be some case I am missing out on, as answer is off by only two. I'm guessing it might have something to do with whitespace, but codeforce does not let me look at the full case. Can anybody pinpoint what's causing the anomaly?39940552
•  » » 15 months ago, # ^ | ← Rev. 2 →   +3 just use a map and change everything to intsAlternatively you can use double hash or even triple hash, but that is probably too much time to code and too error-prone.
•  » » 15 months ago, # ^ | ← Rev. 2 →   0 That test case is actually one I used to hack, it's 299 'a's and one string with 99000 'a's.(that test case was originally designed to possible TLE something, but i saw a solution give a negative answer on it and hacked it with that). If you want a smaller test case, then try this:3aa aa aYour answer: 4Expected answer: 5Your solution treats 'a's as 0s, meaning that it recognizes "aa aa", "aa", "a", "aa a" and "aa aa a" as 0. To fix that, you need to treat 'a's as at least one, meaning you need to add one to your base and the letter. 39946086
•  » » » 15 months ago, # ^ |   0 Thank you, it is very helpful.
•  » » » 15 months ago, # ^ | ← Rev. 2 →   0 Getting the same answer for the 54th test case , any advice for me :Dhttp://codeforces.com/contest/1003/submission/39954969
•  » » » » 15 months ago, # ^ |   0 Resolved :D Thanks for the test case description
 » 15 months ago, # |   0 I would like to know after how much days editorial of div1 div2 or div3 are available
 » 15 months ago, # |   +1 i am a beginner just wanted to ask when will the final results be out for this contest??
•  » » 15 months ago, # ^ |   0 Maybe within an hour.
 » 15 months ago, # |   0 I don't understand why two same solution one in Python and another in Java give different verdicts.The one in Java passes while the Python one gives TLE
•  » » 15 months ago, # ^ |   +1 Simple: because not all programming languages are equally fast.P.S. if you're using python, try submitting with PyPy interpreter. It's optimized for speed.
•  » » » 15 months ago, # ^ |   0 wow man thanks, I am gonna read more about PyPy
 » 15 months ago, # |   0 Your crafting.oj.uz ratings are updated!
 » 15 months ago, # | ← Rev. 4 →   0 I think that we shouldn't have been able to hack F, because there is the hash solution for which there always theoretically exists a countertest. I might be a little biased here, because it happened with my solution: 39926278, but it also happened to more than half of the solutions of F.
•  » » 15 months ago, # ^ |   0 That's why sometimes srand((long long)new char) is needed. xD
•  » » » 15 months ago, # ^ | ← Rev. 2 →   0 Forgot about it. Thanks for reminding me. Still not an elegant solution though...
 » 15 months ago, # |   +3 Where's editorial ?
 » 15 months ago, # |   +2 Can someone explain how to solve F? Or just give some hints?
 » 15 months ago, # |   +3 hey for E, my 39924761 hacked, but i show the hacking test, that was 5 4 1, http://codeforces.com/contest/1003/hacks/465215/test, my answer is "NO", it is correct answer i think, why my solution was hacked? sorry my poor english. Vovuh
•  » » 15 months ago, # ^ |   +8 it depends on exit(1), exit code 1 means runtime error on codeforces, I regret what I dont know about it. I changed my code exit(0) get AC
 » 15 months ago, # |   +5 Same codes with just reformatting again from moamen_ahmed and BaSSam_RaMaDaN.
 » 15 months ago, # |   +1 is there going to be an editorial for this round?
 » 15 months ago, # | ← Rev. 2 →   +1 Why so much people used hashing solutions on F when a simple string matching algorithm like KMP works just fine?
•  » » 15 months ago, # ^ |   0 It's easy to code . At least for me it's easier .
•  » » » 15 months ago, # ^ |   0 But it's not very reliable. I have bad luck when choosing the big prime numbers for hashing, and I say "luck" because I don't quite understand how to choose them, I just pick the most famous ones around, and yet most of them have complex counter-cases!
•  » » » » 15 months ago, # ^ |   0 Well I am afraid of being hacked . So I choose the prime randomly . And I got wa . I got ac after I use a certain one . I don't know why srand and rand affect so much . :(
•  » » 15 months ago, # ^ |   +29 Why so much people used hashing or KMP solutions on F when http://codeforces.com/contest/1003/submission/39912717 works just fine?
•  » » » 15 months ago, # ^ |   0 I think that's a better question
 » 15 months ago, # |   0 In the graph of problem E how do I calculate the maximum number of edges?
•  » » 15 months ago, # ^ |   +1 What do you mean? Since the output is a tree with n nodes, it's always going to have n - 1 edges — no more, no less. Did you mean something else?I guess, to answer your question, the maximum number of edges is always going to be n - 1.
•  » » » 15 months ago, # ^ |   0 Oh yea I just got confused ty
 » 15 months ago, # | ← Rev. 3 →   -29 self-delete
•  » » 15 months ago, # ^ |   +26 Hey at least DQ these guys first http://codeforces.com/blog/entry/60377?#comment-442301 from official standings before DQing me
•  » » 15 months ago, # ^ | ← Rev. 2 →   -29 self-delete
 » 15 months ago, # |   0 Problem 3 Intense Heat... The same O(n^2) solution I implemented runs in PyPy3 but I got a TLE in contest on Test Case 13 for Python. Not fair!