Hello Codeforces,
I'm glad to invite you to our first contest Codeforces Round #684 (Div. 1) and Codeforces Round #684 (Div. 2) which will be held at Nov/17/2020 17:35 (Moscow time) . The problems are invented and prepared by AliShahali1382, Mehrdad_Sohrabi, and Mohammad.H915. The round is rated for both divisions. You will be given 5 problems and 2 hours 15 minutes to solve them. I recommend you to read all the problems :)
Firstly I'd like to thank isaf27 for coordinating and reviewing the round, as well as helping with many different things.
Thanks for our testers 300iq, coderz189, Atreus, Shayan.P, Retired_cherry, morzer, BledDest, UnstoppableChillMachine, MAMBA, prabowo, WNG for testing and giving very helpful advice.
Finally, thanks to MikeMirzayanov for very nice and convenient Codeforces and Polygon platforms.
I hope you all will find the problems interesting. I wish you high scores and good luck!
Scoring distribution:
Div. 1: (500-500)-1250-1750-2500-2500
Div. 2: 500-1000-(750-750)-2000-2500
UPD : Editorial is out.
Auto comment: topic has been updated by AliShahali1382 (previous revision, new revision, compare).
100 upvote just for update :(
I dont know why but Im ok with it :))
(
)
Sir, editorial isn't accessible. Could you please look into it?
As a Monogon give me contribution.
give me too :))
That doesn't even make sense but ok.
Would you mind if I steal this comment next round announcement
No bro
:)
Experience has shown that it always works to get contribution.
Even this comment is just for contributions:)
And this one ???
Fun posts? khkhkhkhkhkhkh
I think I must become master to get more upvotes and respects from newbies. XD lol kek wtf omg
Dahane maro saf kardi ba contribution Translate:you just want contribution it sesms you never had contribution!!
me too!
Been waiting for these guys' contest for a long time now! Hope y'all ready for a fun contest :)
AYYYY
It's time to return an expert
I became 1899 Expert yesterday just to lose the div 1 contest. FeelsBadMan
No Problem. It will be great round for you as you know...
I hope.
Hey, at least you could get a girlfriend.
I must say that this post has many truths
Now, I have one more reason to become Blue.
just needed this sort of motivation
As a student of the writers, i'm sure the contest will be good because they are geniuses.
Yeah and we are forced to participate and upvote the blog and all of the comments XD
yeah because they're teaching you to respect to older's contests
they are one year older but yes youre right. : )
sure I am. because I'm one year older than you too.
:)))
i'll see you next week
Aria 2003-2020
RIP
It is fun to participate in our seniors contest. I hope it will be good. but there is a high chance that it will be bad. Hope it wont get unrated. XD
If it get unrated you should pay us (300$) :))
there are 15 students in the class. why do you always want to get the money from me?
ok. each of you pay us 300$ :))
thats bad but atleast fair!!!
except -this-is-obd-
XDDDD
first of all they must give you pizza for the contest
they are getting the money for the contest! why should we give them a pizza??? they should give us pizza!!!
Maybe you guys should try harder for the pizza =)
are you a fan of FC barcelona?
yes.
i was also ,but after last three years it is very hard to support barca.SED LIFE
as a fan, you have to support the team to get back to its good days. given the current situation and the change of manager, I believe in this team : )
yes i also believe.visca el barca
orz
Yes
As a problem setter : Two of problem seters is fan of barca :)
Dogs are coming...
Why is Retired_cherry a tester in soo many rounds? Is he really friends with so many contest writers? Hmm.. strange
People with testing experience are often asked to be testers again.
And I am testing the rounds without asking for you know what I want.
As a tester(Don't down vote!), I think it would be an interesting round!
Do not think, be sure
you forgot to write "as a problem setter" in the beginning of your comments.
:) :)
So we have a subtask in problem A of Div2?
I guess you saw the Div 1 scoring, for us its on Problem C that we have two subtask
yeah Sorry my bad :P
No. In problem C actually.
Can someone tell me why div3 is not happening ??
what does (750+750) mean , is it its a combination of 2 750 problems or just 1500 level problem ?
it means problem c in div 2 has two parts
.
In problem D1 and D2 of Codeforces Round #671 (Div. 2).
also in last contest div 2's problem F had two versions
it always means problem c has two different situations need to be solved.or problem c should be like just (1000+500) or something else.
Good luck bruh!
I guess I should say, OMG another Iranian round!!!
IslamForces
Religion is free of CodeForce or anything unrelated to it
Wrong comment bro ,both morally and statistically
Ahsant! =)
احسنت
See you tomorrow night :)
(P.S UTC 14:35 = UTC+8 22:35)
I am really excited to see what my friends have prepared after putting a lot of effort into it :)))
I wish you write a lot of rounds from now
plz put some good easy problems for interview prep.
For Interview type Questions goto leetcode,gfg or interviewbit.
yeah bruh btw what is ur rating on codechef?
I don't know what you will do with it but anyway, 1854.
Good luck for GodForces!
−In the name of God −
Very happy to see that
god would be proud XD
I'm pretty sure god never said anything about codeforces contests... these people talking in his name... must be frustrating for him
You guys are talking about the God as a person!
that's a pity
Because he shouldn't be brought here in CF... what is the plus value of writing "In the name of God", this is literally believing without understanding
Before everything we say "In the Name of God" that's the real believing
Whatever.
Reply to your Rev.1
no one did "targeting Non-Muslim people" and it isn't what Muslims do. what you said at the first was considered offensive (at least to some people's beliefs) and what you said now...
look, it's obvious that you don't know Muslims and that's the reason you think like that
"being an honest and good person" is what a real Muslim try to be and seriously you're wrong when you say "I'm pretty sure you like to do these things to get free Hassanate" because that's not what they're doing they're just defending their beliefs without expecting "Hassanate".
I offer to finish talking about this in CF and research and read about other religions before commenting about them (not just talking about what we heard about them)
Telling people what "real believing" is. Very clever.
Did you notice that we no longer live in the Middle Ages?
Actually, there're some people still living in the Middle Ages or even before that :)
we muslims do everything In the name of god so we never forget about god and be thankful that we can do this!!!
everything?
Yup. There are even dua's regarding pissing, pooping, sex etc.
This is racism!!! If you wanna know about islam you can go research! But saying things like this is too offensive
what is the relation between racism and this? gheime haro tu masta nariz pls :<
kids pls dont come to adults conversations!
Because Islam is a race. /s
Why not put some more exclamation marks behind it? Looks super clever.
Good question
Yeah...... Again, some of the medalists of the Iranian Computer Olympiad I wish we had this again!
Why did you give a negative rating to my comment? Did I say something bad?
Laughing My Freaking A*s Off :)
Wa alaykumu s-salam AliShahali1382
we speak persian, we just say salam. thats arabic.
salam -Suto-
salam be rooye mahet.
Be cheshmune siahet =)
lol
nice contest *2
Peaceful Round !
I hope these guys would be as much good writers as they are great people and contestants.
But I hope these guys would be good writers.
I think the hardest part of the questions is to understand the statements. be ready for it!!!
Thanks to isaf27 statements are easy to understand
I am an atheist. Am i allowed to participate ?
Everyone can participate in the contest
Problem D's Title:
Rabin Carp and Allahu Akhbar
Problem E's Title:
Rabin Carp is no more
HAHA That's not funny
Is it really funny to do that???
why grey coder when comment anything gets down votes and whereas Red coders get up votes.
I have already negative contribution I am sure I will increase more from this comment as well.
because they write comments related to the blog post :)
ratism
well simply becoz they are red. that's how it goes
lol, now you ready to loose contribution.
u never know ,after all, humanity is still left in this world
I like the starting — In the name of God.
no one cares
What causes a person to be toxic?
This penetrating display of one's own faith. It's like waving your penis. Nobody wants to be bothered with it.
−In the name of God −
i am happy to see that, thank u ^^
what is polygon platform that is mentioned in post?(I am new I don't know, I am sorry if i asked wrong question!!)
Polygon is a service to prepares programming problems and contests
Polygon is the problem setting platform of CodeForces. There you can prepare problems. Write statement, checker code, validator code, generate testcases, add different types of solutions (ac, wa, tle etc) and run them. Explore ownself: Polygon
Great to see few consecutive rounds, I must say I started losing confidence in between last 2weeks gap, regular contests are fun in many aspects. Hopefully I would be able to increasing my rating, and most importantly enjoy solving the tasks.
good luck
I have a doubt. I registered for this contest before last one as a candidate master but now i am expert and it is showing me as registered in div1. Can i participate in div1 if i want to do so by not unregistering myself from div1? And if i do so what about rating changes, will they be changed relative to div1 participants only?
There is also some purple participants in div2 as well
https://codeforces.com/contestRegistrants/1440?order=BY_RATING_DESC
Yes, i meant in both cases (mine as well as vice-versa). Definitely, we have option of registering with correct divisions too. I wanted to ask whether there is any guideline or rule which we need to follow in such scenario or it completely depends on our wish?
I would suggest that you participate in the correct division. The fact that is technically possible to register for the wrong one is a weak legitimation to do so. I mean, what rule would make sense to you?
Excited for this contest?please don't make it unrated.
Hey Guys, check https://gameofcodes.herokuapp.com for practicing weak and strong topics and much more!
what is special about problem C?
There will be an easy and a hard version of this problem.
Wish you high scores and good luck! Little wish to become blue:)
I think there will be two versions of problem C based on constraints. Which one is better to solve? 1.Solving C1 and C2 both at a time. 2.Solving C1 first and then move to C2.
newbie needs some contribution here.....
what's the point of getting free contributions ??
Why don't u ask Monogon that question xD
100 upvotes and I'll answer.
ok i have already contributed to your score
Btw this is the first time a red coder has replied to me xD(I know I tagged you but still)
Is this the second time?
third time my watch is 20 minutes fast
Pussy+ lots of salt
LOL! do you consider them same as verified account on twitter?
Nah,just it was a first time
That doesn't even make sense but ok.
My first time participating in a Div 1 contest. Very Excited to participate in this round and also do let me know if there are any new strategies that I need to employ in Div1 contests xD :)
Yeah just ask for strategies from your competitors, don't see how that can go wrong.
PS: Jk ofc, most of the people here help each other for healthy competition.
Guys actually this is my 2nd account my first account is red ....so i want to all to spam that upvote button and as a return gift i will wish for your best performance . PS: I am a GodMan ....my wishes are always fullfilled.
solve atleast 3 problems and i will upvote you.
Ok bro i will... :-)
So how many have you solved?? XXDDD
Gave 5 contests and still a newbie XD, and says that he is red, ohh come onnnnn XD
best of luck everyone 5 min left!!!!!!!!!!!!!!!!!
is it rated ?
Why we still here, just to suffer.....
For Div2C2/Div1A2, I write more than 200+ lines of code to handle edge case when n or m is odd. Although I can think clear how to solve it, but it is too complicated and I give up. There must be some simpler ways, good question!
I bricked on only one case where the grid is full filled and both n and m are odd, in that case I print the answer as nm + 2. Man it took me ages to compensate this 2, still dont know how do we do it :(
You only need to solve the 2x2, 2x3 and 3x2 cases. You can then model all n, m into those cases. I bruteforced all costs of strings, made them into linear string instead of grid and tried implementing. I had this one bug in both n and m odd case which I couldn't find which made me mad and I gave up.
I see some hints from other reviews, actually we just need to transform the last odd row and column to all zero first, then solve remaining grid by 2x2 as previous did
that's exactly what I did.
but the implementation costed a total of 90 mins (debugging time included)
Same. I wrote 446 lines of C related code (not counting code template) before giving up and moving to E (which seemed easier to implement).
Lol I had only 80 lines or so
you are lucky
Well, what I did was first make all the frame equal to zero (the corner, if needed to fix, is tricky), and then solve the rest of the matrix in blocks of 2. I had 4 functions — handle_4_ones calls handle_1_ones calls handle_2_ones calls handle_3_ones.
What fucked me over was a bug in my corner case. But now I realize that if the 3 in the corner are all '1's, then we don't do anything, but if it isn't we can just make the whole square 0 in <= 3 moves (and not do if else 8 times and lose because of it :( ).
I wrote 257 line of code but got wrong answer on pretest 1 just because i used 0 based indexing at the last second, now i feel like crying :(
My approach:
1. First of all I pushed all 1s to the bottom two rows
2. Then pushed all 1s to the right bottom 4 cells
3. Then handle the last four cells manually
My submission https://codeforces.com/contest/1440/submission/98733831
Easiest problem of contest: C (idea)
Hardest problem of contest: C (implementation)
Can anyone who used segment tree for E suggest how to handle the lazy updates? What information did you store in nodes? The second type of query was easy to handle and implement. The first, not so much.
As array is nonincreasing updates are assign
y
on some suffix of[1;x]
I stored the min, max, suffix sum at each node. Would that have been enough? I did eventually implement the lazy updates but it was linear and not constant due to bad implementation :(
Can you please give some hints fo Query 2 of E?
for Div2D/Div1B After finding that "a non-empty subset of vertices such that each vertex of this subset has at least k neighbors in the subset" does not exist how to find if clique of size k exist or not? Anyone Please!
What is the Pretest 2 of D2-C2 :(
Maybe this one?
My solution failed on this test case initially.
No not this. I print the answer for this to be 4. One case as of now I am aware of when both n and m are odd and the grid is full filled where I print the answer as 2 more.
For eg :
here I print the answer as 11 moves
...:(
Exact same thing but in Python . I still don't get the meaning of the easier sub-task?
indeed, and i know you from codechef discuss. :D
After I've solved this edge case I've managed to pass pretest 2
Here's a couple from Pretest2 of Div2-C2 that may be worth trying :
Ok thanks, actually my code runs fine on this (giving 2 and 4 moves respectively), but I found a case inpired from your test that breaks my code.
Here I print 7 (not possible to constraints)
https://youtu.be/c3FUlV2Fm6g I made this video on C2 for the very first time. I think it might help you.
Can someone give a hint for D.2 E?
took me 200 years to implement div2 c ...
I wrote a 250 Line code for Div2C1 and still managed to fail on pretest 2 :sob:
80% of my code was just push_back();
Was div 2 E going to be solved using segment tree?
Square Root Decomposition I suppose
Nope. Segment tree that simulates binsearch, or treap. Kinda tough to implement.
I solved it like that, yes. The hungry man takes from no more than $$$O(\log n)$$$ continuous segments and you can find those using the "binary search on segment tree in $$$O(\log n)$$$" technique.
Nice can you give any refrence to "binary search on segment tree in $$$O(logn)$$$" please?
I only know of this tutorial. Unfortunately it's only for Fenwick tree but the idea is the same — the tree already as a "binary-search-like" structure so you can descend in the tree instead of of making separate queries for each binary search step.
You are life saver!
for this problem I think you can do usual binary search (like middle=(x+n)/2) and the find range sum in [x,m] then accordingly change the range. but time complexity will be $$$O(n(logn)^2)$$$ but time limit is 3 sec so should be sufficient..
You can't, because every query in the problem requires $$$O(\log n)$$$ such binary searches.
"Seg Descend" might be helpful, though I haven't solved the problem yet so i don't know for sure. You can find it in this page https://cp-algorithms.com/data_structures/segment_tree.html under the heading "Searching for the first element greater than a given amount".
Can you please elaborate more on the part "The hungry man takes from no more than $$$O(logn)$$$ continuous segments".
When he has bought food in some segment and can't buy food at the next one, the amount of money he has must have been at least halved since the start of the segment (because the array is nonincreasing and the updates maintain that).Oh,I guess it's actually $$$\log C$$$, but it's not very important.
My fingers are hurting after writing code for div2 C.
Am I the only one who felt that problem C1 (Div-2) was totally hardcore implementation problem?
I don't think C1 was. But, definitely C2 imo
I don't think so. https://codeforces.com/contest/1440/submission/98728859
Maybe you can take a loot at jiangly's submission and see that it is not that long, but still dumb implement problem.
yeah it 's for sure that it is not that long if we see jiangly submission , jiangly writes beautiful implementation for each and every problems . But newbies like me writes terrible code see around 388 lines — spaces . Submission link : https://codeforces.com/contest/1440/submission/98743493 It is really nice to see someone mentions the highness of jiangly which in my mind is one of the best coder in the world right now . Sorry jiangly for mentioning your name and an annoying notification of mine :)
Yep jiamgly made me learn. Everything I finishing upsolving I always look at jiangly's submission.
Yes, indeed!
Does there really exist anyone who don't love jiangly-chan?
jiangly-chan, we love you! <3 <3 <3 <3
Just join "jiangly fan-club"! ;P
btw you can check my submission also
How to join that club ? I don't know that they will gonna take a pupil like me in their club but anyway i have learnt a lot from jiangly coding . The way of writing inner lambda functions in main and lots of simple coding style too . Only thing i don't do is writing std:: again and again . I respect and love jiangly way of writing code a lot (infinite times repeat) . I wish that one day jiangly be the best coder in the world . Sorry if anyone finds my words and complements annoying in advance .
It seems that the club is not in the "Organizations" of Codeforces.
But you can create a brand new organization named "jiangly fan-club" for sure! (just like Ildar Gainullin fun-club, btw Ildar Gainullin is 300iq)
I'm sure lots of coders who learnt from jiangly's code will be glad to join!
Its too short!
Ever since I found jiangly, I never looked others' code :) (no offense to other people who write beautiful code)
I am an idiot. I debugged C2 like crazy, submitted in the last 20 seconds, and forgot to submit C1 :(
Btw, great problem — NO IF ELSE IN C2, NO CASES, REALLY EASY IMPLEMENTATION.
obviously now when I look at it I could have saved a lot of the code, but still...
I did a similar approach in my implementation. I still don't know why I got RTE on pretest 2. I spent the last 10 minutes trying to figure that out.
Hey, isn't finding a clique of size k NP-complete? I lost my mind after reading D cuz of that and not to mention I left C behind long long ago XD
I think you can have a clique if and only if you can solve the second task of the problem with k-1. And I think you can do the transition somehow..
Then someone please explain why the problemsetter hasn't been given a million dollars to have shown a poly time solution to an NP complete problem.
There is bron-kerbosch algo, but I think complexity does not allow it to run on 1e5 vertex.
the trick was realizing that for having a clique of size k, you need at least k * (k — 1) vertices
I think extremely easy idea but extremely heavy implementation problems should be reduced (as least just give m,n even).
B and C were so uninteresting. You could easily see the idea (or at least the pattern) in both of them but it all came down to who could implement them faster.
I mean... you're right about C but B was pretty easy to implement... You just sum up elements in a single (kind of-)simple for loop.
I don't think it was very easy to see that, took me 10 minutes to observe it and then another 20 minutes to debug my code. Also, I think C was very implementation heavy, some typos and you will have to spend another 30 minutes figuring it out. PS: my personal opinion.
I never said B was easy... I was it was pretty easy to implement. I mean, the shortest and most simple implementation for C was at least 50 lines of code (or probably closer to 100).
This is my implementation of B:
You can't say a problem like this is implementation heavy.
I think C was really braindead. In B I needed like 20 minutes to switch n and k. I think this is the first problem where the number of the partial thing is named n, not the number of the whole thing. Same goes with k, it is usually used for a property of a part. Misleading nameing.
Why did div1A have subtasks? In one operation, we always cut off one cell from the bottom/right border until we get 2x2 and there are just 4 distinct operations there. I don't see a simpler solution for the first subtask.
Fix each cell individually in 3 steps.
Wasn't the same logic used in the hard subtask also? Each cell can be fixed in 1 step and we are left with just 2 corner cells which require atmost 3 steps.
Fix each cell individually in 1 step.
Still the number of submission in div2 for the same problem were 2500(easy)-700(hard). People must have found some logic for 3*n*m
For subtask one you can change one cell of each 2 * 2 in 3 operasion such that other cells do not change
except last row, all cells in 1 operation. total=(n*m-m). for last row, we can chang each cell in atmost 3 operations. total=(n*m-m)+m*3 = n*m+2*m. this can work for both subtasks?? is the total correct?
Use the idea for "all but the last row" with columns too. Then you're left with a 2x2 grid.
How to solve Div2.D / Div1,B ?, ty.
....?? Why NP-Complete problem comes here?
From the problem statement it kinda follows that it's not NP-complete if you can instead answer the other question.
Can you please tell me just the idea. After finding that "a non-empty subset of vertices such that each vertex of this subset has at least k neighbors in the subset" does not exist how to find if clique of size k exist or not?
I'm not gonna forgive you 3 seconds TL in E :<
Make sure you have amazing typing speed with precision before solving Div2. C
Do you hate your participants or what? What the hell is wrong with these limitations? Why in every problem I have to optimize everything? Ideas are maybe fine, but you have killed this round with your limitations.
Looking at the standings atm I don't know if I should be afraid of you or of an author...
Do you also have to guess the hashset implementation which passes the tests? Fuck you guys, for real.
+1
As a mere blue coder, I know something is wrong when I see Um_nik TLE 2nd problem in div1.
And I thought I was pissed off when carefully implementing clique checking optimised for this problem, lol.
+1
The fact that you could not pass test 57 test is not a reason to say every word that you want, I did not answer yesterday because you were angry, but really a pity for those who are LGM and for example can be a good role model for others, do not value himself.
Fuck you. Today I'm not angry, will you answer?
Why did I really waste my time writing the previous comment? Keep polite and thank you for proving to me that I was not wrong about you :) ;)
You are clearly an extremely talented programmer um_nik, but that does not give you the right to treat people like this. Your language and rudeness is completely unnecessary.
Edit: downvote me all you want — if the guy goes around telling people to f**k themselves because he TLEd on a question, that’s rude, disrespectful of the writers who gave up their time, and just plain unnecessary. No amount of rating points makes that ok behaviour.
I support you. Especially for Div1B, I think 1 sec for this problem is terrible even with $$$O(n \sqrt{n})$$$ without hashsets or something. I always consider quitting Cf with writers who give us problems with such TL/MLs...
I think my recent submission 98748728 is $$$O(m sqrt(m))$$$ without hashset and got TL :(
It's not. Tests 56 and 57 are against solutions like yours with wrong complexity. Tests 25, 58 and others are made against $$$O(m\sqrt{m})$$$ solutions with too high constant and/or log factor.
Ah, my submission is wrong with small K (maybe N^2/K). Sorry for confusing
By the latter sentence, you mean pretests did not have maximum tests? With such tight TL?
There are tests that look like maximum tests, but the ratio between runtimes of any 2 tests can, due to implementation details, be different for 2 solutions with the same complexity. Pretests probably have tests that caused higher runtimes on most authors' solutions, while on some other solutions tests like 25, 29 and 58 can cause higher runtimes. Or maybe I'm wrong and tests 25 and 29 did cause higher runtimes than tests 6, 7, 9 and 12 on authors' solutions but for some different reason they decided to not put them in pretests.
I think that you are just bullshitting me. I used different hashset and got AC now. I was having TL 57. Did different hashset magically fix my complexity?
For some reason test 57 caused an $$$O(n^2)$$$ blow up on your hash table. Changing your hash function from
(v * A + u + B) % P;
to(v * A + u * B) % P;
gave AC: 98754739For fixed v, if u are near each other hashes are also near each other.
As hash table is already 50% full, and chaining is done by increasing index by one you get a blow up.
Increasing size of hash to 100m from 2m ( 98748122 ) or changing chain step to something like P/3 ( 98756686 ) also passes.
mmm cool)
The official solution was O(n.sqrt(n)) without any hashmap or something like that.
Congrats Errichto — LGM
He became LGM in 2019 actually, anyway.
How to solve C2?
In the easy version, I guess you have changed each cell with 3 operations if needed. To optimize this, we can first modify all the cells in the first n-2 rows with one operation for each by using either
XO
OO
or
OX
OO
-shaped modification.
For the first m-2 columns in the rest 2 rows, to modify arr[n-1][i] and arr[n][i] into "correct" entries, just do one operation depending on the current entries on arr[n-1][i] and arr[n][i]. You may divide this part into 4 cases.
As for the rest 2 columns in the rest 2 rows, similarly, do operations depending on the current entries on arr[n-1][m-1], arr[n-1][m], arr[n][m-1] and arr[n][m]. You may divide this part into 16 cases. Each case can be done in 4 operations.
Okay, I got it. Thanks!
Opinion: Hard problems are interesting but increasing of difficulty are kind of imbalanced, and those easy problems are not good.
(
)
Can relate xd. I spent something like 40 minutes on this and didn't get this through xd. In the end I got the idea, but it is quite messy to code.
here is my approach for C2
You can easily solve the rest right ?
{ $$$s[n-1][m-1], s[n-1][m-0]$$$ }
{ $$$s[n-0][m-1], s[n-0][m-0]$$$ }
Yeah, that's what I was coding in last minute, but lacked a bit of time. Quite consoling to see a rather clean solution with provable $$$nm$$$ bound after coding a lot of shitty things before and coming up with a few solutions that would require something like $$$nm+3$$$ operations.
Lmao, this ad-hoc problem is "fun". But I think the lower bound is smaller $$$n \times m$$$.
And how were you as a red-ranker seeing the first problem of the contest is that heavy implementation problem :(((
Looking at other people's comments, this problem appears to be anything but fun, and obviously it isn't fun at all to have a really heavy implementation problem being problem A.
That is why "fun" is inside the quote :D
My code for problem C went for around 200 lines, could not even debug, why such implementation heavy problem with no thinking required
It's more like how you do the implementation.
I made 3 separate funtions to handle the bottom-right 2x2 square :
handle1() : when number of ones is 1.
handle2() : when number of ones are 2.
handle3() : when number of ones are 3.
I completely implemented each case in handle1();
For handle2() and handle3(), I converted the 2x2 matrix, with some operations to case which handle1() does and then call handle1().
Although it helps in a little bit easy implementation but still the code was long
My story with div1C: figure out what to do quickly, start writing a segtree... keep writing a segtree... finally finished 20 minutes before the end. Sample gives very wrong answers, so I'm debugging like crazy, but I'm getting nonsense answers. Check how much time is left... 2 minutes, no point trying. OH WAIT I'm getting very negative sums in the debug output, is there something wrong with my "push an update deeper in the segtree" function? Yeah, I flipped some range bounds and was updating sum[l:r] to $$$y (l-r)$$$ instead of $$$y(r-l)$$$. Quickly I deleted debug couts and managed to submit without even testing on the sample. AC on pretests, less than 1 minute left.
Top 10 anime fight turnarounds.
For the record, the main idea in that problem is to repeat "find first A[z] <= y, find largest sum A[z:new_x] <= y, subtract the sum from y and make x = new_x" because that decreases y more than twice.
How do you know that making the change x = new_x won't be appearing O(n) times every query???
The last few words answer that.
Because it will decrease y at least twice. So it is log(y)