MateoCV's blog

By MateoCV, history, 2 days ago, In English

Hola Codeforces!

The 2026 Argentinian Programming Tournament (TAP) was held last weekend. This is a 2026-2027 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 elsantodel90, FedeNQ, fredy10, lsantire, MarcosK, Monazo1997, pablobce, reedef and me (MateoCV).

I would like to thank CodigoL, Fran2001, Heibor, IvanRenison, joaco-gavernet, Joacoini, Marckess, PekitaZ, racsosabe, Tainel, tonimondejar, 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!

  • Vote: I like it
  • +98
  • Vote: I do not like it

»
2 days ago, hide # |
Rev. 2  
Vote: I like it +26 Vote: I do not like it
  • »
    »
    38 hours ago, hide # ^ |
     
    Vote: I like it +23 Vote: I do not like it

    Mateo, as the handle he is, proposing a band of problems.

»
33 hours ago, hide # |
 
Vote: I like it +27 Vote: I do not like it

Cool problems as every time. Some remarks:

$$$E$$$ is cool, did not see a game theory matching problem (I don't know how to call it otherwise) in some time. For some reason I was able to figure out there are $$$O(N)$$$ edges in the bipartite graph, but I did not realise that the way I was generating them was the way to do the matching fast. Oh well, $$$3$$$ hours is not enough to do a virtual I guess.

For $$$F$$$ I'd like to see a formal proof that taking the first $$$i$$$ edges with cost $$$1$$$ and the rest with cost $$$\infty$$$ produces the infimum. I kinda see why that is the case, but still, a formal proof would solidify that I'm not missing something.

$$$J$$$ is funny, you think $$$O(N^3)$$$ does not pass, but then you see it's actually $$$O\left(\frac{N^3}{9}\right)$$$ or something like this.

For $$$M$$$ I feel that square root decomposition is easier to code than lazy segment tree. I checked (the times available, the ones in the actual contest are hidden) and there are only $$$2$$$ faster solutions than mine (:

$$$G$$$ I did not have enough time to think about, but I suppose you use the fact that the crossbar should have both ends at the same distance from the origin and then brute force pairs (I think there aren't that many but Pythagorean triples are not my strong suit)

$$$H$$$ feels like the problem you give for bored teams that finished everything else, but I may be wrong.

Overall, very nice contest.

  • »
    »
    32 hours ago, hide # ^ |
     
    Vote: I like it +3 Vote: I do not like it

    Actually the graph for E is a forest, because for each $$$u$$$, there is at most one edge $$$(u,v)$$$ with $$$v \lt u$$$ since you want $$$u$$$ and $$$v$$$ to complement themselves to the $$$2^k-1$$$ with the same number of bits as $$$u$$$.

    For F most also didn't prove that lol. Mateo has a proof though, maybe he can share it here?

    For J, in contest I was paranoid that the judging system would be slow so I ended up doing $$$O(\frac{N^3}{64})$$$ with bitset. Fun fact: that solution also allows for any number of letters, not just $$$3$$$, also in the same complexity.

    For M most just did $$$O(nlog^2n)$$$ normal lazy segment tree with binary search, I think it's reasonable for it to be slower than clean sqrt decomposition. There are also solutions that binary search while going down the lazy segtree or directly doing the operation with a different lazy, those will probably be faster as they are $$$O(nlogn)$$$.

    In G you can actually bruteforce that since max coordinates are up to $$$10^4$$$, the max number of integer points in such a circle was about 200-300 I think.

    I agree H looks terrifying, but actually if you think about it for a little it's quite manageable.

    My thought process (small spoiler)
  • »
    »
    30 hours ago, hide # ^ |
     
    Vote: I like it +11 Vote: I do not like it

    First of all, I'm glad that you liked the contest :)

    About $$$M$$$, as the problem setter, I was fully aware that a SQRT-like solution would be way more performant than the $$$\mathcal{O}(n \cdot \log^2(n))$$$, and when deciding the constraints for this problem I decided to not try to kill that family of solutions, since it was going to be impossible to achieve that fully.

    I actually have an SQRT decomposition solution that is (slightly) faster than my official $$$\mathcal{O}(n \cdot \log(n))$$$ solution. Of course both solutions (and yours too) can be tweaked to improve the constant factor even further, but I don't think it matters much :)

  • »
    »
    27 hours ago, hide # ^ |
     
    Vote: I like it +11 Vote: I do not like it

    In problem $$$E$$$, once you think the problem as a graph and you realize it requires a perfect matching, there's a greedy solution. The key idea is noticing that, if $$$M$$$ is the current max element unmatched, and $$$2^x \leq M \lt 2^{x+1}-1$$$ then for any other unmatched element $$$N$$$ we know that $$$2^x \lt M+N \leq 2M \lt 2^{x+2}-2 \lt 2^{x+2}-1$$$, so if there's an edge betweeen $$$N$$$ and $$$M$$$, $$$N$$$ must be equal to $$$2^{x+1}-1-M$$$.

    Now, if there're more cards with value $$$M$$$ than cards with value $$$N$$$ there's no perfect matching. Otherwise you greedily match all the $$$M\text{s}$$$ with the $$$N\text{s}$$$, remove those edges, and proceed to the next maximum unmatched element until there are no more vertices to process.

  • »
    »
    11 hours ago, hide # ^ |
     
    Vote: I like it +3 Vote: I do not like it

    About problem $$$J$$$ , you can even do an $$$\Theta(N^4)$$$ solution. 389211489