Hello Codeforces!
We, the disciples of Omkar (qlf9, Tlatoani, MagentaCobra, 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:
antontrygubO_o and isaf27 for coordinating this round and helping us improve our problems.
Our testers, 244mhq, Monogon, Keshi, czhang2718, HackerMonk, Ari, wxhtzdy, 2020akadaver, smax, PurpleCrayon, AmShZ, FieryPhoenix, Jellyman102, namanbansal013, SlavicG, bWayne, Qualified, kassutta, and H4ckOm. They were great testers so they definitely deserve the karma that they will surely be begging for in the comments.
MikeMirzayanov for creating the Codeforces and Polygon platforms.
Omkar for creating the world and the human race.
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!
As a tester, Omkar orz!
The best part is that this roughly translates to Om Namah Shivay because Namah literally means to bow. Omkar orz!
Why so much reverence to Omkar? I mean I am just curious. You people aren't even Hindus(ig).
One of the problem setters' name is Omkar: qlf9... And he is an American...
Oh. That makes sense.
Hope you all enjoy our problems :)
qlf9 Omkar orz
May Omkar be with you!
CODEFORCES VERSION:
May Omkar bless good ratings on you!!!
As a tester, I must say problems are really interesting !! All the Best :)
As a participant, I must say please tell me something new.
Meanwhile Negative delta : I am coming to you tonight
After System Testing, "Virtual Contest and Practice Mode" : You could not live with your own failure. Where did that bring you? Back to me!!!
Interesting problems.
everyone click the Omkar 3 link
I'm still thinking that you all guys know Hindi ?
Nope! I don't even know C++
Hail Java XD
yo walnut
Very quick scoring announcement!
Scoring looks pretty balanced, gonna be a nice round!!!
When i see there are a lot rounds comming in codeforces :
It's time that these posts should use the word "Bugaboo" instead of "problem".
I was hoping for becoming Expert but now I might get demoted to pupil :(
I like this scoring distribution
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.
"Omkar and X". Here 'X' can be anything.
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?
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.
.
Lmao yep, my real name is Omkar and I’m American :P
Why the organisers are obsessed with Omkar. I don't think they even know Hindi.
Omkar is one of the problemsetter's name.
qlf9
Hope so I will be able to solve B this time
Just curious how to become tester
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 )
I love CF
fwilgi lw4
You are an example of a stupid racist !!!!!!
и почему же
I don't have much sense of humour, can someone explain what's going on?
Just take it as a normal contest
By this contest, they are promoting a video about Omkar. What is Meaning of Omkar
The good' ol 6 problem 2 hr div2 is back finally!
"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.
Yeah they should ask you to create a website :)))
Scoring looks encouraging!
God for creating the world and the human race.
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
Ok snowflake
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
He wouldn't say that he created the world and human race, right?
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"
Should I reply your comment with a fake id?
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
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!
Great job exposing your own fake account used for cheating in contests.
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)
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.
.
Omkar orz... Om Namah Shivay!
Will Omkar inspire the authors to release the Editorial eventually?
there also may or may not be rated contest so you should read all of the rules about unrated contest.
ok
you muslims are weird
ok
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
Why is this comment getting upvoted?
because it's true..ig??
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.
Sources: What is the meaning of the name Onkar?, What is Meaning of Omkar
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.
golions, Is there any way to become disciple of Omkar?
Good Luck everyone!
Hail Omkar
When a problem score is 2000, does it mean its difficulty is 2000?
I am new to codeforces. Pardon me.
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 :)
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.
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
Wrong submissions have penalties. You should consider checking on more test cases before submitting.
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. :)
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!
Hey bro finally, I submitted 3 with one wrong submission ;)
when I was chatting with you at that time I was at one :)
I personally wouldn't be surprised if someone said: "Anton did NOT reject problems for this contest!"
Was Div2 A always this hard?
nah, i consider this problem to be on div2 b/easy c level
the fact that problem statement is written so bad makes this problem even harder
It wasn't that hard especially if you look at the constraints, which made it quite easy to implement.
The problem statements should rather be considered as riddles.
i still don't have Diluc and Fischl..ehe..maybe that's why i still fail to solve their problems
Very true, now my tongue has well-defined six-pack abs after going through these tongue twisters.
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
supahotfire CM perf orz
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.
Edit: nvm it was bullshit
if there is one negative number the difference will still be positive since we are taking absolute value
If there's one negative number and a positive one then you will have to infinitely add new numbers
It seems all of our submission where finaly AC. Congrats to your nice delta!
Yup :D Congrats to you too
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.
Yeah I just realized it sorry XD
Thanks problem B for negative Delta :)
First task was pretty hard for div.2 ( Thanks for your time spent for making a contest)
participating today was a bad idea
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.
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.
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
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.
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.
The issue is that the continuous groups can have different sizes.
Can you provide a testcase on which my code would fail?
Something like this
DKDDKK
It gives 1 1 1 1 1 1. Isnt this correct?
Nope it should be 1 1 1 1 1 2
No, the last one is a 2, since we can split in first two letters, and last 4 letters. Both have ratio 1:1
Hmm, I used ur approach in the beginning and the following testcase did not work: 1 9 DDKDDDDKK
The answer should be 1 2 1 1 1 1 1 2 2
How is it 2 at the last place? Shouldn't it be only 1 group? Or am I missing something?
DDKDDDDKK can be split into DDK and DDDDKK and both have 2:1 ratio.
Ohh, my bad. Got your point thanks!
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.
I don't think so, none of the powers of 2 modulo 1e9 + 7 has value equal to 0.
Can't believe 3k people solved C
It was easy. Just needed to notice then ratio of D/K remains same as the total. After that its just binary search.
A safer approach than doubles is to store a pair <x, y> 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
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.
Its a pretty common idea that has appeared a lot
Can you please give one of those links?
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 Subsequence
Sed Passwords
There 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.
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
I don't think that C was 3k easy. Something else is going on.
Hello,bro,may i ask how to solve Problem C ? Actually, i don't know the reason why i get wrong answer , :(
If 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$$$.
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.
segment tree is very indian
I thought of following approach but could not implement, could someone tell if how to implement if their solution was similar :
I 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.
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.
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 ?
Even I tried to do the same but got WA on Pretest 2. :(
118652416
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.
Create a map<pair<int,int>,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.
**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.
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.
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
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!
Well, Problem E seemed really difficult at first. But the solution is merely two lines!
Count the hashtags. Count the Zeros. Calculate $$$2^{hashtags}$$$ and subtract $$$1$$$ if there are no zeros. It is done!
Imagine 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. :)
How to solve E ?
I didn't submit since I was too late, but my solution got the samples correct.
I 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
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.
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??
No
No, it won't.
You submitted, but got 'Compilation error'. It will affect your rating. Just look at rainboy's contests.
too many redudant statement, can't understand problem C :(
segment tree is very indian
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
meet a new cheater This is how Master_Jiraya 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 Master_Jiraya 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--;
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.
Can anyone give some hints for D?
Whenever you add the two new integers, you have three options.
Try to think of the situation where the answer would be "NO".
How can https://mirror.codeforces.com/contest/1536/submission/118604068 solution pass if the question doesn't say we can remove the element?
Which element is removed? All the required elements are present.
the negative one's
When the
neg
flag is on, the output isNO
.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
if (neg) { std::cout << "NO\n"; }
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.
Genshin Impact Round #001 (Rated for Div 2)
In C I somehow thought I should split the prefix evenly which waste a lot of time of mine :(
Strong Pretests !! :|
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 ??!!
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.
;P nice one
Did anyone tried to solve C using sieve? My Attempt — 118650015
See this I used prime factorization 118647756
(PS: there was no need of this u can simply used gcd of count(d),count(k) )
118650415 why TLE? Problem -: B
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.EBACDF
Really! was E that easy??
at some moment during solving I just realized that placing zeroes goes to unique table, then submit, then "LOL why it is E?"
E isn't that easy if you don't intend on finding a pattern. But anyways, agreed.
True!!
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$$$.
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.
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...
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
Problem A and C are hard to implement :)
turns out you can just print from 0 to 100 for A if there isn't a negative element in the array
118650415 why TLE? Problem -: B
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.
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?
unnecessary loops for each test case are huge when you don't break after you have found an optimal solution.
And if there is a huge test case with answer of 3 characters then? will it no give tle? Btw thanks for helping
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?
if I understand your question correctly, isn't it just $$$2^{ans - 1}$$$ for each prefix?
Ok, that's right.
very nice problems! E was unfortunately very proof-by-AC-able, but the actual induction proof is super clever
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.
One more thing to add here. CF states that it is using CPython version
3.9.1
, but if you runyou can see that the actual version is
3.8.1
. The updated feature to math.gcd you wanted to use was added in Python3.9
. So I'd argue CF is definitely at fault here by mislabeling its version.You're right. MikeMirzayanov please fix the Python 3 version label or update the installed version so they match.
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).
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 ?
For your input the answer is 4, and 110 doesn't appear: 210, 010, 100, 000
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
We have model solution in Java. In the future I recommend that you use StringJoiner or StringBuilder when outputting a lot of numbers.
how can the last output for this test
1
9
KKKDDKDKK
be 2 ? you cannot even divide a string of length 9 in 2 equal chunks .
[KKKDDK] and [DKK] ratio is 1/2
You don't have to equally divide the chunks.
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 .
It is crearly explained afterwards that ratios should be equal, not exact numbers
Problem E is virtually equivalent to 2013 USAJMO Problem 2: https://artofproblemsolving.com/community/c5h532231p3041818
To not keep you waiting, the ratings updated preliminarily. We will remove cheaters and update the ratings again soon!
I will be green again once cheaters are removed :) . Just 1 point away from being green again .
road to purple!!!
first milestone reached, feeling fucking A. Lets go !!!!
Isn't "aaa" lexicographically smaller than "ac" according to rule 2 from Problem B. Can anyone explain why this is not correct?
It has more characters
But it's longer than ac, in the problem it needs the shortest one.
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).
I guess I was more focused on the lexicographically smallest part and missed the shortest Thank you.
You are welcome
btw if it was based on lexicographically smallest, the answer would always be a prefix of the infinite string: aaaaaa.... lol
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.
118612763
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 problem
string MEX(string s,int n){
}
Example to understand clearly
initially, 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 char
Hope you understood it
I use recursion: 118607108
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?
Спасибо!
Please check these two Submissions for Problem 'C' :-
1.) https://mirror.codeforces.com/contest/1536/submission/118643260
2.) https://mirror.codeforces.com/contest/1536/submission/118699081
Logic 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 ...
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.
Got it, Thanks !!
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!...
Attention!
Your solution 118628482 for the problem 1536B significantly coincides with solutions Foundnt_Alice/118625677, Believeu_us/118628482. Such a coincidence is a clear rules violation. Note that unintentional leakage is also a violation. For example, do not use ideone.com with the default settings (public access to your code). If you have conclusive evidence that a coincidence has occurred due to the use of a common source published before the competition, write a comment to post about the round with all the details. More information can be found at http://mirror.codeforces.com/blog/entry/8790. Such violation of the rules may be the reason for blocking your account or other penalties. In case of repeated violations, your account may be blocked.
I have not cheated at all and two or more person can have same approach for the above problem as it was just about bruteforcing.Neither I have used any public code or ideone.com.You can also check my other codes.Please dont skip the solutions As it is a clear coincidence.MikeMirzayanov Please look into it.
Won't the cheaters be eliminated in this round ?