Блог пользователя yse

Автор yse, 4 недели назад, По-английски

Thank you for participating in the contest! I hope you enjoyed all problems :) Also, thanks to reirugan for proofreading the editorial.

Rating Predictions
Rate the contest!
Rate the difficulty!

A — Riptide

Hint
Solution
Code (C++)
Rate the problem!

B — Evanescent

Hint
Solution
Code (C++)
Rate the problem!

C1 — Marenol (easy version)

Hint 1
Hint 2
Solution
Code (C++)
Rate the problem!

C2 — Marenol (hard version)

Solution
Code (C++)
Rate the problem!

D — Silhouette

Hint 1
Hint 2
Hint 3
Solution
Code (C++)
Rate the problem!

E — Chronostasis

Hint 1
Hint 2
Hint 3
Solution
Code (C++)
Rate the problem!

F — Whiplash

Hint 1
Hint 2
Solution
Code (C++)
Rate the problem!

G — Nightcrawler

Hint 1
Hint 2
Hint 3
Solution
Code (C++)
Rate the problem!
Разбор задач Codeforces Round 1114 (Div. 3)
  • Проголосовать: нравится
  • +94
  • Проголосовать: не нравится

»
4 недели назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Guys is there an alternative sol for D

»
4 недели назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится

Nice, thank you

»
4 недели назад, скрыть # |
 
Проголосовать: нравится +17 Проголосовать: не нравится

Excellent contest.

»
4 недели назад, скрыть # |
 
Проголосовать: нравится +26 Проголосовать: не нравится

yse's rounds are the greatest

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

BROOO! I COULD HAVE SOLVED G, I spent too much time on D T-T :(((((((((

»
4 недели назад, скрыть # |
 
Проголосовать: нравится +16 Проголосовать: не нравится

Amazing contest, problems were too good, in my opinion B was harder than C1 and C2

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

figuring out the solutions is easier than implementing the solutions lol

also c2 isnt harder than c1 at all, this was still a fun contest though

»
4 недели назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

I don't think I implemented small-to-large properly for one of my AC solutions to G, can someone hack? https://codeforces.me/contest/2254/submission/385638977

upd: wrong link, sorry. https://codeforces.me/contest/2254/submission/385633001

upd2: hacked, thanks.

»
4 недели назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

one of the bes Tutorials that i seen in CF

thnaks for the Good Contest

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone please explain me why my G got WA?

385673245

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

honestly, the perfectly balanced contest i have given so far, thank you yse

»
4 недели назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится

I want to hack

»
4 недели назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

G is nice, thanks!

»
4 недели назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

good contest, yse thank you

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In B I thought f was only treating subsequences of maximum length. Very unfortunate that there was no example to point the other way.

»
4 недели назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

EVen after getting E, it got me in lot of Confusion!

UPD : more fkd up by the fact, this code got me wrong ans on C2 :(

inspite the idea and implementation being on the right track

https://codeforces.me/contest/2254/submission/385672566

UPD : the mistake in C2 was "no\n" in impossible cases — instead of '-1'

it is like this since i pasted C1 code directly, wtf!

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

great contest learned a lot :0 thanks ;)

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

you guys are soo cool i just can't help choking on easy questions, even today i just couldnt bring myself to think away from dp for C1 and C2 :(

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

D was hard but nice !!

»
4 недели назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

I'm a bit confused about B.

I cannot understand, why removing single character can influence only 1-char sequence and merges. But what about changing the maximum length of the sequence ? For example, consider s = 'aaabbcc'. If we remove 'a' the f(s') will be == 3, or not ? Cause the string s' will reduce to 'abc', now we have maximum blocks length == 2, not 3, so 3 substrings will be reduced, not one ? But it is not covered in Solution.

What I've missed ?

  • »
    »
    4 недели назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    I think you are complicating the problem. It has got nothing to do with substring. It just asks if we can reduce the length or not. See if we have a single character somewhere ini between then its bound to be removed. The interesting part is that what that single character should be.

    Example: Consider string s = 'aabcbbcd' If here I remove b then I get final string as acbcd. But if I remove c then I get abcd which is smaller. So technically we should try to remove a character that has same character blocks on either sides.

    • »
      »
      »
      4 недели назад, скрыть # ^ |
      Rev. 2  
      Проголосовать: нравится +1 Проголосовать: не нравится

      Why after removing c from s = 'aabcbbcd' we get 'abcd'? If we remove c that is between b characters according to the problem statement, as I have understood it, we should get 'aabcd', because we shrink only the blocks of maximum length (3 in this case) ? "Every maximal contiguous block of identical characters". What is the point of the "maximal" word here ?

      • »
        »
        »
        »
        4 недели назад, скрыть # ^ |
         
        Проголосовать: нравится 0 Проголосовать: не нравится

        You have to combine the first a with the second as well. Because its the same block.

        • »
          »
          »
          »
          »
          4 недели назад, скрыть # ^ |
          Rev. 3  
          Проголосовать: нравится 0 Проголосовать: не нравится

          Once again — "Every maximal contiguous block of identical characters". What is the point of the "maximal" word here ? If it were written "Every contiguous block of identical characters" — then ok, we will replace "aa" with "a", but if we consider only "maximal" block of identical characters, then we should consider only "bbb". And if it was supposed, that we consider maximal block for each different characters, in this case we also can find examples, when removing 1 character from maximal block will produce two or more maximal blocks instead of one. For example, "aabbaaccaaa" — we should reduce only "aaa" to "a". But if we remove last "a" we should reduce all 3 "aa" blocks to "a".

          • »
            »
            »
            »
            »
            »
            4 недели назад, скрыть # ^ |
             
            Проголосовать: нравится 0 Проголосовать: не нравится

            I think its maximal word is making you confused. The problem statement is pretty straightforward to understand.

          • »
            »
            »
            »
            »
            »
            4 недели назад, скрыть # ^ |
             
            Проголосовать: нравится 0 Проголосовать: не нравится

            You are confusing maximal and maximum. A maximal collection is one that you cannot add to without violating its property.

            So, for a contiguous block of identical characters, it is maximal if there isn't a position next to it that is the same character. Otherwise, you could extend it and it would remain valid.

  • »
    »
    4 недели назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Claim: You either can reduce the number of blocks in 0, 1 or 2. Think which are the ways!

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

My solution for Problem B. But it fails on test case 2. What could be wrong here. TLDR; If we have a character block of length 1 then we can remove it. If it has same character on either sides than those sides will merge so we will decrease answer by 2. Else only by 1. Please help me out with this people. Thank you!

Code:

void solve()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    // we can decrease the length only if we have
    // a freqs 1 character in teh middle of the string
    // if we have such character we will remove the one whihc has same char on either side to decrease teh lenth by 2 else only by 1 possible

    vector<int> f(n, 0);
    string res = "";
    int x = 0;
    // ba
    // 11
    for (int i = 1; i <= n - 2;)
    {
        int j = i;
        while (j <= n - 2 and s[j] == s[i])
            j++;
        res += s[i];
        f[x] = j - i;
        i = j;
        x++;
    }

    int found = 0;
    res = s[0] + res;
    res = res + s[n - 1];

    string fin = "";
    ll idx = 0;
    for (int i = 1; i <= res.size() - 2; i++)
    {
        if (f[i - 1] == 1)
        {
            found = 1;
            idx = i;
            if (res[i - 1] == res[i + 1])
            {
                found = 2;
                break;
            }
        }
    }

    if (found == 2)
    {
        for (int k = 0; k <= idx - 1; k++)
            fin += res[k];
        fin += res.substr(idx + 2);
    }
    if (found == 1)
    {
        for (int k = 0; k <= idx - 1; k++)
            fin += res[k];
        fin += res.substr(idx + 1);
    }

    if (fin == "")
        fin = res;
    // cout << fin << endl;
    string fin2 = "";
    for (int i = 0; i < fin.size();)
    {
        int j = i;
        fin2 += fin[i];
        while (j < fin.size() and fin[j] == fin[i])
            j++;
        i = j;
    }
    // cout << fin2 << endl;
    cout << fin2.size() << endl;
    // cout << endl;
}
»
4 недели назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

D felt harder than E, especially implementation wise

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

This submission is stuck in the queue and shows Running on test 3 while being actually tested with wa on test 2. yse

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

这个D纯码量题放这个位置好吗

»
4 недели назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

This was a very nice contest, I liked C1 and D. Good job yse :D

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I didn't get any idea on how to think on C1 just give some way or things because i don't want help from any LLM or editorial

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hii guys, Can you please check my soln. to C2? It gave "Wrong Answer" on Test Case 8. I can't figure out why?

Here's the link: https://codeforces.me/contest/2254/submission/385659954

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

я новичек, я поучавствовал и сделал некоторые задачи и у меня есть вопрос, когда появится или где можно увидеть свой рейтинг? Заранее спасибо

»
4 недели назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

even i found d much harder than e

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In E why my solution couldn't get AC? My Code I tried 9 submissions but couldn't get the AC :(

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

very wonderful constructive!!!

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Nice contest ,S0lved till C2 , will try rest of the questions before the contest.

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

infact c1 was easier than b, wasted a lot of time on b...

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Is F still solvable if n could be odd? I didn't notice that n is guaranteed to be even during contest and struggled a lot..

  • »
    »
    4 недели назад, скрыть # ^ |
     
    Проголосовать: нравится +5 Проголосовать: не нравится

    I wondered the same. In short, no, or at least not that I'm aware of. As for why:

    Firstly, notice that through a series of operations, we can permute $$$a$$$ however we'd like. Furthermore, we have the option to make $$$a$$$ of the form $$$[a_1, a_2 \oplus a_1, a_3 \oplus a_1, \ldots, a_n \oplus a_1]$$$ via a final operation.

    Thus, the problem becomes: "Can we permute $$$a$$$ such that $$$a_1 = b_1$$$ and $$$a_i = b_i \oplus a_1$$$ for $$$i \gt 1$$$?"

    Now define $$$X(a) = \bigoplus\limits_{i = 1}^{n}{a_i}$$$. Separating out the first element gives

    $$$X(a) = a_1 \oplus \bigoplus\limits_{i = 2}^{n}{a_i}$$$.

    Since $$$a_i = b_i \oplus a_1$$$ for $$$i \gt 1$$$, substitute this into the expression:

    $$$X(a) = a_1 \oplus \bigoplus\limits_{i = 2}^{n}{(b_i \oplus a_1)}$$$.

    Now split the XOR:

    $$$X(a) = a_1 \oplus \bigoplus\limits_{i = 2}^{n}{b_i} \oplus \bigoplus\limits_{i = 2}^{n}{a_1}$$$.

    Since the interval $$$[2,n]$$$ contains an odd number of elements when $$$n$$$ is even, it follows that

    $$$\bigoplus\limits_{i = 2}^{n}{a_1} = a_1$$$.

    So the expression becomes

    $$$X(a) = a_1 \oplus \bigoplus\limits_{i = 2}^{n}{b_i} \oplus a_1$$$.

    The two copies of $$$a_1$$$ cancel, leaving

    $$$X(a) = \bigoplus\limits_{i = 2}^{n}{b_i}$$$.

    Finally, since

    $$$X(b) = b_1 \oplus \bigoplus\limits_{i = 2}^{n}{b_i}$$$,

    we can rewrite the above as

    $$$X(a) = X(b) \oplus b_1$$$.

    Recalling that $$$a_1 = b_1$$$, we conclude

    $$$a_1 = X(a) \oplus X(b)$$$.

    Hopefully that wasn't too confusing, but the key point is that $$$\bigoplus\limits_{i = 2}^{n}{a_1} = a_1$$$ when $$$n$$$ is even because there are an odd number of copies of $$$a_1$$$. For odd $$$n$$$, there are an even number of copies instead, so $$$\bigoplus\limits_{i = 2}^{n}{a_1} = 0$$$, and the final conclusion is only $$$X(a) = X(b)$$$, which doesn't determine $$$a_1$$$.

    • »
      »
      »
      4 недели назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      Thanks for your reply! I tried to consider possible $$$a_1$$$ bit by bit: for one bit, if $$$a_1$$$ is not set, then it has no influence at all; otherwise, let the number of $$$a_i$$$ which is not set on this bit be $$$c_0$$$, set be $$$c_1$$$(including $$$a_1$$$ itself). After the operation, let the new numbers for $$$b$$$ be $$$c_0'$$$ and $$$c_1'$$$, then

      $$$c_0'=c_1-1$$$ and $$$c_1'=c_0+1$$$.

      Since $$$c_0+c_1=n$$$, we would know that

      $$$c_1+c_1'=n+1$$$.

      So for each bit, we just compute $$$c_1$$$ for a and $$$c_1'$$$ for b, if $$$c_1+c_1'=n+1$$$, then $$$a_1$$$ is set; if $$$c_1=c_1'$$$, then $$$a_1$$$ is not set. For even n this is trivial, since if $$$c_1+c_1'=n+1$$$, $$$c_1$$$ and $$$c_1'$$$ must differ; but for odd n, we may have $$$c_1=c_1'=(n+1)/2$$$, in which case we cannot determine whether $$$a_1$$$ is set on this bit. So maybe there are still many candidates after considering every bit.

  • »
    »
    4 недели назад, скрыть # ^ |
    Rev. 6  
    Проголосовать: нравится +6 Проголосовать: не нравится

    UPDATE: this got hacked, 385697542, it is possible to construct a test case where the probability significantly skews from 50%.

    If n is odd we would need another approach, (i got this from Gemini):

    since we need an element from a and perform the operation on it, we can brute force this element. for checking we use randomization, we pick 30 random elements from the array b, and use those as our sample for testing.

    lets say the current element a[i] is x, so for x to be valid, for every element y from out sample, y ⊕ x should be in a.

    picking 30 elements is sufficient because suppose we lucked out for every of those 30 numbers, the probability of such event is very small; (0.5) ^ 30.

    finally we check if this current element x, makes the multisets of the two arrays equal.

    final complexity is O(30 * n * logn).

    Also gemini mentioned another solution using tries, but i did not bother digging deeper lol.

»
4 недели назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

The year is 2044, there is a pandemic of a bioengineered virus that causes near instant death, and hacks are still not open for Codeforces Round 1114 (Div. 3)

»
4 недели назад, скрыть # |
 
Проголосовать: нравится -9 Проголосовать: не нравится

Shouldn't it be hacking phase rn? For div. 3 rounds, isn't hacking phase 12 hours?

»
4 недели назад, скрыть # |
Rev. 3  
Проголосовать: нравится +5 Проголосовать: не нравится

Just a reflection of what I tried (and failed on) on a couple of problems, in case it's useful to others.

Problem C2

My solution to C1 was different (based on another problem I had seen where the characters are a-z instead of 0/1). For this problem, note that adjacent equal elements can be freely moved around. Thus, it suffices to keep removing adjacent equal elements from $$$a$$$ and $$$b$$$ (can do this fast by going left to right with a stack) and check if the resulting strings are equal. I feel this approach can't / might be hard to generalize to C2

This was my C1 submission link.

Problem F

When I was trying the problem, I was just trying to solve it for the case where the values are all $$$1$$$-bit (i.e. they're all $$$0$$$ or $$$1$$$).

If $$$k$$$ of them are equal to $$$1$$$, then you can swap a $$$1$$$ with a $$$0$$$ (by performing an operation at a location of $$$1$$$, and by performing another operation at a location that was formerly zero), and thus you can have the ones correspond to any $$$k$$$-subset of the indices. Similarly, by flipping in the first operation, the array will have $$$n-k+1$$$ ones, and you can reach any $$$n-k+1$$$-subset.

I had trouble trying to visualize what this looks like with more bits (for example, in an operation, the $$$i$$$th bits might get flipped, but nothing might happen to the $$$j$$$th bits since it was zero at the index where you operated). It's hard to visualize how the bits interact with each other. I probably should have just written things down on paper, like what happens after two operations (operating on $$$i$$$ and then operating on $$$j$$$). It's probably more clear after writing it down that it's the same as just operating on $$$j$$$ and then swapping indices $$$i$$$ and $$$j$$$.

»
4 недели назад, скрыть # |
Rev. 4  
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone explain me for G how the partition should be for k = 3 in this case (it is from test case 2)? Submitted my code after the contest, but before reading the solution.

8

3 7 8 2 8 5 1 3

1 2 3 2 3 6 5

The expected output should be: -1 -1 23 28 31 34 36 37

But mine gives: -1 -1 21 28 31 34 36 37

I have been trying to see where I my original attempt is wrong, but I can´t see how to get 23 unless I understood the problem wrong.

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Nice contest ya'll

»
4 недели назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

Want to add for G that there is an alternative solution that runs in $$$O(n logn)$$$ which avoids small-to-large and uses no heavy theory.

This problem focuses on maximizing whilst also fulfilling conditions.

Define an activated node as a node which is maximum within some subset.

The main observation in the editorial is that for every subtree, the number of activated nodes must not exceed the number of leaves within the subtree. This leads to a simple small-to-large idea. This observation tries to maximize while keeping the conditions fulfilled.

However, we can try to "reverse" the observation. Instead of observing subtrees, try observing the leaves/chains. It's obvious that every activated node must lay in different chains. So, what if we start with activated nodes in different chains and try and improve their value. This observation always keeps the condition fulfilled at the start, so we only have to think of maximizing now.

We start with the activated nodes as the leaves. Then we can try an improve by "lifting" an activated node to its parent and check if it's better. We do need to make sure that no two activated nodes overlap, so lift again if the current node is already activated.

One more problem arises, there could be a node that was activated by a certain chain, but would've been better by a different chain. We can imagine a root with two line subtrees, with the root and one of subtrees containing maximum values. If the subtree with the maximum value was lifted to the root, that would be worse than the other being lifted.

The solution comes by priority. We should lift the lowest valued activated node. This works because if a node should've been activated by a different chain, that different chain would've come to the node quicker than our current.

Still however, this solution (while works now) works in $$$O(n^2)$$$. This is because nodes can be lifted multiple times. But, we can observe that a node that has been lifted, should not be activated again (if something is lifted, it was the lowest and can't be better).

Using a priority_queue + DSU combination, we can achieve $$$O(n logn)$$$ and successfully pass the testcases.

My submission: 385714013

»
4 недели назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Amazing contest!!!

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Problem B was horrible. You say maximal contigious. It means you have to replace the block with maximum length for every symbol not all blocks. I spent 1 hour on B if I did'nt i could even slove E or more. If you did the same pls upvote so Setters see that.

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In problem D (Silhouette), shouldn't the resulting array $$$a$$$ be [2, 2, 5, 5, 6] for the second test case? It is lexicographically smaller than the one provided by the author.

  • »
    »
    4 недели назад, скрыть # ^ |
     
    Проголосовать: нравится +1 Проголосовать: не нравится

    That is lexicographically smaller indeed, but that array doesnt correspond to array $$$b$$$, because in $$$b_{2}$$$, the shadow is 4, but the sum of elements smaller than $$$a_{2}$$$ in your array is $$$0$$$

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I think C1 was easier than B

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

BUT I think D is harderrr than E , Anyone else feel the same? -> _ -> :(

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Thank You

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hi everyone! I am trying to understand the greedy solution for C2. The editorial says that the k-th '1' in the start array must go to the k-th '1' in the target array.

The case for exactly 2 elements is very clear to me. I understand why $$$|A_1 - B_1| + |A_2 - B_2| \le |A_1 - B_2| + |A_2 - B_1|$$$ holds true.

But what if we have more than 2 elements and everything is completely tangled up? If we have 5 or 10 elements, why can't a change in one pair accidentally make the paths worse for some other elements that we didn't touch?

Could anyone explain how to prove that fixing pairs one by one always works for the whole array without breaking anything else? Thanks a lot!

  • »
    »
    4 недели назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    A useful way to approach proofs like this is to ask: "if a solution is not the one we want, can we make a local change that always improves/stays the same?"

    Take any matching. If two pairs "cross" (i.e. $$$A_i \lt A_j$$$ and $$$B_p \lt B_q$$$ and we match the pairs $$$(A_i, B_q)$$$ and $$$(A_b, B_p)$$$, try swapping just those two matches. The only thing that changes is those two pairs, and the inequality

    $$$ |A_i-B_p|+|A_j-B_q| \le |A_i-B_q|+|A_j-B_p| $$$

    shows that uncrossing them never increases the total cost.

    So you don't need to reason about all $$$n$$$ pairs simultaneously. It is enough to show that every crossing can be eliminated locally while only improving/not affecting the answer. Repeating this process eventually removes all crossings, leaving exactly the sorted matching $$$A_i \leftrightarrow B_i$$$, which therefore must be optimal.

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

unable to upsolve system testing takes too much time!

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Amazing contest

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Yooooooh C2 is shi* problem, still i really enjoyed solving D

yse still thx this contest has been the best one for me so far

»
4 недели назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Guys In D i got WA on TC 20 CUZ i writed < instead of <=.

AND In E couldn't write a proper edge case.

And because of this i'm 4833th instead 1000th.

Wth should i do?It's really annoying.

NOW My rating become 1164.I could reach at least 1250 if i didn't made this mistakes.

Well at least i saw my mistakes this is also a thing.

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

@MikeMirzayanov / Contest Authors:

I am appealing the system message stating my solution for 2254D[user:MadCoder_777_18] (Submission: 385661997) coincided with user shreyash_arya (Submission: 385645552).

I do not know this user, and I did not share my code. While I understand the automated checker flagged our solve() functions as structurally similar, I want to point out a few things:

Completely Different Codebases: My submission utilizes a personalized 200+ line template with custom PBDS, anti-hack hashes, and graph structures that I use in all my contests. The other user submitted a bare-bones class-based solution. We have completely different coding styles.

Deterministic Math: The logic for 2254D essentially forces a single path: storing frequencies, checking if the difference between unique elements is divisible by the count, and ensuring strict increases. Like the mathematical progression forces the loop structure to look identical.

The Print Statement: I recognize that we both used (i == n — 1 ? "" : " ") to format the output. This is a common template I have picked up to avoid presentation errors in strict environments.

If my code was scraped from a public online compiler during the contest, it was completely unintentional on my part. I write all my core logic myself. I kindly request a manual review of our submission histories and coding styles, as a human can see these were not copy-pasted from the same source. Thank you.

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone give more detailed proof or give me a starting point to why the small-to-large merging works in (log n)? Still a bit confused on why this works...

  • »
    »
    4 недели назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    We can analyze this from the perspective of an individual element (contribution technique).

    Consider any specific element $$$x$$$ in the tree. Suppose the set currently containing element $$$x$$$ is $$$A$$$ (in this problem, sets are maintained by a priority_queue).

    When set $$$A$$$ needs to be merged with another set $$$B$$$, element $$$x$$$ is extracted from $$$A$$$ and inserted into $$$B$$$ (i.e., $$$x$$$ undergoes a "move") only when $$$\vert{}A\vert{} \le \vert{}B\vert{}$$$.

    After the merge is complete, the size of the new set containing element $$$x$$$ is $$$\vert{}A \cup B\vert{} = \vert{}A\vert{} + \vert{}B\vert{}$$$.

    Since $$$\vert{}B\vert{} \ge \vert{}A\vert{}$$$, the size of the new set satisfies:

    $$$ \vert{}A \cup B\vert{} \ge \vert{}A\vert{} + \vert{}A\vert{} = 2\vert{}A\vert{} $$$

    Every time element $$$x$$$ is moved, the size of the set containing it at least doubles (increases to at least twice its previous size).

    Complexity Analysis:

    • An element is moved at most $$$\log n$$$ times ($$$2^{\text{times}} \le n \implies \text{times} \le \log n$$$).
    • Each move incurs an $$$\log n$$$ cost (transferring an element from one priority_queue to another).
    • There are $$$n$$$ elements in total.

    Therefore, the total time complexity is $$$\log n \cdot \log n \cdot n = O(n \log^2 n)$$$.

»
4 недели назад, скрыть # |
Rev. 2  
Проголосовать: нравится +6 Проголосовать: не нравится

I have an $$$O(n \log n)$$$ solution for problem G.

Use a segment tree on the Euler's tour of the tree. On each leaf node, we store the maximum $$$a_i$$$ over all $$$i$$$ partitioned into the same subset as it. Do this for each non-leaf node on the tree, going from bottom to top: find the minimum value among the entire subtree rooted at this node, and update the value of the single leaf node with the minimum value.

See my solution here: https://codeforces.me/contest/2254/submission/385830330

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

yse or anyone else :)

Could you please clarify the test from problem 2254G - Nightcrawler?

The test (it is number 13 in test 2) is:

8
3 7 8 2 8 5 1 3
1 2 3 2 3 6 5

And the correct answer is

-1 -1 23 28 31 34 36 37

The tree is the following, the numbers on nodes are number(A_i)

How is it possible to make 3 path totaling 23?

The 3 paths should end at leaves, and one of them should have the root, and it has both 8 and 7 in its path, so the best we can get is 8+8+5=21, not 8+8+7=23.

Am I missing something?

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I had a solution for D but after hacks it got TLE. Could someone tell me why?

My Submission

»
4 недели назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

A great contest.

»
4 недели назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

Great contest and nice editorial, but one thing I'm missing in the solution for 2254G - Nightcrawler is an explicit proof that greedily extending the initial solution by adding the largest unused value at each step is optimal.

The idea is intuitive and clearly permissible (splitting a set into two doesn't invalidate any of the constraints), but that's not a proof that it's optimal. Does anyone have an idea how to prove it more formally?

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Why can we ignore the corresponding order for J ?

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

in problem G. Is there any way to solve it by computing the answer top-dowm ? (i mean iterate from N down to the number of leaves)

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Why do we need small-to-large merging in G? Isn't the information of each subtree stored in the root of it? And we only need to merge the sons of the current vertex. I don't understand the tutorial.(sorry my English is really poor)

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Well, I don't take part in the contest. But I have had an attempt, which shows that I can solve A, B, C1, C2, E. But unfortunately I don't take part in it! But it's really a good contest and very educational.

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Guys, i solved E by cutting into pieces... I didn't know how to use binary-search in muilty-set XD

»
4 недели назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

first contest, good experience

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

can anyone give me better understandable code for G or explian a solution of G.

»
4 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

My solution for D TLEd and I'm not sure why. It worked when I rewrote it into C++. LLMs couldn't figure it out-any ideas? 386133959

»
4 недели назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

The first hint of C1 doesn't make sense. There's a counterexample for it, that is for substring 011. Using the hint, we could trivially changed it into 110, but there exist no rules that shows that such operation could be done since the 1st operation requires us to have a string of 001 and the 2nd operation requires us to have a string of 110, both of which are not the same as 011.

edit1: sorry, my mind didn't really read that the vice versa. then such counterexample are negated. again, I am so sorry for my own stupidity

»
4 недели назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

can please anyone tell me why my solution for D is getting tle on 19th test case

weird thing — using map is not giving tle and unordered_map is giving tle

https://codeforces.me/contest/2254/submission/385799346

»
3 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

看到讨论区B题的思路和我不太相同,这里介绍一下我B题目的思路,如果有问题还请大家指出: 首先在一个连续字符块中,如果字符数量大于1,那么你去删除它是没有意义的:比如aaa你删除其中一个a它最后都可以通过压缩来变成一个a,那么删除操作就是多余的。 那么我们就可以根据这个原理对所给字符串进行前缀和后缀的预处理操作,具体来说就是对一个前缀或者后缀字符块我们不进行任何删除操作,只进行压缩操作,然后记录压缩之后且不去删所留下来的字符串长度。 有了上面两个前缀和后缀数组,那么我们从字符串的第二个位置开始到字符串的倒数第二个位置开始循环,模拟每一个位置被删除后所留下来的最短字符串长度,这里有两种情况讨论,1.如果说被删字符的前一个和后一个字符相同,那么就要对前缀和+后缀和还要减一,2.如果说被删字符的前一个和后一个字符不相同,只需计算出前缀和+后缀和即可,再统计这些数中的最小长度即是答案。 AC代码如下: https://codeforces.me/contest/2254/submission/386454862

»
3 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

thanks

»
3 недели назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

tests of task F are so weak, I've got it by O(n^2) solution with optimization where we firstly see at amount of numbers where i-th bit is active https://codeforces.me/contest/2254/submission/387199371

»
3 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Why in problem F there is no way that we gonna got array where N items are satisfied condition of xor-sum, but no one of them really turn A to B? Or there is, but tests are weak?

»
3 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

For D, if we take a test case b = [1 2 3 4], does any valid array a exist, or would it be a -1 in the output?

»
2 недели назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

For D my Python solution gives TLE, it's the same core logic tho ;). Any idea on how we can optimise this

https://codeforces.me/contest/2254/submission/387781222

»
4 дня назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

B felt much harder than both C1 and C2. Very fun contest though :)