### Блог пользователя golions

Автор golions, 10 дней назад,

Hello Codeforces!

We, the disciples of Omkar (qlf9, Tlatoani, hu_tao, golions, and Omkar's newest disciple, rabaiBomkarBittalBang), have written our third contest: Codeforces Round #724 (Div. 2)Omkar 3. It will be held on Jun/06/2021 17:35 (Moscow time) and will be rated for users in Division 2 (rating lower than 2100). As usual participants with rating >= 2100 are allowed to compete too, but the contest will be unrated for them.

You will be given 2 hours to solve 6 problems. There may or may not be an interactive problem, so it would behoove you to read the guide for interactive problems. There also may or may not be competitive programming problems, so you should be sure to thoroughly understand everything here.

We would like to thank:

The scoring distribution is 500 — 1000 — 1500 — 2000 — 2250 — 2500.

May Omkar be with you!

Update: Thank you for participating in our contest! The editorial is here. We have video editorials for every problem there!

Update:

The winners in official standings:

The winners in unofficial standings:

Congrats!

• +532

 » 10 дней назад, # |   +85 As a tester, Omkar orz!
•  » » 9 дней назад, # ^ | ← Rev. 2 →   +50 The best part is that this roughly translates to Om Namah Shivay because Namah literally means to bow. Omkar orz!
•  » » » 8 дней назад, # ^ | ← Rev. 3 →   0 Does omkar even means shiva? because it means om pronunciation according to me and I verified by searching its meaningupd: it doesn't matter. Hoping for good bugaboos and strong pretests.
•  » » » » 8 дней назад, # ^ | ← Rev. 2 →   0 Then, what does it mean you think?
•  » » » » 8 дней назад, # ^ |   0 Omkar is also used one of the many names of Shiva. So yea it symbolizes him.
•  » » 9 дней назад, # ^ |   +34 Why so much reverence to Omkar? I mean I am just curious. You people aren't even Hindus(ig).
•  » » » 9 дней назад, # ^ | ← Rev. 2 →   +14 One of the problem setters' name is Omkar: qlf9... And he is an American...
•  » » » » 9 дней назад, # ^ |   +11 Oh. That makes sense.
 » 10 дней назад, # |   +48 Hope you all enjoy our problems :)
•  » » 10 дней назад, # ^ |   +35 qlf9 Omkar orz
•  » » » 9 дней назад, # ^ |   +18 May Omkar be with you!CODEFORCES VERSION: SpoilerMay Omkar bless good ratings on you!!!
 » 10 дней назад, # |   +50 As a tester, I must say problems are really interesting !! All the Best :)
•  » » 10 дней назад, # ^ |   +9 As a participant, I must say please tell me something new.
•  » » » 9 дней назад, # ^ |   +6 Meanwhile Negative delta : I am coming to you tonight
•  » » » » 8 дней назад, # ^ |   +1 After System Testing, "Virtual Contest and Practice Mode" : You could not live with your own failure. Where did that bring you? Back to me!!!
•  » » 9 дней назад, # ^ | ← Rev. 2 →   -24 [Deleted]
 » 10 дней назад, # |   +86 Interesting problems.
 » 10 дней назад, # |   +48 everyone click the Omkar 3 link
 » 10 дней назад, # |   +22 I'm still thinking that you all guys know Hindi ?
•  » » 10 дней назад, # ^ |   +30 Nope! I don't even know C++
•  » » » 9 дней назад, # ^ |   0 Hail Java XD
•  » » » 9 дней назад, # ^ |   0 yo walnut
 » 9 дней назад, # |   +4 Very quick scoring announcement!
 » 9 дней назад, # |   +5 Scoring looks pretty balanced, gonna be a nice round!!!
 » 9 дней назад, # | ← Rev. 5 →   -32 When i see there are a lot rounds comming in codeforces :
•  » » 9 дней назад, # ^ | ← Rev. 5 →   -20 [Deleted]
•  » » 8 дней назад, # ^ |   0 Rev 5 meme is fun :D i think it needs upvote, Thanks Amir_Hossein_Farhadi
 » 9 дней назад, # |   +7 It's time that these posts should use the word "Bugaboo" instead of "problem".
 » 9 дней назад, # | ← Rev. 4 →   +20 I was hoping for becoming Expert but now I might get demoted to pupil :(
 » 9 дней назад, # |   0 As a best coordinator antontrygubO_o orz!
•  » » 8 дней назад, # ^ | ← Rev. 2 →   0 After giving this contest i am really sad with my Lord to not rejecta single problem antontrygubO_o.
 » 9 дней назад, # |   0 I like this scoring distribution
 » 9 дней назад, # |   +21 Wow , another contest this week. If codechef could conduct as many contest as they launch new courses for cp then I would have become 4 star on cc xDD.
 » 9 дней назад, # |   -8 Hail omnipotent Omkar.
 » 9 дней назад, # |   +31 Problem / Bugaboo Names of this Contest"Omkar and X". Here 'X' can be anything.
 » 9 дней назад, # |   -38 Brother,just curious to know Omkar means what? The link you provided Omkar3 is youtube link that's the hinduism. From my perspective, Here all contestant are not hindu. But you are spreading your religion by Omkar?
•  » » 9 дней назад, # ^ |   +20 You can just replace omkar with god. This is maybe not for spreading any religion, but instead it creates a humour(here). Also the link is a part of that joke, pointing that its their third contest(its like they created a third part of a kids movie) At first it baffled me. But later I recognized that it lightened my mood.
•  » » 9 дней назад, # ^ | ← Rev. 3 →   +3 .
•  » » » 9 дней назад, # ^ |   +3 Lmao yep, my real name is Omkar and I’m American :P
 » 9 дней назад, # |   +3 Why the organisers are obsessed with Omkar. I don't think they even know Hindi.
•  » » 9 дней назад, # ^ |   +1 Omkar is one of the problemsetter's name.qlf9
 » 9 дней назад, # |   +1 Hope so I will be able to solve B this time
 » 9 дней назад, # |   +5 Just curious how to become tester
•  » » 9 дней назад, # ^ |   +14 You should be personally familiar with some problem setter, so (s)he could personally kick the s**t out of you if you leak some problems beforehand, spoiling the contest and efforts of many people )
 » 9 дней назад, # | ← Rev. 2 →   -59 I love CF
•  » » 9 дней назад, # ^ |   0 fwilgi lw4
 » 9 дней назад, # |   +3 I don't have much sense of humour, can someone explain what's going on?
•  » » 9 дней назад, # ^ | ← Rev. 2 →   -17 Just take it as a normal contest
•  » » » 8 дней назад, # ^ |   0 By this contest, they are promoting a video about Omkar. What is Meaning of Omkar
 » 9 дней назад, # |   0 I like this scoring distribution Scoring looks pretty balanced, gonna be a nice round!!!
 » 9 дней назад, # | ← Rev. 2 →   +8 The good' ol 6 problem 2 hr div2 is back finally!
 » 9 дней назад, # |   0 "There also may or may not be competitive programming problems" yeah like why would you include competitive programming problems in a competitive programming contest, that would be very weird.
•  » » 9 дней назад, # ^ |   0 Yeah they should ask you to create a website :)))
 » 9 дней назад, # |   0 Scoring looks encouraging!
 » 9 дней назад, # |   -11 golions, you made a mistake. This should be BUGABOOS, not Problems.
 » 9 дней назад, # | ← Rev. 2 →   -38 God for creating the world and the human race.
•  » » 9 дней назад, # ^ |   +9 but when did he disrespected other religion,omkar is name of one of the problem setter and I am sure he said it all in sarcastic way
•  » » » 8 дней назад, # ^ | ← Rev. 3 →   -37 Omkar for creating the world and the human race.That means the problemsetter created the world?
•  » » 8 дней назад, # ^ |   +1 Ok snowflake
 » 9 дней назад, # | ← Rev. 2 →   +11 after looking at a few comments up here, I would like to imagine a Latin American guy named Jesus creating a round, then they put his name on all problems and thanked him in the announcement blog
•  » » 8 дней назад, # ^ |   -26 He wouldn't say that he created the world and human race, right?
•  » » » 8 дней назад, # ^ |   +27 lol Everytime someone has prob with other religion,it is always muslim guy from Indian subcontinent,from santa time to omkar name ( although omkar is name of problem setter and he has surely written that in sarcastic way )and even if he hadn't why did you care so much,I know one muslim writer (Dont remember name) has written " all credits due to allah and allah has created world " thing but then no one felt offended lol and then he say " respect all religions"
•  » » » » 8 дней назад, # ^ |   -10 Should I reply your comment with a fake id?
•  » » » » » 8 дней назад, # ^ |   +12 who say this id is fake?If it was fake I wouldnt have been active daily for the last 6-7 month,Its just that I prefer upsolving instead of giving contest btw You also know I spit a fact so you brought fake id thing in reply LET CF BE CODING COMMUNITY DONT MAKE IT SITE TO START WAR ON RELIGION BASIS OR NATIONALITY BASIS ALL CODERS ARE SAME
•  » » » » » » 8 дней назад, # ^ | ← Rev. 3 →   0 Do you know about the new feature of codeforces that if you solve any problem it will be showed in your profile. And your profile says that you didn't solve a problem since April, and you total solved 8 problems since you created this fake account!
•  » » » » » » » 8 дней назад, # ^ |   +7 Great job exposing your own fake account used for cheating in contests.
•  » » » » » » » » 8 дней назад, # ^ |   0 lol, that fake account has much higher rank than me! And fake account was created before real account!
•  » » » » » » » 8 дней назад, # ^ |   +6 Have you even heard of mashup thing,I had done lots of mashup but is this even a point? Point was that you guys had always problem whether it is santa or omkar (although not all muslims, Every community has black spot and I think you are that in Muslims ,cause none of muslims brothers commented except you)
•  » » » 8 дней назад, # ^ |   +1 If you want to debate on religion. I'll happy to join you on Twitter. Please let this site be for CP only. It shouldn't matter to anyone if problem setters add one two lines for humour and thanking god according to their own faith.
•  » » » » 7 дней назад, # ^ |   0 i was thinking the same.these guys are everywhere!!
 » 9 дней назад, # | ← Rev. 7 →   -85 .
•  » » 8 дней назад, # ^ | ← Rev. 2 →   +53 Very relevant meme
 » 8 дней назад, # |   +6 Omkar orz... Om Namah Shivay!
 » 8 дней назад, # |   +3 Will Omkar inspire the authors to release the Editorial eventually?
 » 8 дней назад, # |   +1 there also may or may not be rated contest so you should read all of the rules about unrated contest.
 » 8 дней назад, # |   -38 God for creating the world and the human race.
•  » » 8 дней назад, # ^ |   +3 you muslims are weird
•  » » » 8 дней назад, # ^ |   -11 Muslims say Allah not God. God is a common name of our creator for all kind of people.
•  » » » » 8 дней назад, # ^ |   +9 lol So he was telling me that I uses fake account, Bro when a muslim author said in a contest announcement blog that allah created universe then why didnt u pointed out? Again writing same thing LET CF BE CODING COMMUNITY DONT MAKE IT SITE TO START WAR ON RELIGION BASIS OR NATIONALITY BASIS ALL CODERS ARE SAME
•  » » » » 8 дней назад, # ^ | ← Rev. 2 →   0 Who decides that God is a a common name. It can be anything... you can't assume it to be God, Allah or whatever... It's ones choice. Also don't get offended by others expressing their beliefs.
•  » » » 8 дней назад, # ^ | ← Rev. 2 →   -11 Why is this comment getting upvoted?
•  » » » » 8 дней назад, # ^ |   +4 because it's true..ig??
•  » » » » » 8 дней назад, # ^ |   0 You don't talk about stuff like race or religion on a cp website.
•  » » » 8 дней назад, # ^ |   0 From the Indian subcontinent, not from the middle east.
 » 8 дней назад, # |   +25 What is the Meaning of Omkar ?The word OM came from Hindu mythology.OMKAR ओंकार —OM + KAR = Om is a indeclinable .It is a sacred syllable and is Uttered as a holy exclamation at the beginning and end of a reading of the Vedas or previous to the commencement of a prayer or sacred work.KAR is from kri कृ root word , which means doing , making , performing.It is a term, denoting a sound or word which is not inflected.OMKAR is a SACRED syllable OM itself.The exclamation OM. It is a Supreme Brahm.OMKAR is a powerful word when chanting gives physical and mental health. One can feel certain vibrations in the body and so it controls anger, increases patience and tolerance levels.Chanting of Omkar improves concentration, brings down stress, anxiety, and tension.It is a meditation. It reduces negativity.So the meaning of the name has powerful meanings.I think this will help you.
•  » » 8 дней назад, # ^ | ← Rev. 3 →   0 I have explained it in short in this comment(see rev 1 of that) https://codeforces.com/blog/entry/91438?#comment-800185 And I don't know why I got a lot of downvotes there.
•  » » 8 дней назад, # ^ |   +1 Yes, True that. Only I would like to add-. "Om" is considered to be the cosmic sound. It originates back when nothing existed and space was empty & quiet, the creation of universe brought with itself the vibrations of Om. And hence it was the first sound that ever originated.. Proper chanting of "OM" has remedial effects on any mental or physical stress because "om" is considered to be made up of every possible frequencies of sound and when chanted, it tunes with the frequencies of self and provides relief.
 » 8 дней назад, # |   +3 golions, Is there any way to become disciple of Omkar?
•  » » 8 дней назад, # ^ |   0 Do meditation and concentrate solely on the sound "OM" of the universe. Not only will you become a disciple of Omkar, but all your confusion will also go away xD.
 » 8 дней назад, # |   -17
 » 8 дней назад, # |   0 Good Luck everyone!
 » 8 дней назад, # |   +25 Hail Omkar
 » 8 дней назад, # |   +10 When a problem score is 2000, does it mean its difficulty is 2000?I am new to codeforces. Pardon me.
•  » » 8 дней назад, # ^ |   +8 No, it doesn't. The problem score means only the gap between difficulties of the problems. In average it's close to the truth, but now always :)
•  » » 8 дней назад, # ^ |   +11 No. It is the maximum score you can get upon solving the problem. Difficulty is assigned to a problem after the contest is over, on the basis of ratings of participants who were successfully able to solve it.
 » 8 дней назад, # |   0 Seems like problems were made for div1, lol.
•  » » 8 дней назад, # ^ |   0 Very bad problem explanation as well IMO
 » 8 дней назад, # |   0 The Marking system feels shit, if you submit first in just 3 min with one error, gives less marks compared to someone who solved it after 25 minutes.ughhhh
•  » » 8 дней назад, # ^ |   +11 Wrong submissions have penalties. You should consider checking on more test cases before submitting.
•  » » » 8 дней назад, # ^ |   -24 Saying by not even sitting in the contest sounds good.Here I am the one who failed horribly in the contest and there you are who didn't attend a single contest giving and firing your utopian quotes on me. :)
•  » » » » 8 дней назад, # ^ | ← Rev. 2 →   +5 Sorry if that hurt you. I know how it feels dude. I already solved 3 problems with 5 wrong submissions, I already had negative contributions, so I was just afraid to comment with my actual id because of down votes. hehe, LOL!
•  » » » » » 8 дней назад, # ^ |   -13 Yaa, that hurt me, and tell me your real id then ;)But, I am feeling sad for you as you care about your contribution more than your rating
•  » » » » » 8 дней назад, # ^ |   +3 Hey bro finally, I submitted 3 with one wrong submission ;)when I was chatting with you at that time I was at one :)
 » 8 дней назад, # |   0 I personally wouldn't be surprised if someone said: "Anton did NOT reject problems for this contest!"
 » 8 дней назад, # |   +1 Was Div2 A always this hard?
•  » » 8 дней назад, # ^ | ← Rev. 2 →   +9 nah, i consider this problem to be on div2 b/easy c levelthe fact that problem statement is written so bad makes this problem even harder
•  » » 8 дней назад, # ^ |   0 It wasn't that hard especially if you look at the constraints, which made it quite easy to implement.
 » 8 дней назад, # |   0 The problem statements should rather be considered as riddles.
 » 8 дней назад, # |   +21 i still don't have Diluc and Fischl..ehe..maybe that's why i still fail to solve their problems
 » 8 дней назад, # |   +7 There also may or may not be competitive programming problems Very true, now my tongue has well-defined six-pack abs after going through these tongue twisters.
 » 8 дней назад, # | ← Rev. 2 →   +17 me on A: 31 minutes B: 28 C: 24 I'm not saying it's not balanced but WTF is wrong with me why do I start like an idiot then focus more and more
•  » » 8 дней назад, # ^ |   0 supahotfire CM perf orz
•  » » 8 дней назад, # ^ |   0 I think A was difficult than usual. I submitted A in 18 minutes still had a decent rank for a while.
•  » » » 8 дней назад, # ^ |   0 I still dont know why my A is incorrect.
•  » » » » 8 дней назад, # ^ | ← Rev. 2 →   0 probably because of the 300 size conditionEdit: Just realized i didn't read the problem properly and thought array may contain any integer
•  » » 8 дней назад, # ^ |   +1 For me A was harder than B and C. Actually I am not sure if A works. I implemented some brute force for both, A and B, without being able to see if then will TLE or not.
•  » » » 8 дней назад, # ^ | ← Rev. 3 →   0 Edit: nvm it was bullshit
•  » » » » 8 дней назад, # ^ |   0 if there is one negative number the difference will still be positive since we are taking absolute value
•  » » » » » 8 дней назад, # ^ |   +3 If there's one negative number and a positive one then you will have to infinitely add new numbers
•  » » » » » » 8 дней назад, # ^ |   0 It seems all of our submission where finaly AC. Congrats to your nice delta!
•  » » » » » » » 8 дней назад, # ^ |   0 Yup :D Congrats to you too
•  » » » » 8 дней назад, # ^ |   +3 Nope, why should it fail?? If the array is [-a, 0]. Then their absolute diff is still positive (|a|). So it will go on forever. Don't give such heart attacks, I solved with the same logic as you lol.
•  » » » » » 8 дней назад, # ^ |   +3 Yeah I just realized it sorry XD
•  » » » 8 дней назад, # ^ |   0 me too, I had to skip it and come back to it..
 » 8 дней назад, # |   +5 Thanks problem B for negative Delta :)
 » 8 дней назад, # |   +8 First task was pretty hard for div.2 ( Thanks for your time spent for making a contest)
 » 8 дней назад, # |   +3 participating today was a bad idea
 » 8 дней назад, # |   +11 I see a huge gap between C and D, but on the other hand there where still a lot of people solving D.Maybe I missed some more or less obvious observation.
•  » » 8 дней назад, # ^ |   0 Yeah, you missed a small observation. Let's build array a based on array b from the beginning. So for every operation, we can add at most 2 elements into a. So for the current move, if the previous median is not equal to the new median then there cannot be an element in the array we build (a) whose value is in between the new median and the old median. Because if you add two unknown elements into array [1,2,3,4,5,6,7] then the median can be one of 3,4 and 5.
 » 8 дней назад, # | ← Rev. 2 →   +5 Can someone please help me where I went wrong for bugaboo C? I was getting correct answer on test cases and I am pretty sure about the logic too. 118652416
•  » » 8 дней назад, # ^ | ← Rev. 2 →   +1 Not sure how this is supposed to work dp[j] = max(dp[j], j / i);The ratio is arr[0][i]/arr[1][i], but not the mathmatical result of the division, but the fraction. So we need to divide both values by gcd(), and then count foreach position how much of them exist left of that position.
•  » » » 8 дней назад, # ^ |   0 If the ratio of D:K upto position j is equal to that upto position i, then I am updating dp[j] to be the number of conntinous groups of size i which is j/i.
•  » » » » 8 дней назад, # ^ |   +1 The issue is that the continuous groups can have different sizes.
•  » » » » » 8 дней назад, # ^ |   0 Can you provide a testcase on which my code would fail?
•  » » » » » » 8 дней назад, # ^ |   0 Something like this DKDDKK
•  » » » » » » » 8 дней назад, # ^ |   0 It gives 1 1 1 1 1 1. Isnt this correct?
•  » » » » » » » » 8 дней назад, # ^ |   0 Nope it should be 1 1 1 1 1 2
•  » » » » » » » » 8 дней назад, # ^ |   0 No, the last one is a 2, since we can split in first two letters, and last 4 letters. Both have ratio 1:1
•  » » » » » » 8 дней назад, # ^ |   0 Hmm, I used ur approach in the beginning and the following testcase did not work: 1 9 DDKDDDDKKThe answer should be 1 2 1 1 1 1 1 2 2
•  » » » » » » » 8 дней назад, # ^ |   0 How is it 2 at the last place? Shouldn't it be only 1 group? Or am I missing something?
•  » » » » » » » » 8 дней назад, # ^ |   0 DDKDDDDKK can be split into DDK and DDDDKK and both have 2:1 ratio.
•  » » » » » » » » » 8 дней назад, # ^ |   0 Ohh, my bad. Got your point thanks!
 » 8 дней назад, # |   0 Many E's will fail today (at least 2 in my room itself) because they will print $-1$ instead of $10^{9}+6$ but I was too lazy to hack lol.
•  » » 8 дней назад, # ^ | ← Rev. 2 →   +69 I don't think so, none of the powers of 2 modulo 1e9 + 7 has value equal to 0.
 » 8 дней назад, # |   +12 Can't believe 3k people solved C
•  » » 8 дней назад, # ^ |   -10 It was easy. Just needed to notice then ratio of D/K remains same as the total. After that its just binary search. C//Think simple yet elegant. #include using namespace std; #define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ll long long #define all(v) v.begin(),v.end() #define F first #define S second #define pb push_back #define mp make_pair #define pi pair #define REP(i,n) for(int i=0;i> n; string s; cin >> s; int cntD=0,cntK=0; map> m; for(i=0;i> tt; while(tt--){ run_case(); } } 
•  » » » 8 дней назад, # ^ |   0 YES!!! My code is based on binary search ,but i dont know why i cant pass
•  » » » 8 дней назад, # ^ |   +10 A safer approach than doubles is to store a pair representing x / y. However be careful to store it in its reduced form, that is, where gcd(x, y) = 1.Also instead of binary search, we can just store the number of times we have encountered this reduced fraction when iterating from left to right.Implementation: 118610628
•  » » » » 8 дней назад, # ^ |   0 Wow nice luckily it passed, I have to be careful next time thanks for the heads up.
•  » » 8 дней назад, # ^ |   0 Its a pretty common idea that has appeared a lot (especially at the start of this year on Codechef) — having a map storing some property which becomes the same (or similar) for all valid ranges then checking for each right end. So I don't think its that surprising that a lot of people solved it.
•  » » » 8 дней назад, # ^ |   0 Its a pretty common idea that has appeared a lot Can you please give one of those links?
•  » » » » 8 дней назад, # ^ |   +1 I'm not really good at remembering problem names, but two examples of problems using the right end of a subarray idea, that are somewhat similar to this problem are:Mex SubsequenceSed PasswordsThere were 2-3 others ones I think (including some at a comparable difficulty to this C that didn't need dp), but I only remember the names of these two problems since I was involved with testing them.
•  » » 8 дней назад, # ^ | ← Rev. 5 →   0 C was easier than B. I think we have to just maintain the simplified ratio of D and K we got till now.Like 1:2 is same as 2:4 and which is same as 4:8 so, just divide D and K by gcd for that. As ratio of one part of the string must of equal to the ratio of complete prefix. But i feel B more harder than C. Although there was not much difference.BTW problem similar to B was also on HackerEarth Link
•  » » 8 дней назад, # ^ |   +10 I don't think that C was 3k easy. Something else is going on.
 » 8 дней назад, # |   0 Hello,bro,may i ask how to solve Problem C ? Actually, i don't know the reason why i get wrong answer , :(
•  » » 8 дней назад, # ^ |   0 We just have to iterate through the string, keep track of num_of_D, num_of_K, and store their ratio (after dividing by gcd(D, K) iff D!=0 AND K!=0) perhaps in a map int> — and print the value of the map for each pair — soln https://codeforces.com/contest/1536/submission/118649389
•  » » » 8 дней назад, # ^ |   0 thx a lot , ur solution is very great!!
•  » » 8 дней назад, # ^ |   +4 HintIf you add or subtract equal ratios then also it's value remains same. Hence you can do dp solution. Suppose ratio of whole prefix till $i$ is $r_1/r_2$ then $ans[i]=ans[m[{r_1,r_2}]]+1$ where $m[{r_1,r_2}]$ is map which gives last index of occurrence of $r_1/r_2$.
 » 8 дней назад, # |   +12 Out of curiosity, is there a way to solve D by sort of simulating the valid ranges $a_i$ could lie in using coordinate compression on $b_i$ plus something like a fenwick tree? Something like when you initially place a new element we constrain it to lie between (-INF, $b_{i} - 1$] or [$b_{i} + 1$, INF), assume they initially lie at the left end and use a fenwick tree to count how many we can move to the right. I know the intended solution using upper and lower value stacks is easier and more elegant but I'm just curious if such an approach is feasible.
•  » » 8 дней назад, # ^ |   0 yes 118614133
•  » » 8 дней назад, # ^ |   0 I thought of following approach but could not implement, could someone tell if how to implement if their solution was similar : SpoilerI thought of approach were at each step i will append -1e9,1e9 , will replace -1e9 by median if median is greater than last median else will replace 1e9 if median is smaller than last median.For example if input array is 6,2,1. Then first i will append 6 and then -1e9,1e9. Hence till index 3 array will be 6,-1e9,1e9. Then we can replace 1e9 by 2 since 2<6 i.e array will become 6,-1e9,2. Then again i will append -1e9,1e9 and array will become 6,-1e9,2,-1e9,1e9. Since 1<2 i will replace 1e9 by 1 and array will become 6,-1e9,2,-1e9,1. If at any stage after replacing, median is not same as required median then answer will be NO.
•  » » 8 дней назад, # ^ | ← Rev. 2 →   0 Yes, that is more or less what I did. Compress coordinates. Use a binary indexed tree to keep track of values that are fixed. All values from the input need to be fixed, and if values are repeating, it is enough to fix each value once. Values that are not fixed are either minus or plus infinity, and we keep track of the counts. So, iterate over the input array. The first value goes to the Fenwick tree directly.After that, for each value, check how many values so far were strictly larger (including values from BIT and plus infinities), strictly smaller (including values from BIT and minus infinities) and equal to the new intended median. If the value of the median was not fixed before, fix it. The remaining values (1 or 2 depending on whether we had to fix a new value in this iteration) become minus or plus infinity, depending which category is less numerous. After the assignment, check if the supposed median is actually a median.
 » 8 дней назад, # |   +5 How to solve C ? I tried to iterate on divisors of count of 'D' and then finding the value for possible count for 'K' and then check if the ratio existed somewhere. But I kept wrong answer on Pretest2. . What is the correct procedure to solve this sum ?
•  » » 8 дней назад, # ^ |   0 Even I tried to do the same but got WA on Pretest 2. :(118652416
•  » » » 8 дней назад, # ^ |   0 I am kinda bad at explaining but this is my attempt at solving Chttps://codeforces.com/contest/1536/submission/118641651
•  » » 8 дней назад, # ^ |   0 The key observation is, that if we remove a prefix of given ratio, the remaining part has same ratio.So foreach position, we need to find the number of positions left of it with same ratio.
•  » » 8 дней назад, # ^ |   +1 Create a map,int> where the key is the ratio, seen as a pair of ints instead of a double. Iterate through the string and keep two counters, current numbers of D (currD) and current numbers of K (currK), for every position in the string call x=gcd(currD,currK) and add one to map[{currD/x,currK/x}] and thats the answer for that position. You are counting how many segments are with the same ratio than your current position.
•  » » 8 дней назад, # ^ | ← Rev. 2 →   0 **if A/B = C/D = E/F then A/B = C/D = E/F = ... = (A+B+E+...)/(C+D+F...) ** Thus a prefix can be divided into Components if The count ratio of D and K in all the partitions is same as that of Prefix . How to Store Fraction in Their Simplest Form : simple form of x/y is X/Y = (x/G)/(y/G) where G=__gcd(x,y) . We Can use map to store the position of Last index where the ratio was {X,Y} if the ratio at any index is i {a,b} the ans[i] = 1 + ans[pos[{a,b}]]; pos is a map.
•  » » 8 дней назад, # ^ |   0 Notice that the D/K ratio of any prefix remains the same as its optimal partition. Also for such a prefix it suffices to greedily find the smallest prefix that satisfy this value of D/K. This can be precomputed. Then use binary search to find the total elements with same ratio uptil index i and print the answers for every prefix online.Proof that D/K ratio is a constant : $\sum\limits_{k = 1}^MD_i + \frac{yD_i}{x} = L$Here M is the optimal partitions Di are number of D in prefix of length L and the fixed y/x is the ratio of K to DCode : C//Think simple yet elegant. #include using namespace std; #define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ll long long #define all(v) v.begin(),v.end() #define F first #define S second #define pb push_back #define mp make_pair #define pi pair #define REP(i,n) for(int i=0;i> n; string s; cin >> s; int cntD=0,cntK=0; map> m; for(i=0;i> tt; while(tt--){ run_case(); } } 
•  » » 8 дней назад, # ^ |   0 Move along the array from left to right and for each prefix, find the ratio of D/K (rounded down to simplest form). Maintain a map to count the number of occurrences of this ratio and then the answer for index i is simply mp[ratio] + 1. It is always better to store the ratio as a pair of numerator and denominator to avoid division by 0.
•  » » 8 дней назад, # ^ | ← Rev. 2 →   0 Suppose when iterating from left to right, at index $i$, we have $cnt_D$ occurances of $D$ and $cnt_k$ occurances of $K$.Now let us note that for a given string, if all the components have the same ratio $x:y$, then the total string will also have the ratio $x:y$. So it is sufficient to check for only this ratio.Now the answer is just many prefixes till index $i$ has a ratio $x:y$ occurred. This works as if for some $j \lt i$ $x_{j}:y_{j}$ and $x_{i}:y_{i}$ have the same ratio, then $x_{i}-x_{j}:y_{i}-y_{j}$ must have the same ratio. So we can just count this using a map of pairs $(x, y)$However we must also take care of the fact that $x:y$ and $kx:ky$ are the same ratio. To do so we can just reduce the ratio to its lowest form by dividing both terms by $gcd(numerator, denominator)$.Code: 118610628
 » 8 дней назад, # |   0 There should be a bugaboo named "Omkar and hard contest"
 » 8 дней назад, # | ← Rev. 2 →   0 Thank you for the contest!I kinda feel like C and D should be swapped, but then again it's kind of my fault I didn't start reading D after getting stuck on C I guess.Anyway, it's not really much of a problem, the bugaboos were IMHO still good!
 » 8 дней назад, # | ← Rev. 4 →   +45 Well, Problem E seemed really difficult at first. But the solution is merely two lines! SolutionCount the hashtags. Count the Zeros. Calculate $2^{hashtags}$ and subtract $1$ if there are no zeros. It is done! HintImagine you got a distribution of 0-es and *-Stars. A Star denotes some number >0. This distribution defines exactly one valid solution, since each Star is predetermined! I got no proof yet, but just try it out with some small examples, you will see. :)
 » 8 дней назад, # |   +11 How to solve E ?
•  » » 8 дней назад, # ^ | ← Rev. 3 →   +16 I didn't submit since I was too late, but my solution got the samples correct. SpoilerI checked some small cases by hand and found that if you fix which zero cells you take, then there is exactly one valid solution. So, the answer is just how many ways you can fix the zeros or $2^{hashtags}$.If there are no zero cells in the grid, then you have to $-1$ the answer since you need at least one zero in the grid due to the second condition.UPD: Idea got AC post-contest
•  » » 8 дней назад, # ^ |   +13 So, basically, you fix each hash to be 0 or non-zero. Now, which elements in matrix are zero and which are non-zero. Now, suppose you fix the hash at position (i,j) in the matrix to be non-zero, then the value of (i,j) will be the manhattan distance to the nearest zero. My proof is quite tedious but try proving it by contradiction.
 » 8 дней назад, # |   0 I just want to know , whether i will have any rating change , if i didn't submit a single line of code, no right no wrong??
•  » » 8 дней назад, # ^ |   0 No
•  » » 8 дней назад, # ^ |   0 No, it won't.
•  » » 8 дней назад, # ^ | ← Rev. 2 →   -8 You submitted, but got 'Compilation error'. It will affect your rating. Just look at rainboy's contests.
•  » » » 8 дней назад, # ^ |   0 Yes , i saw , thank you
 » 8 дней назад, # |   +4 too many redudant statement, can't understand problem C :(
 » 8 дней назад, # |   +21 trollest contest on cf
 » 8 дней назад, # |   0 spent a lot of time on A , then thought "they did not mention to give an optimal solution" so i just printed 0 to 100 for every case without negetive values and voila , answer accepted . is that an acceptable bugaboo? hmmmm .
 » 8 дней назад, # |   +16 My submission to A is totally not legit (TLE), but I managed to pass system tests anyway. Here's my video of the round: https://www.youtube.com/watch?v=dXS6nNiYeZs
 » 8 дней назад, # |   +53 meet a new cheater This is how kedos123 bypasses Plagiarism testing.I am watching him from so many contest , He has done this today and in previous contest, and I am sure he must have done it multiple times before as well. People like kedos123 are spoiling the sport. I don't understand where would cheating take them in life. They will never get anywhere in life but always remain what they are i.e cheater. He should be banned from the platform as soon as possible . MikeMirzayanov sir pls ban him and skip his solutions . todays submission 118639631 118614794 saw his submission time , he is that much pro that he can solved problems in 2 minutes .kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++; jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++; jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;
•  » » 8 дней назад, # ^ |   0 MikeMirzayanov look into the matter sir . upvote expose these cheaters and mention new cheatears if u found anyone
 » 8 дней назад, # |   +41 How the hell was B approved?! Such an annoying to code problem. The average problem-A on CF requires more thinking than that. I liked C, A today and have almost no clue why my D or E passed. Seemingly dumb guesses that I can't prove.
 » 8 дней назад, # |   +8 Can anyone give some hints for D?
•  » » 8 дней назад, # ^ |   +22 Whenever you add the two new integers, you have three options. Add them to the left of the previous median. This results in shifting the median one to left. Add them to the right of the previous median. This results in shifting the median one to the right. Add one on either side. Same as previous median. Try to think of the situation where the answer would be "NO".
 » 8 дней назад, # |   0 How can https://codeforces.com/contest/1536/submission/118604068 solution pass if the question doesn't say we can remove the element?
•  » » 8 дней назад, # ^ |   0 Which element is removed? All the required elements are present.
•  » » » 8 дней назад, # ^ |   0 the negative one's
•  » » » » 8 дней назад, # ^ |   0 When the neg flag is on, the output is NO.
•  » » 8 дней назад, # ^ |   +4 if the given array contains negative elements then the answer is NO, otherwise just print from 0 to 100, it will always contain the given array
•  » » » 8 дней назад, # ^ |   0 oh sorry, I am totally BLIND.
•  » » » 8 дней назад, # ^ |   0 Damn, I actually constructed the array by using set and vector. Didn't see this observation!!
•  » » 8 дней назад, # ^ |   0 if (neg) { std::cout << "NO\n"; }
 » 8 дней назад, # |   +6 stories (short or big) in problems are good if they can somehow help in imagining. In A,B,C,D if problems were without stories then it would have been good.
 » 8 дней назад, # |   +14
 » 8 дней назад, # |   +2 In C I somehow thought I should split the prefix evenly which waste a lot of time of mine :(
 » 8 дней назад, # |   +9 Strong Pretests !! :|
 » 8 дней назад, # |   0 My opinion about C:WTF is this explanation ?!! if someone couldn't understand the explanation then he'll see the samples, that's what I did but the sample explain another problem !! I (and I think a lot of peoble) understood it like every segment should have the same number of 'K's and 'D's. question for the authors: couldn't put a good sample to explain another cases ??!!
•  » » 8 дней назад, # ^ |   0 The explanation could have been simpler i guess..
•  » » 8 дней назад, # ^ |   0 Exactly, I also understood the problem to be this, and could not come up with why it is not passing for about 1 hour.. before realizing that the ratio are compared in simplest form.
 » 8 дней назад, # |   +24
•  » » 8 дней назад, # ^ |   +1 ;P nice one
 » 8 дней назад, # |   0 Can somebody please tell me why 118638104 gives run time error on test case 2?
•  » » 8 дней назад, # ^ |   0 a<0 && lol!=true once this condition is met it will always goes into else case but when there is a second negative number isit[neg] will throw RTE
•  » » » 8 дней назад, # ^ |   0 yea got it thanks!
 » 8 дней назад, # | ← Rev. 2 →   0 Did anyone tried to solve C using sieve? My Attempt — 118650015
•  » » 8 дней назад, # ^ |   0 what will be the time complexity of prime divisor using in this question?will it pass?
•  » » 8 дней назад, # ^ | ← Rev. 2 →   0 See this I used prime factorization 118647756 Spoiler(PS: there was no need of this u can simply used gcd of count(d),count(k) )
 » 8 дней назад, # |   0 118650415 why TLE? Problem -: B
•  » » 8 дней назад, # ^ |   0 Use m.find(g)==m.end() instead of $m[g]!=1$. This is the cause you are getting TLE. In map, [] operator store the key, then check value.
•  » » » 8 дней назад, # ^ |   0 Thanks Broh. so Unlucky iam
 » 8 дней назад, # |   0 EBACDF
•  » » 8 дней назад, # ^ |   0 Really! was E that easy??
•  » » » 8 дней назад, # ^ |   -8 at some moment during solving I just realized that placing zeroes goes to unique table, then submit, then "LOL why it is E?"
•  » » 8 дней назад, # ^ |   +8 E isn't that easy if you don't intend on finding a pattern. But anyways, agreed.
•  » » 8 дней назад, # ^ |   -37 True!!
 » 8 дней назад, # |   -6
•  » » 8 дней назад, # ^ |   0 for that, you need to be in the same room as your alt which is close to impossible. This is only possible in the educational round where there is a separate hacking phase.
 » 8 дней назад, # |   +37 Random fact: B can be solved in $O(n*|\Sigma|)$ using dp on suffix automaton (code). This approach can solve the problem even if $n\leq 10^6$.
 » 8 дней назад, # | ← Rev. 2 →   0 My code for B. It is most likely to get MLE in SysTests. Can somebody say, why the memory usage has skyrocketed?UPD: It passed :'). Still, can somebody tell why the memory usage has skyrocketed? I have used simple brute force.
 » 8 дней назад, # |   +12 While I'm practicing problems with difficulty 2500, it's very sad that I couldn't solve even C. I didn't have a good observation to solve D either. Not sure what's wrong with me...
•  » » 8 дней назад, # ^ | ← Rev. 3 →   0 you are me+(300-500) cf rating. i am solving so many 2000 problem and still took so much time to solve B, but solved C just by looking at it
 » 8 дней назад, # | ← Rev. 2 →   -9 Weak Pretest in Problem 1
 » 8 дней назад, # |   -11 Problem A and C are hard to implement :)
•  » » 8 дней назад, # ^ |   +1 turns out you can just print from 0 to 100 for A if there isn't a negative element in the array
 » 8 дней назад, # |   0 118650415 why TLE? Problem -: B
•  » » 8 дней назад, # ^ | ← Rev. 2 →   0 Although you know that it will run at most n time for any string (worst case: consecutive subsequences) but there's still some additional calculation in the loop so you need to break all the outer loop after you have found the answer.
•  » » » 8 дней назад, # ^ |   0 I just added a break after checking a single character if the ans is present and it gave accepted ... its worst complexity is still O(26*26*26) . How it is possible?
•  » » » » 8 дней назад, # ^ | ← Rev. 2 →   0 unnecessary loops for each test case are huge when you don't break after you have found an optimal solution.
•  » » » » » 8 дней назад, # ^ |   +1 And if there is a huge test case with answer of 3 characters then? will it no give tle? Btw thanks for helping
 » 8 дней назад, # | ← Rev. 2 →   0 How to approach slightly modified problem C, if it is asked to find the number of ways to split such that the ratio (D/K) should be the same?
•  » » 8 дней назад, # ^ |   +4 if I understand your question correctly, isn't it just $2^{ans - 1}$ for each prefix?
•  » » » 8 дней назад, # ^ |   0 Ok, that's right.
 » 8 дней назад, # |   +10 very nice problems! E was unfortunately very proof-by-AC-able, but the actual induction proof is super clever
 » 8 дней назад, # |   0 Dang, I feel like an idiot. When solving A, I didn't realize that the version of Python 3 on the server only supports the 2-argument version of math.gcd(). It took me 17 minutes and 7 wrong submissions to debug this simple error.
•  » » 8 дней назад, # ^ |   +24 One more thing to add here. CF states that it is using CPython version 3.9.1, but if you run import sys print(sys.version) you can see that the actual version is 3.8.1. The updated feature to math.gcd you wanted to use was added in Python 3.9. So I'd argue CF is definitely at fault here by mislabeling its version.
•  » » » 8 дней назад, # ^ | ← Rev. 2 →   0 You're right. MikeMirzayanov please fix the Python 3 version label or update the installed version so they match.
 » 8 дней назад, # |   0 When will the ratings be updated??
 » 8 дней назад, # |   +9 Idea for E:Fix which #s turn into 0s.All other numbers are uniquely determined. Imagine a multisource BFS from every 0. The value of a certain cell is simply its distance to the closest 0.Answer is 2^X, where X is the number of #s (Edge case if there are no 0s in the original matrix. Then the answer is 2^X-1).
•  » » 8 дней назад, # ^ |   0 Can you explain to me how is the answer 2^x ? Test case like ##0 when doing 2^x that means at some time the test case will become 110 and it doesn't follow the second constraint of the problem, so how is it 2^x ?
•  » » » 8 дней назад, # ^ |   0 For your input the answer is 4, and 110 doesn't appear: 210, 010, 100, 000
 » 8 дней назад, # |   -8 I had written correct logic for Problem C during the contest but it was exceeding time limit just because standard print method of Java was not fast enough for the given constraints. Isn't it unfair for non-C++ coders !! The constraint of 2 * 10^5 is carefully chosen to avoid these language specific problems and is widely used. I wonder why it was not considered during the testing phase!! :( golions
•  » » 8 дней назад, # ^ |   +6 We have model solution in Java. In the future I recommend that you use StringJoiner or StringBuilder when outputting a lot of numbers.
 » 8 дней назад, # | ← Rev. 2 →   0 how can the last output for this test test 1 9 KKKDDKDKKbe 2 ? you cannot even divide a string of length 9 in 2 equal chunks .
•  » » 8 дней назад, # ^ |   0 [KKKDDK] and [DKK] ratio is 1/2
•  » » 8 дней назад, # ^ |   0 You don't have to equally divide the chunks.
•  » » » 8 дней назад, # ^ |   -7 then why is it written this ? Both brothers act with dignity, so they want to split the wood as evenly as possible. as far as i understand english " Even distribution " means equal distribution of something . Thanks to the problem setters you guys have written some beautiful problem statemnts .
•  » » » » 8 дней назад, # ^ |   +4 It is crearly explained afterwards that ratios should be equal, not exact numbers
 » 8 дней назад, # |   0 https://codeforces.com/contest/1536/submission/118611087 never thought that I would fail in brute force can there be new rating category named 'noob' for people like me :)
 » 8 дней назад, # |   +20 Problem E is virtually equivalent to 2013 USAJMO Problem 2: https://artofproblemsolving.com/community/c5h532231p3041818
 » 8 дней назад, # |   0 Hello everyone! Can anyone explain to me why in problem E the answer does not depend on the shape of the lattice region (#)Всем привет! Кто нибудь может объяснить мне, почему в задаче E — Омкар и лес ответ не зависит от формы области решеток(#)picture/картинка
 » 8 дней назад, # |   +24 To not keep you waiting, the ratings updated preliminarily. We will remove cheaters and update the ratings again soon!
 » 8 дней назад, # |   +1 I will be green again once cheaters are removed :) . Just 1 point away from being green again .
 » 8 дней назад, # |   0 WILL USING PRIMES FOR C WORK OR WILL IT GIVE TLE?
 » 8 дней назад, # |   +5 road to purple!!!first milestone reached, feeling fucking A. Lets go !!!!
•  » » 8 дней назад, # ^ |   0 yo same! good luck man, I'll see you in purple :)
 » 8 дней назад, # |   0 Isn't "aaa" lexicographically smaller than "ac" according to rule 2 from Problem B. Can anyone explain why this is not correct?
•  » » 8 дней назад, # ^ |   0 It has more characters
•  » » 8 дней назад, # ^ |   0 But it's longer than ac, in the problem it needs the shortest one.
•  » » 8 дней назад, # ^ | ← Rev. 2 →   0 Because in statement it is said that: "The MEX of the string is defined as the SHORTEST string that doesn't appear as a contiguous substring in the input." So mex is string of length two, and if there are more than one string of length 2, that sutisfies the condition of mex, than you should pick the lexicographically smallest among those(of length 2).
•  » » » 8 дней назад, # ^ | ← Rev. 3 →   0 I guess I was more focused on the lexicographically smallest part and missed the shortest Thank you.
•  » » » » 8 дней назад, # ^ |   0 You are welcome
•  » » 8 дней назад, # ^ |   +13 btw if it was based on lexicographically smallest, the answer would always be a prefix of the infinite string: aaaaaa.... lol
 » 8 дней назад, # |   0 Problem E Explanation shows Math Processing Error in Major Browser like Edge, Chrome or Opera. How can I get rid of it?
•  » » 8 дней назад, # ^ |   0 Try Firefox!
 » 8 дней назад, # |   0 Problem B : 1536B - Prinzessin der Verurteilung Prinzessin der Verurteilung of Codeforces Round #724 (Div. 2) by hu_tao significantly coincides with this HackerEarth Problem:
 » 8 дней назад, # |   0 Can anyone tell what is the best method to generate strings like a,b,c.....z,aa,ab,ab.....az,ba,bb..... and so on in problem B and store in a vector? What is the easiest method? Please share your piece of code.
•  » » 7 дней назад, # ^ |   0
•  » » 7 дней назад, # ^ |   +3 wasn't able to solve this problem during the contest but after the contest I search for this and luckily found this beautiful way to generate all substring and solve this problemstring MEX(string s,int n){ vectorsubstrings;// will store all substring in sorted order substrings.push_back(""); while(true){ vectortemp;// stores all substrings generated in this iteration for(auto c: substrings){// iterating over all subtring for(char i='a';i<='z';i++){ string str = c; str.push_back(i);// adding a,b,c one by one to generate new subtring temp.push_back(str);// pushing in temp to use it on next iteration if(s.find(str) == string::npos){ return str; } } } substrings.swap(temp); } return "";}Example to understand clearlyinitially, substring contains an empty string we are adding a,b,c...z, one by one to "" and pushing back to temp so temp contains {a,b,c,d.....z} now swap temp and substring Now substring contain {a,b,c,.....z} here the magic happens Now you will extract a (first element) and again add a,b,c...z, one by one so the new substring becomes aa,ab,ac...az you will do the same thing for b,c,d....z so Now temp contains all subtring possible with two charHope you understood it
•  » » 7 дней назад, # ^ |   0 Check out the increment function in the my submissionIt just takes in any random strings and make it work like a counter.
•  » » 7 дней назад, # ^ |   0 I use recursion: 118607108
 » 7 дней назад, # |   +3 Can anyone tell me the rating of each problem and the best time complexity to solve the problem New to CP, was able to solve only 1st problem also what kind of contest should I give as a beginner?
 » 7 дней назад, # |   -6 ass
 » 7 дней назад, # |   0 Please check these two Submissions for Problem 'C' :-1.) https://codeforces.com/contest/1536/submission/1186432602.) https://codeforces.com/contest/1536/submission/118699081Logic is same in both but in 1st submission, I used ratio (in double) as key and in 2nd, I used pair as key of unordered map.1st one got accepted but 2nd one is giving TLE.Please Check them ...
•  » » 7 дней назад, # ^ |   +2 Your calculation of hash of pair is poor. Do not combine hashes using simple xor as x ^ y. Use constructions like: x ^ (y + 0x9e3779b9 + (x << 6) + (x >> 2)) or x + y * 1000000007 (in this case you can use some prime number instead of 1000000007).And it pass testes: 118753875 and 118754141.
•  » » » 6 дней назад, # ^ |   0 Got it, Thanks !!
 » 6 дней назад, # |   0 This contest's sytle is so strange than others.Almost every problem I had to find the law behind the title ,it's very easy if we find the law ,but if we cann't find the law ,it's very puzzling!...
•  » » 6 дней назад, # ^ |   0 yes,that's true
 » 6 дней назад, # |   0 Codeforces is fun.