Hola Codeforces!
The 2025 Argentinian Programming Tournament (TAP) was held last weekend. This is a 2025-2026 ICPC subregional contest for teams from Argentina to qualify to the South America/South Regional contest. You can send your solutions or do a virtual participation in the Codeforces gym. I invite you all to solve the problems.
The problems were written and prepared by Alejandro Strejilevich de Loma, elsantodel90, FedeNQ, fredy10, lsantire, MarcosK, Monazo1997, pablobce, and me (MateoCV)
I would like to thank Agua_Podrida, Aristides, CodigoL, Heibor, IvanRenison, Klaus26, MrNachoX, Tainel, kovaxis, and visho33 for solving and reviewing the problems and providing valuable feedback.
Feel free to use this blog to discuss about the problems :)
Happy coding!








These were the authors of each problem:
Nice problems. What is the intended solution for problem D? I have a simulation sped up with linear memory binary lifting but I feel there is a simpler solution.
Also curious about problem K. Couldn't come up with a better approach than splitting colors by number of appearances and doing $$$O\left(\frac{N^2}{B} + \left(\frac{N}{B}\right)^2 \cdot \log N\right)$$$. Did not implement this.
Also, is there any editorial for problem F? Did not even consider solving it but I was curious how hard it actually is.
For K, from the time complexity you mentioned, you seem to have a correct or close to correct idea (might be a bit too slow, more details below).
First, for each query we only care about the frecuencies of the given nodes, and not the nodes themselves. Then let's call a frecuency "big" if it has more than $$$K$$$ elements, and "small" otherwise. We can do different things according to the type of frecuencies involved in each query.
We can solve all queries where at least one frecuency is "big" offline doing a bfs multisource for each of the "big" frecuencies with a total complexity of $$$O(N^2/K)$$$. Then what remains is to solve queries where both frecuencies are "small".
So we can solve the problem in a total complexity of $$$O(N^2/K + QS)$$$, assuming we solve each of the remaining queries in $$$O(S)$$$.
Here is where it gets tricky, and there are different approaches with slightly different time complexities (using $$$Q=N$$$ below):
In the official contest the time limit was quite tight as we aimed to cut 1 and 2 out (making it hard to get AC with 3 and 4 as well as a consequence). Here in codeforces the time limit is a bit more generous and it shold be a bit easier to get AC with most of the approaches.
We have tried the 4th approach for more than 20 submissions to get an accepted solution due to the constant factors.
For F:
I don't think the idea is very complicated, but I do think it is difficult to code as there can be a lot of edge cases.
I will answer queries in order from smallest rope length to biggest.
Call $$$A$$$ the goat going ccw and $$$B$$$ when it goes cw.
If $$$2\cdot l \leq$$$ perimeter it is easy to do the math with the angles because $$$A$$$ and $$$B$$$ won't intersect. (To do this you must precompute some information about the angles at each vertex and its distance from the first vertex, to then replace the rope length and get the result)
Note that you are only interested in the intersection of the curves $$$A$$$ and $$$B$$$, Also the curves are the concatenation of various arcs of circunferences made when the goat rotates around each vertex, reducing the radius each time you encounter a new vertex.
It is also clear that once the two curves intersect, you are no longer interested in the curve from that point, so you can eliminate the points of the polygon we are not interested in using as centers (subtracting the area of the triangle we are erasing).
You can do this with two pointers because if we can cover an arc of $$$B$$$ with $$$A$$$ at some moment, then with more rope length you will cover it too (to prove this you should see how the arcs are formed and the points between two arcs).
When you have the intersection it is the same as the case $$$2\cdot l \leq$$$ perimeter, with the current polygon and being careful of not counting that area twice (you can do this in $$$O(1)$$$ by calculating the triangle and reducing the last angles).
Thanks everyone who helped with TAP 2025, especially Mateo for authoring so many of the problems.
Also, since I have already received a few codeforces private messages asking me about solutions, (shameless self-plug next) I might as well share here a couple of live streams (in Spanish) I made explaining (most of) the problems' solutions in detail, and coding them in Python:
https://www.youtube.com/watch?v=tsA3ySwurqs
https://www.youtube.com/watch?v=BCaP5uEdFwk
Hope somebody finds them useful :)
Someone have wa30 in H problem? Pls hint