All the best to all registered teams for ICPC India 2024 Preliminary Contest.
Attaching an excerpts from my team's codebook (it may help you during the contest).
If you haven't gone through the GoForGold initiative , read this blog and visit the website.
Do register for camp : fill the interest form
UPDATE
Since ICPC prelims will be organized again and it will be difficult for the teams to arrange for travel in short duration thus we will be selecting teams on the basis of :
1. Your past performance in ICPC Regionals/AWC/WF
2. Average rating of your team (~1800+ for div2 and ~2100+ for div1 with some advantage for 2nd/3rd year and IOI candidates)
3. If you have solved >=4 problems in the recent prelims round.
Note : This is a non-profit invite only camp to enhance the CP culture in india. We have more initiative lined up so even if you think you won't be in top50 prelims teams then also register. The selection criteria will be similar to IOITC where if you are in 2nd/3rd year then you will be given a little bit more preference even with lower rank/rating.
For the teams with rank > 50 in prelims, do register in div 2 if your team's average rating is >= 1700-1800 and in div1 if your average team rating is >= 2100.
The camp is also open for IOI participant. Some of them are already coming and also volunteering in the camp (like our orz evenvalue)
Codebook credit : hitman623 , TooDumbToWin, DeshiBasara, _shanky, Enigma27
Auto comment: topic has been updated by Enigma27 (previous revision, new revision, compare).
Thank you, sir. This will be a great help to all the participants.
Is the website opening??
No
Is there a cheat sheet on how to vent out anger after giving a contest on such a shitty website?
I had similar experience in 2017 (my first prelim) but not because of platform but because of problems.
After finishing contest, me and my team mate (GT_18) went to Assi Ghat in Varanasi and it worked for us.
Now, what will you guys do? Do a recontest?
yes, there will be a recontest
The contest was nothing less than mental harassment. :(
I just don't understand what the problem with Codedrills was and why you guys chose to shift to such a Holy piece of Shit.
As usual greedy management, tried to make their own platform for contest and literally fked things up
1100 Rupees for mental harassment and constantly loading the website for whole 30 minutes. WHY ??? Why can't your website handle the traffic if you made us pay for it , where did our money go . This is How you will select best team to represent India , the one with best internet should go to further rounds right ?? Take a recontest or refund us .
Even the standings were disabled but no gain .
i received a mail about the re contest, so ig it is happening
I didn't get :(
it is written on the official website for all regionals that the re contest will happen
so dont worry
i just hope they fix this issue
codedrills had a cooldown that u cannot submit 2 solutions under 30s, that helped alot to save from things like mass submissions, they havemt implemented anything like that
Let's see if they improve or not the next time , it was really frustating for my first time . Btw Thank you for informing .
yes its more frustuating when tumhara solve hogaya hai but cancel hogaya hai round :(
I had an exam today, and I didn’t even study for it so I could focus on practicing and performing well. But you completely messed it up. If you can’t handle responsibilities, please don’t take them on.
What a waste of time giving a contest where you can't even see the problems half of the time
About time they start hosting ICPC on codeforces ;-;
Codedrills worked fine IMO — it was stress-tested and didn't have any issues over the past 3 years and verdicts were super quick too.
It was a positive change as previously even ICPC regionals had server issues (personal experience from 2016) despite only 10% of teams participating compared to the current online round.
Unfortunately, what I've heard is that profs who lead ICPC India don't want to use a "third-party" platform (idk why). I think it doesn't make any sense and we should just go back to Codedrills or Codeforces (basically any platform that can deliver a pleasant experience for participants).
where can we upsolve?
Looks like there was some sort of a DDOS attack? Problems like C and E had >1500 submissions which makes no sense. It would also explain why the server suddenly went down around the 1.5 hr mark.
It does make sense.
But aren't the only ones who have access to the website, those with a login ID and password.
I don't know how it works in details though.
People were prolly spamming submissions, we were trying to submit D and suddenly the submissions wasn't working so we starting clicking submit as much as possible so that it gets submitted. Honestly they should have servers that can handle 20k-30k submissions.
I mean if you look at the top 100 in the standings, there are barely any submissions on C/E (maybe <20). I would not expect teams much farther down to have even solved C/E, much less end up accounting for close to 2000 submissions on C for example. Again, I can't be sure of what happened but something feels out-of-place.
I think people circulated their solution on telegram/discord. That's the only explanation I can think of.
I solved C during the contest but server issues didn't let me submit it, is there a way to submit questions in practice now?
Could you share the approach? I couldn't figure one out.
I used the idea of MST in this, which can be implemented using convex hull and DSU.
First sort all vertices in increasing order of x, now there are n components and n vertices and possible nC2 edges, we only care about the least costing edges we need to add, initially the least costing edges would be the edges between the adjacent components i.e vertex i, vertex (i+ 1), all such edges would be stored in a set(acting like a priority queue), we remove the lowest costing edge from the set and merge the components they were reffering to,
so the components array may look somewhat like
1 2 3 4 4 6 7
here I merged components 4, 5 and I add the least costing edges between components (4, 3) and (4, 6) using convex hull to the set, we only focus on low costing edges so we can use the rightmost vertex of 3 and leftmost vertex of 6, we can see the equation $$$a_i(x_i-x_j)$$$ as a line so for each component I maintained two convex hulls for edges going towards left and right, it is somewhat along these lines, overall if you have seen convex hull and alot of DSU i don't think it was that dificult.
Is there a reason why these contests are not done on codeforces ?
Can someone can explain how to approach yesterday's preliminary problem D (Game-2048).
Knapsack
can you share your solution or explain how to use knapsack in that problem
Weights are the points we score for making blocks of X = 4, 8, 16, 32, .. 2 ^ n, then just use knapsack with repetition.
any hints/solution for Collisions problem??
dp
Yup I tried something with dp but got WA, can you share your code
Approach : We consider moving each column either to left or right, the first one will move to right and last one will move to left (consider this as base case), now if the current column moves left then it can collide with previous two if they move right else we move current column to right. This is what me and my friend coded but couldn't submit.
what was needed to solve buy k, get 1 free? like dp, greedy etc
dp[i] = sum of last 'k' elements — arr[i-k] + dp[i-(k+1)]
with obvious segfault handling over i-k+1,i-k
thank you
Auto comment: topic has been updated by Enigma27 (previous revision, new revision, compare).
Will the prelims be held again or not ? The Update is confusing.
It will happen again.
Can teams that haven't registered before register for this one?
That depends on the RCD, I guess their deadline has already passed.
Recontest clashes with the cf div1 round, please consider moving the contest to a different day or to a different time on the same day.
I think 24th should also work
Actually there are multiple such requests because of exams, interview rounds of campus placement etc.
But as the regionals are approaching, it's practically impossible to delay it to other date. You can send the request to RCD of corresponding regional.
But sir, the recontest is clashing with the launch of a new episode of Faketaxi. How am I supposed to give the contest?? It should definitely be postponed.
What about changing the timings? I guess 4.30 to 7 in the evening should be fine?
Many colleges have exams till the evening (both my teammates got till 8). So, keeping it in the night makes more sense. 24th night seems like a valid time too though.
In fact, I have an exam till 6pm on 23rd and I didn't know it at the time of writing that comment 💀. Given the rarity of div1s these days, it would be great if they could avoid the clash, and 24th night seems like a good option for it.
India ICPC prelims 2024 (cancelled one) is over, so where can i test the code i wrote for one of its question. Its saying submission "Too Late", when i try to submit.
We are thinking of hosting a practice round with the problems from cancelled prelims, so you will be able to submit them soon.
Solutions (SubtasksWhere)
Let $$$f(n)$$$ denote the required value for $$$n$$$. Let $$$b$$$ be the index of the MSB of $$$n$$$. We’ll formulate $$$f(n)$$$ recursively.
Notice that we can split $$$f(n)$$$ into parts $$$A$$$ and $$$B$$$ — where $$$A$$$ is the concatenation of binary numbers $$$1, \ldots, (2^b - 1)$$$, and $$$B$$$ is that of numbers $$$2^b, \ldots, n$$$.
For example $$$f(6) = 11011100101110$$$. Here $$$b=2$$$, $$$A$$$ is $$$11011$$$ (corresponding to numbers 1, 2, and 3), and $$$B$$$ is $$$100101110$$$ (corresponding to numbers 4, 5, and 6).
Clearly, $$$A = f(2^b - 1)$$$.
We’ll now separate out the contribution of bits corresponding to $$$2^b$$$ to part $$$B$$$.
Rewriting, $$$B = 100100100 + 000001010$$$.
The first addend is the contribution of $$$2^b$$$, and it is just the sum of a GP $$$(10^3 + 10^6 + 10^9)$$$. We can calculate this quickly (under modulo) using binary exponentiation. Let’s call this contribution sum $$$c$$$.
The second addend is quite similar to the original problem — it is the concatenation of the binary representations of $$$(2^b - 2^b), (2^b + 1 - 2^b), \ldots, (n - 2^b)$$$. The (simplifying) change is that each binary number is padded with leading zeros to always have $$$(b + 1)$$$ digits.
Let’s define a new function $$$g(l, n)$$$ which denotes exactly this — concatenation of binary numbers $$$0, \ldots, n$$$, with each binary taking $$$l$$$ digits. We’ll figure out how to compute this recursively. This will solve the problem for us, since:
You can similarly break $$$g(l, n)$$$ into two parts, splitting where the MSB of $$$n$$$ appears. Both halves here are quite symmetric, since all binary lengths are equal. Do a similar calculation of the contribution of the MSB (call it $$$c'$$$), and you’ll get a clean recursive form for $$$g$$$ as well:
This is nice, but takes $$$O(n)$$$ calls to complete the recursion tree. To fix it, memoise and AC :D
(As an intuition for why memoisation works, notice that the left call always has the argument of the form $$$(2^k - 1)$$$, which means it can only have $$$\log(n)$$$ distinct values. The right call just strips off the bits of the initial $$$n$$$ one by one, going from the MSB to the LSB, which is again atmost $$$log(n)$$$ steps.)
Python code for reference.
Sort all points by their positions. We’ll try to simulate Kruskal’s algorithm. Notice that while running Kruskal’s on this graph, the connected components will all be contiguous ‘subarrays’ of these sorted points. (More formally, there exists a sorted order of edges such that adding them in order, […])
We’ll store all relevant edges in a priority queue $$$P$$$ and repeatedly pick the smallest. Initially, each point is a separate component. The relevant edges are only ones that join two adjacent components. If a component currently contains points $$$[l, r]$$$, then $$$P$$$ should contain (upto) two edges corresponding to extending this component: one merging it with $$$r + 1$$$, and another merging it with $$$l - 1$$$.
All that remains is to quickly calculate the cost of extending a component to one side. In other words, we need $$$\min \limits_{l \leq i \leq r} a[i] \cdot (p[i] - p[l - 1])$$$ (for one side). This can be done using CHT, maintaining two sets (one for each side) for each component in the UFDS along with small-to-large merging.
Could you please elaborate on your statement? I cannot see how it forms a continuous subarray: "Notice that while running Kruskal’s algorithm on this graph, the connected components will all be contiguous 'subarrays' of these sorted points. (More formally, there exists a sorted order of edges such that adding them in order, [...])"
Points and Threads
Note that it is possible to avoid using cht to eliminate a log factor (though it wasn't necessary to get AC)
Use deques
how do you merge the deques fast? I dont see an easy way
we were trying to solve B using the approach that we will add all nodes(except the ones used for creating diameter) to the center node of the diameter according to number of leaves needed. What's wrong with our approach?
}
Can someone explain the tree construction problem (B)? My approach was first add number of leaf nodes to root node 1. So now the remaining nodes are n-(l+1) and tree has a diameter of 2. Now for every node that we attach to tree will increase diameter by 1. So if remaining nodes+2 ==d then the tree can be constructed else not.
You are extending only 1 leaf mode, what if you can attach some more nodes to any other leaf now without increasing the diameter?
Take this example one root node and it has l chains each of size d/2 attached to it. Now diameter will be d only but leaves will be l (last mode of each of the l chains) and total nodes will be l*d/2 + 1.
This structure can hold much more nodes than the solution you mentioned.
For l chains with d/2 diameter it means that leaf nodes should always be 2 only what iif leaf nodes are 3 then it would not satisfy as per your solution i guess.Your solution says it should always be 2 leaf nodes.
And as per mine even if i attach d-1 chain to one side and 1 node to other it will still be diameter d and leaf node 2 only. I may be wrong also, could you please provide the solution if you have solved it?
I think you misunderstood me, L chains of length d/2 connected to a common point.since there are L chains this their will be L leaves.
Yess thanks i understand now. Could you provide the code for it? It would be great help
We rank 2nd in our college and the first team filled both regionals same as us i.e. Kanpur & Chennai.If they decided to go to only one of the regionals say Kanpur, did we get the chance to go to Chennai regionals or the seat from our college left vacant.
I guess no(this has already happened with one team 5-6 years back), but you can talk to the RCDs to confirm.
You will get the seat if you would have qualified for regionals with them not on the ranklist
Aayein?
i meant if the competiting team (who didn't confirm their seat) was not on the ranklist, then if the other team (who wants the seat now) would have gotten the seat then they will get the seat
They are on the ranklist, he was trying to ask what if they refuse to go to the regionals even after getting invitation.
If a team declines, the next eligible team (from a different college or same college within the limit) gets the spot.