Henlo Codeforces! ^_^
I invite you to participate in Codeforces Round #663 (Div.2) taking place on Aug/09/2020 17:35 (Moscow time). The round is rated for users rated less than 2100, while other users can participate non-competitively.
The round features five problems, and you have 2 hours to solve them. There may, or may not, be an interactive problem; regardless, you should know how to deal with them.
I would, now, like to thank–
- antontrygubO_o for coordination
and manipulation. - AwakeAnay, AsleepAdhyyan, and RestingRajarshi for always listening to my problem ideas.
- BRCode for making 3b1b-style video editorials of the problems!
- Aggu_01000101, Devil, Dragnoid99, far_from_NOOB, IaMaNanBord, Osama_Alkhodairy, prabowo, taran_1407, Tarrus, Tathagat_shah, TheOneYouWant, Utkarsh.25dec, Vivek1998299, _Aaryan_, aryanc403, dorijanlendvaj, coderz189, hugopm, knightron00, kshitij_sodani, ltc.groverkss, nishkarsh, Roham, shash42, socho, talibmohd, and thenymphsofdelphi for testing!
- MikeMirzayanov for Codeforces and Polygon platforms– Polygon is truly remarkable!
Please do not mind the long list of testers (I had to write code to tag everyone here) since the problem set changed significantly after the first round of testing.
We will announce the scoring distribution shortly. The scoring distribution is 500–750–1250–2000–2750.
Good luck, and stay safe!
UPD: Editorial
Here are video editorials by BRCode:
UPD2: Finally, congratulations to the winners!
Div. 1:
Div. 2:
As a tester I think people will like this round because of interesting problems,diverse topics and short statements
Also (as a tester) wants contribution :)
So that was a f***ing lie (about "as a tester")
I meant kshitij_sodani, not me. I guess people got confused and downvoted me.
Understand, have a great day!
Sir on CodeForces never make the mistake of arguing with a person who has higher rating. I've been burnt before.
Ratism...
I literally just told you not to do this smh
I didn't argue with you smh
I've heard myths like If you are div 1 , than the number of div 2 guys you've roasted is (your contribution)*(1000000000 +7) , is that true
It's actually 998244353
I guess its bad news for el_heffeh then
Time to lose contrib :)
thanks, I see a lot of orange here in the group.BTW what's polygon, I read it in every announcement
MikeMirzayanov for Codeforces and Polygon platforms– Polygon is truly remarkable!
Polygon in basically the platform for creation of programming contest problems. It also supports problem statement writing, test data preparing, model solutions, judging and automatic validation.
how can i increase my rating
Just after reading SleepyShashwat I am feeling sleepy
As a tester... Damn there's so many of us!
OMG!!! another "as a tester" comments "/
But we can't disagree many of them gives us some useful information about the round.
blobugh , I understand the first part of your username butt why do you like 1373
Which ponies are we helping this time?
I wish none of them :(
Sorry to disappoint you, but I've tried my best to keep the statements short and purely formal.
Thanks a lot for short and formal statements :)
That's disgusting
Omg Indian round! So excited
Ah shit here we go again. Oh, wait...
Am I the only one, seeing the similarity between the names of SleepyShashwat,RestingRajarshi, AsleepAdhyyan , AwakeAnay.. UPD:one of them is odd one out
and...?
https://mirror.codeforces.com/blog/entry/72644
it will be Mathforses because you are coordinator no writing) look like stupid and interesting)
*insert cringe proud indian comment here *
I hope, we don't have to help Ponies, in this contest, unlike Previous Contest! :|
Hope the problem statements are made while you are not sleepy.
Well he was, but I made sure they are alright ;)
Memes/images should be posted in spoiler!
"
"
Disclaimer: The memes aren't specifically for this round, that's for you to decide :) I liked it a lot as a tester.
So we'll have video editorials too this time?
Yes and afaik in 3b1b style.
Looking forward to it!
:)
This will be the first official video editorials for me in CF. Looking forward to it.
orz
As a participant, all we want is short and clear statement. Hope we won't get disappointed :)
Not.Enough.Memes.
Is it just me or the meme image disappeared after 12 hours?
Props for the 3b1b style video editorials! Sounds really cool, will definitely watch.
As a pony , I hope I'll not find any problem about ponies :(
Lol
Don't downvote sir
SleepyShashwat, AwakeAnay, AsleepAdhyyan, and RestingRajarshi.
Coincidence!? I think not. ;)
How so insightful sir
Not a coincidence indeed, check this
LOL, didn't know about this.
Wow Lelouch.Lamperouge you are a brilliant archaeologist!
Thanks NewAccelWorld XD
LMAO
BRCode for making 3b1b-style video editorials of the problems!
...![ ](
I'm wondering why almost half of the recent contests, including this one, contain $$$5$$$ problems, but not $$$6$$$.
As a tester you will know why 5 is enough :)
I won't be wondering any more if I can have a chance to be a tester
Because , by excluding 1 problem from 5 contests ,they can create a new one.
Is this the quartet of last year's IOI from India?
"Henlo" ?
Here
Hopefully the ponies are grazing grass instead of playing chess coloring games with each other.
Happy to see an Indian round Again. :D
Not as a tester I hope you good luck!
Wait did I read it right that there are vedio editorials ? Cool.
How many testers do you need?
-YES!
How many pony stories do you need?
-NO!
I hope this round will not test our English comprehension skills.
lol, last one did! XD
Yes the problems were very confusing.
Why is every div2 round having 5 problems now? Is making 6 problems too hard or are you sleepy while writing problems as well?
I prefer 5 problem rounds. They have better problems.
(I had to write code to tag everyone here) : How does one write code to tag people? O.o
Oh, I meant to sort the handles, and then wrap them around [user: ] o_o.
I just realize that the names are sorted.
Did you use an
if
to add the and before the last handle? :PHope the statements are not sleepy.
As a tester i want to say that the contest is shit!!!! Thankfully i am not participating in this officially!! sighs: All the specialists brace yourself!!
Deleted:(
Do you mean advanced algorithms as you mention specialists are going to have a hard time? or are you referring to math tricky questions? or ADHOCs? 0_0
Its just because i am a specialist
Typo in spelling of Hello Codeforces Please change Henlo --> Hello
Actually not, see this.
Just have learned that few comments above.
Although your Indian English is kinda weird, but the 3B1B-style video is so fantastic!
Why am I getting a feeling that this is going to be a MathForces round? I hope it is not though! :P
Also antontrygubO_o as a coordinator (Yay! :D)
I think your 2 statements contradict each other
Oh fuck! :/
Henlo Codeforces! ^_^ I think here must be "Hello" ^_^
No, they didn't misspell Henlo is a cute puppy language style for saying Hello.
Another contest!! As a regular contestant, I need a break :'(
As a contestant, I want rounds with aryanc403 as the author
Round preparation as an author very hard. :(
I really starts enjoying memes here...
Thanks , Codeforces!!!
author, how could you misspell the word ,,Hello''? i want to cry((
Henlo is an internet term used for greeting others. It is not misspelt :')
ok but my eyes can't understand it((
They didn't misspell it. It is a cute puppy language style for saying Hello.
Did any tester test anything with Python? Did someone spend the 10 minutes checking if the standrad solution in Python doesn't get TLE or too much memory?
Advise as a community member, You should never worry about TL issues in an Anton coordinated round.
^_^
Hope the statements are clear. I don't want to walk around the maze :)))
soo, if i utterly fail to do the questions then what will happen? (my rank is 0 , will to in minus or increase if yes then how?!
If you don't have a submission then rating will be unchanged.
If you make at least one submission but solve 0 then rating may increase for new users.
Check Here for details.
Thanks , Codeforces!!!
As a tester I think people will like this round because of interesting problems,diverse topics and short statements. Thanks, Codeforces!!!
SleepyShashwat please don't sleep during the going contest
Relax, there's AwakeAnay
Happy to see Indian School Students doing great on Codeforces and other CP Platforms! I wish, I also knew about CP while I was in School. Indian Students need to learn that "Apart from IIT JEE, there is also a world called CP". All the best SleepyShashwat for your future endeavours!
Awwwwwwwww, Were you not able to clear JEE, you poor soul
Poor Soul thinking that only a JEE Failure would write that statement. I think you are in the First Year of an IIT or you are not an IITian. Only some First Yearites(Fachas) at IITs have this attitude that they have cleared JEE and won the world OR this attitude is shown by Butt Hurts who couldn't clear JEE Advanced!
What if i say i am in third year in an IIT ? What shitty explanation will you give then ?
In my college "fachas" or first years, whom you are saying shit for no reason, are better than you in CP.
I have seen people mention IITJEE many times before . So , does this university conduct some kind of computer science competition like I.O.I. , because I have seen it quite a few times like on this blog , Indian contest blog , cheater blogs and some ICPC blogs .
Its a rare thing for universities getting mentioned so it kind of made me curious
The only reason i am offending you is you tried to offend those students who busted their ass in getting a f***** IIT after like 2 years of rigorous studying ( maybe 4 years for some ) and you are into CP for like one year and still nowhere with CP ( to be honest ).
I am also in the third year. And to be honest, you can check my submissions, I only gave contests till December last year. Many first years are better than me in my college also. They are Masters and it happens in all IITs I guess. I know I am nowhere in CP and it doesn't even matter to me. And what I have tried to say is there is a world apart from JEE also- for those who couldn't clear that! We also do CP only to get Jobs in MNCs and they also! I also spent 2 years in rigorous studies and I know that situation. And for your kind info, you are wrong even at judging my "Special and Reserved Community" LOL!!! It is just that some need more time doing CP some don't need that. Some do CP continuously and daily while some don't practice that much and I belong to the second one. I don't practice that much because everyone has different priorities. CP is a backup for some to enter the software/IT sector. They may want to do something else like Management, Civil Services, etc. And there are many such IDs on Codeforces- belonging to IITians, a general category and Pupil/Specialist. So, keeping all factors in mind stop judging people! And for your kind information, study for Internships rather than trying to offend me! And I didn't call first years SHIT. It was you who misinterpreted it! I just said they have that kind of feeling in mind in first years. But second-year onwards they know the situation :P.
or he might have cleared JEE
I cleared JEE but wish I'd rather got to know about CP back in school. I have been good at programming since I was in high school but thanks to the JEE culture in India I never got to know about cp.
Whats worse, I got to know about cp only in my third year and I have only 1 year in my college life left now. Honestly if i could go back in time, I would tell my earlier self to do CP rather than jee.
What is IIT JEE ? Is it something on the lines of web development or something like that
it is the exam conducted to select students for studying in the most prestigious colleges of india (IIT). and no, u need to learn physics, chemistry and maths to crack the exam and secure the highest ranks possible to take up computer science(which is one of the many streams taught in an IIT).
So are students not aware about cp or they choose not to pursue it
I feel very sorry to say that but the education system in India is totally weird. I hear the word "CP" just some months before(after going to college). When we were in standard till 10. We have absolutely zero knowledge about programming(and we taught in school is totally theoretically especially in CBSE Board(I am from CBSE). In countries like Russia, people start programming in a very early age. They have much more knowledge than us. (Prooving my above statement, Currently there are only 7 red coders from India despite having the largest number of active members in Codeforces(almost double than any country).I am from India, and I really feel for it!!!
you mean that we have not started cp early, so we are not talented as other country's people?
Yes, this is the only reason I can think of!
Thank you.
Score Distribution?
where is editorial for this round?
What do you mean? The round hasn't even started yet...
here
UPD: lol. 7 people got rickrolled :))
Auto comment: topic has been updated by SleepyShashwat (previous revision, new revision, compare).
very excited for round.
Very excited for the indian round :)
woweeeeeeeeee! 3Blue1Brown style editorials.
Half of the coders are giving Goldman Sachs aptitude test now lol
Is it necessary to post it here ?
Just felt like posting man. Everyone posts irrelevant memes, so why not this. Anyways, I apologise I said something wrong.
That's true about irrelevant meme. But what I am saying here is we should try to avoid posting irrelevant stuff here. Is someone is committing some mistake, it doesn't mean that we should also right ?
I can't understand what 'even length square sub-matrix' means in problem D.
Does it mean a sub-matrix with even width and even height?
Thanks
@SleepyShashwat
A binary matrix is called good if every even length square sub-matrix has an odd number of ones.
It is described in the sample explanation below the testcases
Problem B was too easy , should have been a little harder...
After solving A and B what should be the best thing to do?
Rest, I guess.
Looking at the scoreboard hahaha
leaving
Solve C.
Solve Problem C. XD
Me after solving A and B :-)
Permutation lover SleepyShashwat
From today, I started loving permutations because no one knows how you can play with permutations except the master SleepyShashwat. Truly a good and well implementation based round. Only DS can help :)
That's right! Only DS007 can help make future contests better!
The problem statements were really nice :) But the difficulty could have been a bit higher for C.
I havent studied graph theory till now sad.
there is nothing to do with graph theory for c
C is perfect. Intuitional.
Determine if the contest is good?
If Tx is the number of people solved task x, then the contest is good if Tj < Ti for any j > i
For now, 13045 — 12108 — 5115 — 1169 — 61.
My JEE notes help me in solving question C
JEE?
In india this exam is to get into engineering colleges.
Now this is what I call a Contest. loved it. Kudos to the author.
Nice problem set! A good round after a long time :)
Waiting for the end of the contest to start discussing the task E
PATH: if diameter of graph >= (n+1)/2 ^)
PAIRING: if otherwise, but how to construct?
Do dfs. In dfs tree if there is a path from root to any leaf with length >= (n+1)/2 we have solution PATH. Otherwise we pair nodes at same depth/level in dfs tree(because in worst case we won't pair only one node at some depth and from first check depth of the tree < (n+1)/2 so we will lose at most n/2 nodes during pairing which is valid).
Root at any node. Find a dfs Tree.
If the height is >=N/2 you have a path. Otherwise pair nodes on the same height.
Nice contest, too bad I wasn't concentrated enough :(
2 minutes of silence for these people.
Do you mean problem C? D didn't have issues with mods
Changed.
or
Thanks to Errichto
In case someone wants the link, https://www.youtube.com/watch?v=-OPohCQqi_E
Solution of C:
https://oeis.org/A059204
:( I recognized how to solve it that permutation must have at least one dip but was not able to generalize the series. Thanks for OEIS link.
Pretest 6 For Problem C ????
negative number modulo
print answer modulo
(ans%mod+mod)%mod
;)My solution got negative answer for n=100
You getting WA because sometimes (n!)%mod < (2^(n-1))%mod. You need to add do (ans+mod)%mod
Such a nice D!
What's the pretest 3 for problem D
I think some n=3 and m=300000.
Hmm, but I am not getting what I am doing wrong
I liked the problemset.
How to solve D? (I had understood that for n>=4 and m>=4 the answer is -1, but I don't understand what to do next).
Since $$$n \leq 4$$$ you can do dp[i][mask] in O($$$m * (2^{n})^2$$$)
"mask" means the type of the square?
oh, I should have thought about dp :( nice problem but.
n<=m so you don't need the min and max functions.
Thanks, I guess I need to read problem statements more carefully.
Oof, wasted 10 mins altering it to work in the case where m < 4 and n >= 4 without seeing this.
everybody got that part but man how should we place greedily anyone ??
I don't think that it's possible to do it greedily.
that's why I wasted a lot of time next time I will make sure when dp is possible just apply it.
how to solve C please help??///
n!-2^(n-1) is the answer.
why?
number of permutations is n!. And you have to count how many permutation of the form (2,1,3) do you have because that gives you a cycle between 1,2,3. (and 3,1,2 too). The permutations which are not from this type is 1,2,..n (increases) and after n decreases. And that number is 2^(n-1).
(with 2,1,3 i mean some v[i-1] > v[i] < v[i+1] not just 2,1,3)
Didn't the question asked to find the total permutations of length given n? For n=4, is [4, 2, 3, 1] having length cycle of length 4?
As per the definition given, vi and vi+1 share an edge for all i (1≤i<k), and v1 and vk share an edge. v1 to vk edge is only possible either of 2 cases 1. n-1 at position and n is at last position 2. n is at first position and n-1 is at last position then only we can form a cycle of length n right? Correct me if I am wrong somewhere.
I agree but i can`t see your point. 4,2,3,1 has a cycle of length 3 so i don't care if has a cycle of length 4.
Sorry I misinterpreted the question.
From the statement, "Given n, find the number of cyclic permutations of length n. Since the number may be very large, output it modulo 109+7.". I thought, we need to find permutations whose cycle length is n.
Total permutations = n! Permutations without cycles = 2^(n-1) I'll explain how I got 2^(n-1): For any permutation, if there is no cycle in it then it should follow this logic: 1)For any i,(1<=i<n) numbers i+1,i+2,i+3,... n should lie on the same side, if not then the permutation contains cycle. Then start calculating the ways by following this logic. Eg: for n = 4 You can put 1 in either of the ends.(because all other numbers should be on same side of 1) Then 2 possibilities: 1--- ---1 (you have to fill blankns with 2,3,4) Now, 3&4 should be on same side of 2, so, our possibilities are now 12-- 1--2 2--1 --21 .Recursively this gives 2^n-1 ways.
Use simple permutations and combinations and the principle of inclusion and exclusion :)
A very nice contest!! Problem statements were short and to the point.
People with WA/RTE/TLE on A. Care to explain your soln?
Congrats Beta_R for getting hacked on A twice.
maybe Levon2004 can shed some light on this
iches uzum aber?
1 77
1 6 4 RRRR RRRR RRRR RRRR RRRR RRRC
1 57
AnandOza
I have a feeling that it was done on purpose to gain hacking points.
Yeah, they have an if statement to get hacked lmao: if(TN==1 && n==57){
Yeah It was done on purpose. Levon2004 has hacked both A(twice) and B with the same technique.
asgardianadhi я просто смотрел решения и увидел что решения Beta_R неправилный и взломал специально нечего не сделал
how to solve D? I found it really hard to find answer for min(n, m) = 3 because there were too many states
Yeah I also got stuck in that case. Waiting for the editorial!!
there are only 4 states. 1)from {(000), (111)}(consider which of these two require min change) to {(010), (101)} and visa-versa. 2)from {(100), (011)} to {(001), (110)} and visa-versa. check this
Has the core idea behind C appeared in a contest in the last year or so? I remember solving a problem which had the same idea (sequence must increase then decrease, find number of ways) not too long ago.
3blue1brown styled Video Editorials:
Problem A+B: https://www.youtube.com/watch?v=KJVigs8w-gg
Problem C: https://www.youtube.com/watch?v=vWHUmtiPRQw
Problem D: https://www.youtube.com/watch?v=kspzot42-uI
Problem E: https://www.youtube.com/watch?v=y62jjZev3pY
Not all heroes wear capes
problem D:
if the matrix is 4 by 4 or greater size answer is -1. and for smaller matrixes, we need to get the answer?
where I went wrong please help me?
so far so correct but real question starts after that if you don't want to brute force every case.
can we solve D without brute-forcing every case separately?
I think we can XOR the bits (0s and 1s) and come up with a simple approach for dp. I couldn't do it in time though.
if(n>=4) must -1 so we care of n<=3
What should be the states for n==3 ?I couldn't figure it out.
all 1 <= e <=m , arr[0][e] * 4 + arr[1][e] * 2 + arr[2][e] can make the bits. then we can use dp to solve the problem. build the array dp[length][8]
I brute forced for n = 6 and m = 3 and my pc crashed.
Problem D: Am I right in thinking that if the no. of 1s in every 2X2 matrix is odd then no. of 1s in every 4X4 matrix will be even hence answer is -1 for all the matrices with n and m >=4? OR am I missing something. If I'm right, then how to go further?
No that's correct, but the hard part is doing the dp for the min(n,m)=2/3 cases
Shame on me for not reading the problem properly. I didn't read that only 'R' and 'D' were valid directions for problem B, so I implemented something way more complicated to deal with all 4 directions cardinal directions XD.
Maybe this will help you fell better but you are not the only one :D
I started implementing the solution with all directions, after about 10 minutes I saw that there was more than 2K Accepted solutions so I knew something was wrong, read the full statement again and solved it in 2 minutes :(
the intresting fact about this contest was that nobody knew the proof for problem C but everyone solved it :))))
I saw that you can have a cycle iff you have a "dip" in the sequence. 95% sure that that's correct, so then I tried to count every permutation without a dip and saw that for every n, it was double the previous one. You're right, no actual proof though!
The permutations that don't work are ascending and then descending. The number of them is the sum of (n-1) choose k from k=0 to n-1, and it's well known that it's equal to 2^(n-1). So the answer is n!-2^(n-1).
One way you can see why it's the sum of n-1 choose k from k=0 to n-1 is that you have a 1-1 correspondence between subsets of {1,...,n-1} and a not good permutation because you place all the numbers in your chosen subset to the left of n and then the remaining to the right of n (there is only one way to arrange these two subsets). Or you can just think of it as there being two choices for each number, being on the left of n or the right of n.
Non-valid permutations are the one which first increases then decreases, rest all are valid, and number of such permutaions are $$$2 ^ $$$ $$$(n - 1)$$$. So ans is $$$n!$$$ $$$-$$$ $$$2 ^ $$$ $$$(n - 1)$$$
Problem C was really awesome and the statements were also quite perfect...
Isn't the answer to C is
fact(n) - 2^(n-1)
???Yes, it is!
Can someone please see why my solution to C failed on pretest 6 ? My answer is also
fact(n) - 2^(n-1)
?Link : https://mirror.codeforces.com/contest/1391/submission/89453457
when fact[n] < 2^(n-1) you give a negative number. you have to add MOD and then apply %MOD again.
Yes...But there is modular arithmetic..
Nice problemset. I think D can be done by bitmask dp, correct me if I am wrong.
Really nice contest! D was the first dp problem I've done in contest in a while.
Solution for D: If n>=4, the answer is -1. To see this, note that each 4x4 matrix is broken up into 4 2x2 submatrices that are disjoint. If the sum in each of these is odd, then the sum in the 4x4 matrix should be even, which is a contradiction.
Now, we do cases on n=1 to n=3.
For n=1, there are no even sub squares, so the answer is 0.
For n=2, each column alternates between a sum of 1 or 0 mod 2, so theres only two cases to check here (whether the first row has sum 0 mod 2 or 1 mod 2), and that can be done in O(m).
For n=3, you can use dp. Let dp[i][j] be minimum number of moves needed to get the first i columns to satisfy the problem constraints, with the ith row equal to j in binary (so, for example, if j=5, then the ith row would be 101). Then, dp[i][j] = min(dp[i][j],dp[i-1][k]+add), where k ranges from 0 to 8 and is the state of the previous row, and add is the number of moves to change the grid ith row to j in binary (so it would be 2 if the ith row was 000 and j=5 = 101 in binary). Answer is min(dp[m-1][j]) from j=0 to 7, and time complexity is O(m*4^n), but n=3, so it passes. There might be a more efficient solution.
I think we can construct 4*3 matrix. I have constructed a 4*3 matrix in my copy?
N <= M
Thanks for such a nice contest!
We want more such contests :)
E is a nice problem
Idk if I'm dumb, was anybody else confused with the "Cycle of length n", for n = 4 there weren't 16 cycle of length 4. Although there were 16 perms. which have cycle.
My solution for problem C failed on pretest 6 using C++. Later, I changed it to python and it worked. Can someone explain why?
(Did n!-2^(n-1))
C++: https://mirror.codeforces.com/contest/1391/submission/89438077 changed to: https://mirror.codeforces.com/contest/1391/submission/89443077
because (fac-ans) can become negative
(a — b) % m = (a%m — b%m + m)%m
Nice contest, math lovers for the win. I go back to Div4.
Lol
Most of em just AK'd problem C with OEIS!
But it still felt like more or less fair math, at least.
I am so used to seeing your name in blue that it feels weird when it is cyan.
Thanks for your support ;)
no problem i believe that u can get whatever you lost within one contest..
Yep
A — trollforces
B — observation?
C — math
How to calculate modulo inverse efficiently ?
Calculate $$$n^{mod-2}$$$ (if $$$mod$$$ is prime)
Only if it's a prime (usually it is).
If it's not you use extended euclidean (I didn't mean to counter what you told him, but imagine he will be in a contest in the future and he needs inverse modulo not a prime, he will want to kill himself XD)
Thanks for correcting my mistake XD I missed that.
Did you solve problem C with it? I tried to solve it using the binomial coefficient but I had problems with dividing and keeping it modulo. Is this modulo inverse commutative for multiplication, it doesn't matter in which order you multiply?
It looks like it works, but was just a bit too slow (in Java) using modular exponentiation. Thanks, am going to look a bit more into this, looks useful.
I optimised it a bit and it barely passed.
I used BigInteger class at the time of the contest to calculate it but the method is too slow
My solution to C —
tn = (n-2)(n-1)!+2*tn-1
Problem C makes you fall in love with CP all over again. Concise and to the point statements. Great round :)
C is in oeis but i cant just implement it.
Excellent contest; I really enjoyed solving the problems! Here's my screencast and solutions to everything if you're waiting for the editorial.
Well particularly, I was waiting for your editorial. Nice job as always.
You're videos have helped me a lot. Love the way you talk through your thinking process even during the contest. Please Don't stop doing this :)
Very Nice, It looks like an educational rounds format (i.e: the statements are formal)
For a moment while reading C , I thought the edges are directed and wasted like 10 min on so, But still I think that this version would be interesting one I would really appreciate ideas on this version of question if solvable
Another high quality contest. Codeforces back in form.
Damn. In problem D I figured out very quickly that n<=3, but then I thought it's greedy after that, and now I see people solved that part with DP! And now it seems so obvious I want to bloody kill myself :<
Me too.
I can't agree with you more...
I solved D with greedy https://mirror.codeforces.com/contest/1391/submission/89444320
shame for copy&pasting code a lot because I was in haste
My opinion might be unpopular but I think the formula wasn't too hard to guess.. I came up after an hour into the contest but still I spent 15 mins trying to prove it.. and I couldn't prove it.
It would be better if the formula for the problem is harder to guess from samples else it beats the purpose of the problem...
I mean for problem C.
Which problem are you talking about?
problem C just edited my comment above
Agreed. Just a little thinking gave the formula automatically.
For problem A, How can any permutation work?
Like for n=5, 1,2,3,4,5 can be called as any permutation but does not work for index 1 to 2.
2^3 = 1 whereas length of the array is 2.
I just could not grasp problem A.
It's not XOR it's OR
It's OR not XOR. Man I feel do bad for you if you thought it's XOR!
Can any bide tell whats wrong with my d solution?
Most probably, the relation for dp[j][4].
OOO thanx! i will upvote you with all of my acs : )
l-l-l-l-l-l-l is one of those accounts.
Problem C was really fun, and in general the whole round was great! I loved reading and thinking about all the problems!
Can you please tell how did you approach C?`` Like did you see a pattern or used oeis?? I want to know how good coders approach such problems
Well, first I thought about what happens with the ID permutation (i.e 1 2 3 4 5..), and I saw that there are no cycles. Immediately I concluded that that the reversed also has no cycles (5 4 3 2 1). Then I tried to make one inversion, such as 1 2 4 3 5, and saw there is a cycle and then I thought that maybe any inversion might mean a there is a cycle, but then I tried to put the max in the middle, and my first example was 1 2 5 4 3. I saw it has no cycle, and that's because 5 has no one larger than him anywhere. Then I thought I had it, I checked 1 2 5 3 4 to see it has a cycle, and of course it did. (because of 5 3 4).
My conclusion was that any "mountain" structure has no cycles, mountain means that for i < j a point p_i < p_(i+1) and for i >= j, p_i > p(i+1).
I proved it to myself briefly by saying that if it isn't a mountain, then there is a "Valley", and a valley is just a triplet (a,b,c) where a > b < c (for example 5 3 4), and that creates a cycle!
So then it became counting the number of "mountain" permutations. The peak of the mountain must be n (the max value in the permutation), and if you choose a subset of elements to be on its left (and the rest on its right), there is only one way to place them — non-decreasing on the left of him, and non-increasing on the right of him.
So you just need to choose the subset of elements to the left of 'n' out of the n-1 remaining numbers. The number of different subsets of n-1 numbers is 2**(n-1).
And the solution is (n! — 2**(n-1)). Of course you calculate both those value modulo P through out, and perform the modulo operation after the subtraction.
Thanks a lot!
Excited for the 3b1b style video editorials
Auto comment: topic has been updated by SleepyShashwat (previous revision, new revision, compare).
the problems are very good!
Solved div2C for first time but doesn't feel like an achievement because formula was too intuitive I think.But still enjoyed the contest
what was intutive about that?
Sorry if I hurt anybody. I was just saying I don't know how I came up with it and after reading the comments, I thought that the formula was pretty obvious:)
Congratulations! Not that intuitive. The problem was solved by less than 1/3 of the participants. And there were over 13,000 participants.
What this means is that you are improving! Treat yourself well!
Well, thank you:)