### Akikaze's blog

By Akikaze, history, 4 months ago, ,

TREMBLE BEFORE THE MIGHTY OMEGALULGRAPE

Hello Codeforces!

We are honored to invite you to Codeforces Round #538 (Div. 2), which will take place at 10.02.2019 17:05 (Московское время). The round will be rated for all Division 2 participants (with rating less than 2100). Still, we warmly welcome Division 1 participants to join us out of competition.

You will be given 6 problems to solve in 2 hours. The round's problems were initially prepared by Duy-Bach Akikaze Le, Xuan-Tung neko_nyaa Nguyen and Xuan-Quang xuanquang1999 D. Nguyen.

This is our first attempt in making a Codeforces round, so suggestions are much welcome to help us improve ourselves. ;)

We also want to thanks many friends for making this round possible:

• Dmitry _kun_ Sayutin for coordinating the round, providing a neat idea on one problem and some Russian translations.
• Andrew GreenGrape Rayskiy for various suggestions on the problems, some other Russian translations, and most importantly, peacefully submitted himself to be quarantined from pretests. ;)
• Michal majk Svagerka for testing the round.
• And last but not least, Mike MikeMirzayanov Mirzayanov for the amazing Codeforces and Polygon platform, without which this round would never be possible :D

P/s: I will be at the Discord CP Community to discuss the problems after the coding phase. However, please follow the rules and don't discuss the problems during the contest by any means.

Wish everyone good luck and high rating!

UPD1: Score distribution: 500-1250-1500-2000-2000-2750

UPD3: The contest is finished. I apologized for the "somewhat" weak pretests at here and there. Anyway, time to celebrate our winners ;)

Official participants:

Div.1 + Div.2 participants:

• +573

 » 4 months ago, # |   +37 Congrats on your first round!
 » 4 months ago, # |   -26 i don’t understand any of this can someone explain
•  » » 4 months ago, # ^ |   +28 OMEGALULGRAPE
•  » » » 4 months ago, # ^ | ← Rev. 2 →   +21 ALL HAIL THE MIGHTY OMEGALULGRAPE
•  » » » » 4 months ago, # ^ |   -24 i am confused and you come here to make fun of me and confuse me even more? classic slav attitude...
 » 4 months ago, # |   +32 GreenGrape everywhere...
 » 4 months ago, # |   0 Good Luck to All!
 » 4 months ago, # |   +83 GreenGrape in two consecutive rounds, you must be joking
 » 4 months ago, # | ← Rev. 2 →   -129 writing an announcement five days before a round -> bad round
•  » » 4 months ago, # ^ |   +30 At least it showed my bad patience :D
•  » » » 4 months ago, # ^ |   -89 bad patience -> bad round
•  » » 4 months ago, # ^ |   0 Is That Angel/Angle Said u to write so?? :thinking: sorry_marymarine
•  » » » 4 months ago, # ^ |   -27 no, angel said to write a comment about dead boi
•  » » 4 months ago, # ^ |   +5 I think it's vice versa and it means that this round is important for him and he worked on it well.
•  » » » 4 months ago, # ^ |   -33 important != worked well
•  » » » » 4 months ago, # ^ | ← Rev. 2 →   0 Furthermore, important != bad work
 » 4 months ago, # |   +5 Kuroyukihime round? awesome!
•  » » 4 months ago, # ^ |   +8 So far the round is not anime-themed...... yet Lotus will not disappoint ya ;)
•  » » » 4 months ago, # ^ |   +11 that's fantastic! i can not waiting anymore!
 » 4 months ago, # |   -20 Vietnamese, raise your hand!!!!!
•  » » 4 months ago, # ^ |   +3 You speak the language of the trees?
•  » » » 4 months ago, # ^ |   +2 No, the trees speak his language.
 » 4 months ago, # |   +13 Good luck for your first round! I'm feeling some math here
 » 4 months ago, # |   -9 first congrats on your first round second why interactive?
 » 4 months ago, # |   0 I dont know if I can ask this, but which is the interactive problem? C, D, E or F ???
•  » » 4 months ago, # ^ |   +93 All you need to know is there will be an binary search problem.
•  » » » 4 months ago, # ^ |   +33 Or a magic random problem
•  » » » » 4 months ago, # ^ |   +23 With binary search.
•  » » » » » 4 months ago, # ^ |   +41 On bits.
•  » » » » » » 4 months ago, # ^ |   -35 or HLD + FFT.
•  » » » » » 4 months ago, # ^ | ← Rev. 2 →   +18 your wish was granted
•  » » » » 4 months ago, # ^ |   +13 Why did you wish for this bro :D
•  » » » » » 4 months ago, # ^ |   +13 I knew you bro xD
 » 4 months ago, # |   +4 Did anybody notice that there are less comments than shown in the blog.
•  » » 4 months ago, # ^ |   +15 Some spams were hidden by the administrators.
 » 4 months ago, # |   +23 Dont worry guys Not every grape is Greengrape
•  » » 4 months ago, # ^ |   +21 Purple grapes taste better.
•  » » » 4 months ago, # ^ |   +6 How about black grapes? :D
•  » » » » 4 months ago, # ^ |   +8 never knew they exist D:
 » 4 months ago, # |   -28 romania!!! unite for this contest !!!
•  » » 4 months ago, # ^ |   -25 romani unitiva!!! acum ori niciodată!
 » 4 months ago, # | ← Rev. 2 →   +20 I hope the difficult gap between problems can be proper.More personally,I hope there will be a problem(maybe problem D) whose difficulty is between 1700 and 1900.In recent contests,the gap between C and D is always wide(such as 1500 and 2200),which is ,to be honest, unfriendly to me(rating between 1800 and 1900).In many contests,I pass the first three problems in 30 mins and cannot solve problem D in remaining time.
•  » » 4 months ago, # ^ |   0 Try problem E
•  » » » 4 months ago, # ^ |   0 Personally,this contest's problem E is easier than D for me.But I focus on D and fail,so I miss a chance to become purple.
 » 4 months ago, # |   0 Interactive problem，I'm not good at it,sad... Hope it won't be too difficult.
 » 4 months ago, # |   0 Hoping to finally be blue.
 » 4 months ago, # |   0 They didn't complete surgery on GreenGrape
 » 4 months ago, # |   +17 Just a random fact, GreenGrape has never been GreenGrape .
•  » » 4 months ago, # ^ |   +13 He was! New year's magic :)
 » 4 months ago, # |   +52 Why are there more and more Div2 rounds consisting of 6 problems nowadays? I think that this leads to more implementation and to less thinking. I think it's better when there is one interesting Div2E problem than 2 pure implementation Div2E and Div2F problems.
 » 4 months ago, # |   -7 i will get grandmaster this round
•  » » 4 months ago, # ^ |   +10 good luck!I believe in you!
 » 4 months ago, # |   -6 I wished that there will be 6 nice problems and make me get some new skills in this contest. Thanks to the selfless dedication of the problem provivers.
•  » » 4 months ago, # ^ |   0 what are you talking about i dont understand
•  » » » 4 months ago, # ^ |   +5 tf you say to me you little
•  » » » » 4 months ago, # ^ |   0 stop harassing people, you might get muted.
 » 4 months ago, # |   +3 Auto comment: topic has been updated by Akikaze (previous revision, new revision, compare).
 » 4 months ago, # |   0 Good Luck to All!
 » 4 months ago, # |   0 What will be the pattern of the points of every problem?
•  » » 4 months ago, # ^ |   0 A 500 B 1250 C 1500 D 2000 E 2000 F 2750
 » 4 months ago, # |   +9 what is pretest 10 for problem C?
•  » » 4 months ago, # ^ |   +4 I think it breaks some overflow checkers, namely the ones that test if your new product is less than your old product. You can have overflow and still have the new product be greater than your old ones, and in this case I believe it is because they had some prime that was greater than 4e9 that was getting squared.
•  » » » 4 months ago, # ^ |   0 "You can have overflow and still have the new product be greater than your old ones", how to handle this ?
•  » » » » 4 months ago, # ^ |   0 You could use long doubles for checking overflows or, possibly less stupidly, GCC's __builtin_mul_overflow
•  » » » » 4 months ago, # ^ |   +2 Or instead of n >= p * p0 check n / p >= p0.
•  » » » » » 4 months ago, # ^ |   0 Thanks! It worked
 » 4 months ago, # |   +5 Pretest 12 E?
•  » » 4 months ago, # ^ | ← Rev. 2 →   +5 RAND_MAX is 32767, u should extend it.
•  » » » 4 months ago, # ^ |   0 Oh my god...
•  » » » 4 months ago, # ^ |   -42 So basically random_shuffle would not shuffle properly for N ≤ 106?If this is the case then it is really bad problem setting because this is not something of common knowledge and many people would have encountered this error even though the had the solution.
•  » » » » 4 months ago, # ^ | ← Rev. 2 →   0 Yes, but I think we can use some tricks to make it work in N<=1e6 even though it is not actually uniform distribution.
•  » » » » 4 months ago, # ^ | ← Rev. 2 →   +91 "The problem is bad if it requires some knowledge that I don't have" doesn't sound like a reasonable approach to me. The fact that random_shuffle() isn't very random by default is important thing to know, and your comment sounds like "It is bad to expect us to know that cout<
•  » » » » » 4 months ago, # ^ |   -13 It seems many people had the same issue so it isn't really common knowledge that inbuilt randomisation in C++ does not work properly for sizes greater than 32767.I do not mean to disrespect the problem setters, but it does seem like this specific piece of knowledge is not known to many. Otherwise I would not have said anything like that. Although I do understand that if I am coding in C++ I should know it well enough to be able to code all kinds of solutions.
•  » » » » » » 4 months ago, # ^ |   +23 I still think that your reasoning makes little sense. The fact that a lot of contestants don't know (or don't think about) something doesn't imply anything. I would agree if that was something very compiler-specific or CF-specific, like exploiting particular compiler bug that behaves clearly against the standard of C++ and has been introduced in particular version of compiler. I also didn't manage to get this problem initially, and it took me long time to figure out my mistake — but that's my fault, and not setter's.Rabin-Vazirani algorithm isn't known to majority of CF users either, should we criticize any setter for deciding to use it for their problem? :)Moreover, setters are so nice here that they even included this test in pretests. Can you imagine the mess we'd have otherwise? :)
•  » » » » » » » 4 months ago, # ^ |   -19 Well I do agree to that. After all, someday someone had to make such a problem which would have highlighted this issue despite the fact that this has been posted in a blog earlier (because many people don't read blogs or simply don't happen to come across them). I guess this was inevitable.Again, I don't mean to say this was setters' fault. All I wanted to say was that maybe the problem could have been set in a way that this issue would not have occurred (maybe setting N ≤ 104). But then this is also true for many other situations, like the need for fast IO (though I am not the setter so I don't have a say in this :P). In no way I mean to disrespect the setters, and I truly believe all setters do a great job at bringing us new problems to solve.
•  » » » » » » » 4 months ago, # ^ |   0 In what sense is including this test different from including a test for the random generator of an arbitrary language? I could see which are the first 60 numbers the program would ask for and make sure they are not coprime positions. Also using any solution (assuming it does not seed on time) I can break it. I don't think this test adds to the quality of the problem and it is specifically targeted towards one of the allowed languages. Is there a test with the first 30 numbers the random of java would generate? Would you consider such a test fair?
•  » » » » » » » » 4 months ago, # ^ |   +8 Yes, I would consider it totally fair.Moreover, your analogy sounds wrong to me. You don't need to know much about generator here — the solution is going to fail no matter what seed is used in generator.You are complaining that the solution doesn't work because constraints are too large. That's like saying "my solution with int didn't pass only because in your problem n<=1e18".
•  » » » » » » » » » 4 months ago, # ^ |   -18 I don't agree. It is like having the codeforces server using integers fit up to 2^15 and my solution failing because I had used int. On my machine and ideone rand() is not limited to 32k: https://ideone.com/r91m04 And c++ standard does not guarantee the size of int to fit 2^31: https://stackoverflow.com/a/589684/812912
 » 4 months ago, # |   +5 What is the 12th pretest on E? I kept getting wrong answer on this one
•  » » 4 months ago, # ^ |   +11 Probably a test exploiting https://codeforces.com/blog/entry/61587.
•  » » 4 months ago, # ^ |   0 I did this too,so I changed random_shuffle into my_rand.
 » 4 months ago, # |   +11 what is the pretest #6 in D? ..
 » 4 months ago, # |   +5 Can someone please explain how to solve D?
 » 4 months ago, # |   0 Does interval DP not work for problem D?
•  » » 4 months ago, # ^ |   0 It does, my solution is df[from][to]
•  » » » 4 months ago, # ^ |   +1 Interesting. I kept getting WA on pretest 6. What was your idea?
•  » » » » 4 months ago, # ^ |   -8 If the first and the last letter of the interval do not much you either will convert the longest prefix matching the first letter or the longest suffix matching the last letter. If the two letters match you will change both the longest suffix and the longest prefix on the last move.
•  » » » » » 4 months ago, # ^ |   0 So it seems that you're doing the DP by decreasing the size of the DP interval?
•  » » » » » » 4 months ago, # ^ |   0 Yeap
•  » » » » » » » 4 months ago, # ^ |   +10 I did my DP with increasing size of the DP interval (I suppose that should work?). I couldn't seem to come up with a counter case though.
•  » » » » » » » » 4 months ago, # ^ |   0 It should at least pass the pretests I did something similar to your solution. Did you take every possible starting position?
•  » » » » » » » » » 4 months ago, # ^ | ← Rev. 3 →   0 My program should have accounted for every possible starting position. I guess the code speaks better for itself. 49731308I think my transitions may be wrong but I'm not sure how.
•  » » » » » » » » 4 months ago, # ^ |   0 I did it with increasing interval. you can have a look at my code- here
•  » » » » » » » » » 4 months ago, # ^ |   0 Thanks
•  » » » » » 4 months ago, # ^ |   0 I'm probably misunderstanding you, but I don't think what you said is true. If your array is 1 2 2 3, you can change this minimally to 2 2 2 2, which doesn't match the first or last letter.
•  » » » » » » 4 months ago, # ^ |   0 Hmm no you can not. You have to change it first to 2 2 2 3 and then to 2 2 2 2
•  » » » » » » » 4 months ago, # ^ |   0 Ok, I misunderstood what you meant. I thought you meant that the prefix/suffix was going to match the exact color of the endpoints.In any case, I see where my understanding of the problem was flawed.
•  » » » 4 months ago, # ^ |   0 What are the recursive calls? I imagine it's the classic (l+1, r) and (l, r-1), but sometimes you'll have to add 1 to your result, namely if it's not possible to get (l+1, r) to be the color of c[l] or (l, r-1) to be the color of c[r], but I couldn't find a good way to find when that's possible or not.
•  » » » » 4 months ago, # ^ |   0 That is the typical way I implement DP — recursion with memoization
 » 4 months ago, # |   0 What to do in E after finding Xn? I asked for 30 random values and tried to find d based on these, but it doesn't have to be correct
•  » » 4 months ago, # ^ |   0 i do the same and pass the pretests
•  » » » 4 months ago, # ^ |   0 So I may have failed just because I forgot to delete the line where I was checking something...
•  » » » » 4 months ago, # ^ |   0 how u calculate d ? i find all gcd between all pairs, smth like : g = gcd(d, a[j] — a[i]) , for every i, j
•  » » » » » 4 months ago, # ^ |   0 I did the same and could not pass pretest 12
•  » » » » » 4 months ago, # ^ |   0 I had a list of all common divisors of differences. Final list could have more than 1 element, so d is last element in list, which is the greatest one. I made mistake here and said that d is first element of the list which is actually 1 :)
•  » » 4 months ago, # ^ |   0 Use your own rand instead of C++ rand.
•  » » » 4 months ago, # ^ |   0 I had something like cout<<"xn is "<
•  » » 4 months ago, # ^ |   0 In fact u are findng at least 30 rand number and get their common gcd, if it is 1, the d is true. Actually, it is correct at most situations.
•  » » 4 months ago, # ^ |   +16 That seems to be the intended approach.Probability of failure is very small. Let's assume that you found dFake which is equal to k * d. This means that all your queries were lucky to hit position with same remainder modulo k, and the chance for it is roughly (1 / k)NumberOfQueries - 1.
 » 4 months ago, # | ← Rev. 2 →   0 Why fail segment tree solutions and pass BIT solutions in F? (Offline, solve for each prime separately) -_-
•  » » 4 months ago, # ^ |   0 My segment tree managed to pass the time limit. https://codeforces.com/contest/1114/submission/49743195
•  » » » 4 months ago, # ^ |   0 This isn't the segment tree solution I was talking about. There is another approach using segment tree that solves the problem offline by handling one prime at a time and merging all answers. Such solution using segment tree gets TLE but BIT gets AC.
 » 4 months ago, # |   +4 i think for about 40 minutes that's is sum in F instead of mult :(
 » 4 months ago, # |   +9 I was literally begging for pretest 5 in 'C' :(
•  » » 4 months ago, # ^ | ← Rev. 2 →   0 when u are finding minimum your minimum keeping variable should be large enough initially even 9e9 did not work....but after this i got struck at pretest 10 :(
 » 4 months ago, # |   0 what is pretest 7 in C :(I just checked how much each prime for b exists and applied this func for each primelong long factr(long long n,long long p) { long long po=0; for(long long i=p;i<=n;i*=p)po+=n/i; return po; } and then I got the result after division first array to the second (not sure if this is important to explain first array and the second )what's the mistake maybe just tell me the right solution and I'll know it because I have no idea
•  » » 4 months ago, # ^ |   +3 Have you checked your data type? I changed from long long to unsigned long long, and passed Pretest 7.
•  » » » 4 months ago, # ^ |   0 that would make a difference in the function I wrote above ?
•  » » » » 4 months ago, # ^ |   0 You may try remove i, and let n /= p and po += n / p instead. I passed the pretests in this way.
•  » » 4 months ago, # ^ |   +1 long long i=p;i<=n;i*=pIs there anything in your code to make sure that i*=p doesn't overflow long long?The idea that you described sounds right.
•  » » » 4 months ago, # ^ |   0 yikes No what a sad mistake
•  » » » 4 months ago, # ^ |   0 And this is the silliest mistake i have made . WA on pretest 7, i think im gonna cry a lot today :-(
•  » » » 4 months ago, # ^ |   0 49731384 Can someone help me with this. I am getting WA on Pretest 10 for problem C.
 » 4 months ago, # |   +9 E test case 12?
•  » » 4 months ago, # ^ |   0 Anti rand() testcase.
•  » » » 4 months ago, # ^ |   0 I used srand(time(0))
•  » » » » 4 months ago, # ^ |   0 Err yes — the C standard srand() and rand() will only generate integers up to RAND_MAX = 32767. The array size is quite large, and such low-range randomization could be easily countered.
•  » » » » » 4 months ago, # ^ |   0 I don't know what is worse anti-rand or anti java Arrays.sort tests
•  » » 4 months ago, # ^ | ← Rev. 2 →   0 My lazy way of solving this: long long RAND(){ long long ret = 0; while(ret < n) ret = ret * RAND_MAX + rand(); return ret % n; } 
•  » » » 4 months ago, # ^ | ← Rev. 2 →   +3 How about using C++ random #include mt19937 gen(time(NULL)); uniform_int_distribution range(1, 1000000000); auto RAND = bind(range, gen); 
 » 4 months ago, # |   0 I feel liangliang
 » 4 months ago, # |   +7 Tonight I learnt one thing from C, that one should never try multiply two numbers as large as 1e18... Failed several times for it. qwq
 » 4 months ago, # |   +5 Auto comment: topic has been updated by Akikaze (previous revision, new revision, compare).
 » 4 months ago, # |   +3 Anyone passed E without randomisation?
 » 4 months ago, # |   0 So is problem E just testing that we have read this blog Don't use rand(): a guide to random number generators in C++? Really?
•  » » 4 months ago, # ^ |   +20 Problem E was only about knowing that rand and random shuffle might fail you.
•  » » » 4 months ago, # ^ | ← Rev. 2 →   -23 Wow. So we have to be prepared for THIS type of problems now too? So it's kinda STDforces?
•  » » » » 4 months ago, # ^ |   +35 I’ve once heard that it’s a programming competition. And yes, you must know how basic stuff works in your favourite language.
•  » » » » » 4 months ago, # ^ | ← Rev. 2 →   -6 I don't mind. I'm just curious if this exploit-as-a-main-idea-stuff is going to be a trend.
•  » » » » » » 4 months ago, # ^ |   +3 It's like exploiting hashes modulo 2^64: if you are doing it often enough, everybody knows it and it gets rather pointless as an "exploit".I would even say that my example is far from perfect: hashes modulo 2^64 have advantages (like faster execution), so you may still reasons to gamble "Do they have tests against it?.."; and here the fix is pretty much one-liner without significant side effects.
•  » » » » 4 months ago, # ^ |   +73 Wow, mathforces, quickforces, hackforces, stdforces...You guys just never run out of ways to complain about contests.
•  » » » » » 4 months ago, # ^ | ← Rev. 2 →   +61 delayforces, isitratedforces, forcedforces, damnforces, unratedforces, grapeforces, overflowforces, cheatforces, longstatementforces, pupilforces, foolishforces...
•  » » » 4 months ago, # ^ |   0 Add time(NULL) and random_device not being random to that list.
 » 4 months ago, # |   0 What is correct structure for F? My first thoutgh is segment tree for each prime with add on segment and sum on segment. But then I realize that segment tree can't do that from my understanding.
•  » » 4 months ago, # ^ |   +11 That is entirely possible with lazy segment tree, but it uses too much memory.I had a segment tree storing the product of values in an interval, and a segment tree for every prime telling if the prime exists on the interval. The second type of segment trees just use vector, so they don't use too much memory.Answer to every query is just product of numbers in the interval * (p-1 / p) for every prime p that has at least one appearance on the interval. The division is of course modular division.In total this is O(q * log(n) * (log(n) + cp)), where cp is the amount of primes below 300This was quite annoying to fit in time limit however, since I don't know how to write a lazy interval multiplication segtree without taking modpow log(n) times. TLE'd once but some changes passed pretests, taking around 3s
•  » » » 4 months ago, # ^ |   +27 You can make things easier by noticing that there are 62 primes below 300, so you can store a single long long with a bitmask of primes available, and then have a single segment tree for all primes and do all updates/queries with bitwise operations.
•  » » » 4 months ago, # ^ |   0 Thanks.
•  » » 4 months ago, # ^ |   +4 One segment tree for product with range multiplication and the second one with bitsets for primes in range.
•  » » 4 months ago, # ^ |   +2 Segment tree got TLE with this idea. But BIT passed pretests. :(
 » 4 months ago, # |   +2 Now everybody knows who is the author of problem A. Of course, it's GreenGrape ;)
 » 4 months ago, # |   +8 Problem C Largest power of k in n!
•  » » 4 months ago, # ^ |   0 Yeah，I thought of the idea too, But I have not done that problem....sadT_T
 » 4 months ago, # |   0 What was pretest 5 in C ?
 » 4 months ago, # |   0 what is wrong with my solution on C? 49728844
•  » » 4 months ago, # ^ |   0 Try this. 9 36.The answer should be 2.
•  » » 4 months ago, # ^ |   0 I got that :( f *= f; always create a copy of f then multiply it in the loop. it should be like : f *= copy_f;
 » 4 months ago, # |   +6 20 minutes per problem? I want to think in deeper way, not just to be the fast-solving machine :( Why codeforces is pushing participants(in terms of time) so hard?
•  » » 4 months ago, # ^ |   -12 noob
•  » » » 4 months ago, # ^ | ← Rev. 2 →   0 Don't insult, playboy. FYI I prepassed ABCDE in this contest.
•  » » » » 4 months ago, # ^ |   +8 pro
•  » » » » 4 months ago, # ^ |   -8 FYI i dont give shit
 » 4 months ago, # |   -17 C was gay af
 » 4 months ago, # |   0 what would be the ans in test case in problem C: 5 100?
•  » » 4 months ago, # ^ |   0 0
 » 4 months ago, # | ← Rev. 3 →   -58 I_hate_greengrape
•  » » 4 months ago, # ^ |   0 I love GreenGrape. His problems are very beautiful.
•  » » » 4 months ago, # ^ |   -12 NOOOOOOOO, all his problems are from clay. Mathematical clay.
•  » » » » 4 months ago, # ^ |   0 The best. I hate greengrape, and now i start hate all other people))
 » 4 months ago, # |   +177 Wow what the fuck is wrong with those people bashing the authors for including anti rand() tests in pretest? If they weren't kind enough to make those pretests for you then surely someone would hack you in like 5 minutes. Do you guys seriously expect the authors to publicly announce Hurr durr just saying rand() is weak you should not use that but this problem is definitely not about random?Maybe next time try to actually appreciate the knowledge you gained in contests.
•  » » 4 months ago, # ^ |   -8 salty
•  » » 4 months ago, # ^ |   -9 omfg fuck author rand() gave me WA on contest noob tests my code best >:(((
 » 4 months ago, # |   +12 First time I actually enjoyed a GreenGrape contest.
 » 4 months ago, # |   -34 dissapointed with the contest overall but the setters are some weebs so what to expect
•  » » 4 months ago, # ^ |   +30
•  » » » 4 months ago, # ^ |   -7 sorry noob i dont get it
•  » » » » 4 months ago, # ^ |   0 You will get it once you achieve something other than trolling for fake internet attention haha cheers ;)
•  » » » » » 4 months ago, # ^ |   0 how can attention be fake? and who said I am trolling? I generally think anime is bad cheers ;); ) ;)omg im cool kid;);):)
•  » » » » » » 4 months ago, # ^ |   0 Yup! You are a "cool fool"
•  » » » » » » » 4 months ago, # ^ |   0 omg i use big words guys
 » 4 months ago, # |   +8 I think intersection enjoyed this contest!
•  » » 4 months ago, # ^ |   +3 Me too.
•  » » » 4 months ago, # ^ |   -22 how could you enjoy such a bad contest? it was so poorly made i am legitimately starting to wonder if it was a bad joke being played on us.
 » 4 months ago, # |   0 turns out rand() has max value 32768 on CF... rip master
 » 4 months ago, # | ← Rev. 3 →   +29 For those of you who are looking for a good and clear randomization implementation 49733774 Correct me if I'm wrong.Thank you Akikaze GreenGrape _kun_ neal
 » 4 months ago, # |   +6 WA#108 E... How to know did it fall due chance 1.86185·10 - 9?)
•  » » 4 months ago, # ^ |   0 I failed that too. It should be some hacks regrading std::random_device. I saw lots of submission failing 108 are using std::random_device.
•  » » » 4 months ago, # ^ |   0 That's because the output sequence of std::random_device on Codeforces is deterministic, check this.By the way, you are using std::random_device in wrong way, check this.
•  » » » 4 months ago, # ^ |   0 Yeah, I failed on that test case too.
 » 4 months ago, # |   0 first impression is last impression. great round!
 » 4 months ago, # |   +24 NO!!!! WHY????
•  » » 4 months ago, # ^ |   +14 rank 2 to rank 128...
•  » » 4 months ago, # ^ |   +18 Found you! Original rank 1 (8089 points):
 » 4 months ago, # |   0 What is wrong with this code.
•  » » 4 months ago, # ^ |   0 flag might exceed the range of lld and without fortune it can be in range [0, n - 1] again.
•  » » » 4 months ago, # ^ |   0 Thanks!
•  » » 4 months ago, # ^ |   +3 If you have a sufficiently big prime (say, greater than 5e9), flag will overflow during your while(n / flag > 0) cycle.
•  » » » 4 months ago, # ^ |   0 Thanks!
 » 4 months ago, # |   +67
•  » » 4 months ago, # ^ |   +10 Hacks on RANDOM-NUMBER-GENERATOR??!! That's pure evil!!
•  » » » 4 months ago, # ^ | ← Rev. 2 →   +6 Today I learned that pure evil is less than 232. The funny thing is that random_device is deterministic on codeforces.
 » 4 months ago, # |   -8 Auto comment: topic has been updated by Akikaze (previous revision, new revision, compare).
 » 4 months ago, # |   0 Why does using long double instead of long long worked for passing test case 10 in Q.C ?
•  » » 4 months ago, # ^ |   0 Even long long can have overflow issues dealing with big primes, something like 1e10 or so. 1e10 * 1e10 makes number even bigger than long long limit.
 » 4 months ago, # |   0 why my Test Case 17 is failing: Problem B @Akikaze Test: #17, time: 0 ms., memory: 140 KB, exit code: 0, checker exit code: 1, verdict: WRONG_ANSWER Input69 9 5-7 10 7 3 8 -9 9 -6 -5 -1 6 7 -3 10 2 3 -10 3 1 -7 -9 -10 7 2 -10 -7 -5 -5 -8 -7 4 3 10 -7 -8 7 4 6 -5 -6 8 -7 6 -5 -1 -4 0 -3 1 -2 -8 -3 -4 9 8 5 5 -5 -4 10 6 -6 -2 4 -6 -6 -3 -3 0Output13612 27 41 52 Answer13613 32 47 57 Checker Logwrong answer the sum of beauty in contestant's partition does not match with contestant's answer: expected sum = 136, found 130
•  » » 4 months ago, # ^ |   0 you are using the least in "bigger" numbers for several times. i got wrong on this test ,too. you should use a flag not to use it more.
 » 4 months ago, # |   +37 Hello codeforces, I want some advice about my sysfailed code in problem E.the only diffrenece between two codes is random function. the one with (rand()<<15)|rand() fails at test 101, but (rand()<<16)|rand() successfully passes all cases. I thought that if cpp rand() generates [0,32767] uniformly, then (rand()<<15)|rand() can generate [0,2^30] uniformly, but the result says it isn't.Could anybody solve my curiosity? Thanks in advance.
•  » » 4 months ago, # ^ |   +43 rand()<<15|rand() does generate [0,2^30] uniformly.I think that test 101 is an anti-test for rand(time(0)), or in other words all values of time(0) that start from somewhere around the end of the contest until a few hours after that, which is around 10800 values for 3 hours, so any code that uses srand(time(0)) and was judged during that time will fail, resubmitting should get AC.rand()<<16|rand() most likely works because test 101 was based on rand()<<15|rand(), and no similar test was based on rand()<<16|rand().All of what I said is might not be true, but I couldn't think of any other explanation.
•  » » » 4 months ago, # ^ |   0 Yeah, that's right.I did hacked rand()<<15|rand() and srand(time(0)); during the contest, and I generated 50000 values.https://codeforces.com/contest/1114/hacks/536367/test
 » 4 months ago, # |   +29 Apparently, my this submission got WA on test 101 in contest time and now the same solution is getting AC.WA SubmissionAC Submission (added an extra space before the last line because they weren't allowing me to submit the same code twice).
•  » » 4 months ago, # ^ | ← Rev. 2 →   +5 AC submission doesn't have the line x ^= 16153382;. rand() is a bad random number generator in general, and using it multiple times actually makes it worse. Also, rand() on CF gives atmost 215 - 1 anyway, so the lines x &= (1 << 15) - 1 and y &= (1 << 15) - 1 don't have any meaning.
•  » » » 4 months ago, # ^ |   0 May be it's not the most ideal random number generator. But that's not the point. The point is I should get consistent verdicts if I submit the same code repeatedly. And it appears that basically using srand(time(0)); is what caused me that WA, which is frustrating because many other contestants also used it and got AC.
 » 4 months ago, # | ← Rev. 5 →   0 What will be the output of this test case for D: 5 6 7 6 8 6
•  » » 4 months ago, # ^ |   +4 It's 3. My previous wrong solution was printing 2 for this test, because it wasn't take in consedirstion that the chosen start is unchangable, so it proceed your example like following:7 -> 68 -> 6But the correct process is:If we choose the index 2 (with number 7) as a start, then we will change it to 6, so the array will be: 6 6 6 8 6, then we connot change the index 2, so the array should become: 8 8 8 8 6, then: 6 6 6 6 6, so the answer is 3.
•  » » » 4 months ago, # ^ |   +4 Thanks a lot! I too misunderstood the question. :D
 » 4 months ago, # |   +8 Wow, cool song
 » 4 months ago, # |   -34 alright, this is enough. i have so many times expressed my concern about programming problems being wrongfully, but intentionally mixed with math. problem C was a nightmare because it had useless math. why do you keep making these? mid problem set you think “i can’t make this hard in a challenging way so i’m just going to bombard it with some random useless stuff”? this is not okay.also, seeing from the editorial you really didn’t care about the whole contest and/or about us either.. it was a joke. i had high hopes but they all fell short.
 » 4 months ago, # |   0 Loved this contest! Decently prepared and well-balanced. GRAPE ALL THE WAY
 » 4 months ago, # |   +36 Trying to make some rand(time(0)) code fail? Well, I'm not the great fan of that idea, but it can be an option if problemsetter can block every possible code that he can think of. The problem is that it's definitely impossible. If I use "rand() << 16 | rand()" instead of "rand() << 15 | rand()" by mistake, it will still work. If I use "for(int i = 1; i <= 5; i++) val = (val * RAND_MAX + rand()) % (1<<30)", which is my common random number generating code, it will still work too. If you can only make that exact random generating method, then what's the whole point of making those anti-rand tests? At this point, it's totally unfair to make some of the codes fail only by the reason that he used the same random number generator with the problemsetter.
•  » » 4 months ago, # ^ |   0 Well, my initial idea was blocking srand() and its derivatives only. I have thought of time(0) stuff, but then I didn't go on with making such failed, because: There'd be too many seeds to kill all of them. Using current time from epoch has been a common method in choosing seeds for RNGs, thus causing such approach failed (for not being precise enough to be unpredictable) would be too unfair, even to me. However, hacks are here and there. This kind of behaviours was unavoidable, and we still had to include such hacks into systest (tests with indices  ≥ 97 were hacks), thus making things more unfair than what I wanted at first.
 » 4 months ago, # |   0 I keep getting Runtime Error on B :( What could be the problem? I checked the memory capacity, return value, and declared them in the global variables but nothing seems to work! #include #include #include using namespace std; vector > vec; bool pick[2000001] = {0}; vector vec2; bool myfunc(pair a, pair b) { return (a.first >= b.first); } int main() { int n, m, k; scanf("%d %d %d", &n, &m, &k); for (int i = 1; i <= n; i++) { int a; scanf("%d", &a); vec.push_back({a, i}); } sort(vec.begin(), vec.end(), myfunc); long long int ans = 0; for (int i = 1; i <= m * k; i++) { pick[vec[i-1].second] = true; ans += vec[i-1].first; } int bucket = 0; for (int i = 1; i <= n - 1; i++) { if (pick[i]) { bucket++; } if (bucket == m) { bucket = 0; vec2.push_back(i); } } printf("%lld\n", ans); for (int i = 1; i <= (int) vec2.size(); i++) { printf("%d ", vec2[i-1]); } return 0; } 
•  » » 4 months ago, # ^ | ← Rev. 3 →   0 I think you made some mistake when you print the answer, have a try on this data : 6 1 4 4 3 2 2 1 1 your code has output 4 numbers in the second line, while the correct case should be 3. By the way, I suggest you use > instead of >= in myfunc()` , it seems that c++ requires strictly lower or bigger.
•  » » » 4 months ago, # ^ |   0 Thanks! Got an AC! Hope I don't make mistakes on indexing next time...haha^^;
 » 4 months ago, # |   0 First time become blue in this round, feeling good ^_^ .
 » 4 months ago, # |   0 Wonder how to prevent hack of E by random generator
 » 4 months ago, # |   0 In problem C, I m getting WA in test case 7 . But I m getting right answer in my compiler. but CF compiler is showing another output and giving me WA in test case 7 . I m using gnu g++ 14 . Can anybody have a look at my code ? https://codeforces.com/contest/1114/submission/49753432.
 » 4 months ago, # |   +1 For Problem C where can i read the necessary properties of factorial to understand the logic behind the given editorial?? I cant understand how the problem was simplified to just that. Akikaze
•  » » 4 months ago, # ^ |   0 Consider the b-ary representation of n!. Let it be represented by the digits d1,d2,d3,d4,d5,d6 (I'm considering it consists of 6 digits. It's similar for any no. of digits). Suppose last 3 digits are zero. Then it's decimal representation will be num=d1*b^5+d2*b^4+d3*b^3. The rest terms are not considered because they are zero. Clearly num is divisible by b^3. Here 3 is the maximum power of b that divides n! which is also the no. of trailing zeros. Hence proving the solution. Satisfy yourself with some more examples.
•  » » » 4 months ago, # ^ |   0 Got it man thanks a lot!!
•  » » » » 4 months ago, # ^ |   0 No problem brother. Happy coding!
 » 4 months ago, # |   0 In problem C the system says that my code is similar xith xb2403/49705111, ciwomuli/49716822, XY_cpp/49725082;That is because C is similar with the problem P3927 and I use the solution which is last modified at 2017-10-15 14:46
 » 4 months ago, # |   0 can someone tell me why my solution is wrong?code
•  » » 4 months ago, # ^ |   0 Try to get gcd from a[x] - a[y] for all your selected x and y, not only x and max.
•  » » » 4 months ago, # ^ |   0 Hey,Thanks for replyingit is still broken...Code
•  » » » » 4 months ago, # ^ |   0 I think that there is a countertest on pure random_shuffle. (Might be hack?) And sorry, using Euclidean algorithm my first suggestion is useless. (gcd(a, b) = gcd(a, b + a))
•  » » 4 months ago, # ^ | ← Rev. 2 →   0 You using random_shuffle for shuffling. Since it using rand() it shuffling only first RAND_MAX items which is small. Use std: : shuffle(begin, end, mt19937) instead.
•  » » » 4 months ago, # ^ |   0 Hi there,Thanks for pointing it out! Fixed. Appreciated!
 » 4 months ago, # | ← Rev. 2 →   +6 Problem C is an interesting maths problem. The idea is to look carefully at the b-ary representation of the number n!. It is a modification of Legendre's formula. We need to find the largest power x of b such that b^x divides n!.
 » 4 months ago, # |   +20 Wow 2019_BecameMaster! You seriously lived up to your name.
 » 4 months ago, # |   0 Wow the contest makers is a group of vietnamese. Does anyone vietnamese in here
 » 4 months ago, # |   0 In problem B i am getting correct output on test case 5 on my machine but on codeforces i am getting wrong output please help. My code