Error_Yuan's blog

By Error_Yuan, 8 months ago, In English
Rate the Contest!

2136A - In the Dream

Idea: Alan_dong
Preparation: Register

Hint
Solution
Code (C++)
Code (Python)
Rate the Problem!

2136B - Like the Bitset

Idea & Preparation: _istil

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

2135A - Against the Difference

Idea: Error_Yuan
Preparation: __baozii__

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

2135B - For the Champion

Idea & Preparation: Error_Yuan

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

2135C - By the Assignment

Idea & Preparation: Register

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

2135D1 - From the Unknown (Easy Version)

2135D2 - From the Unknown (Hard Version)

Idea & Preparation: Error_Yuan

Hint 1
Hint 2
Solution (Easy)
Code (Easy, C++)
Hint 3
Hint 4
Hint 5
Solution (Hard)
Code (Hard, C++)
Rate the Problem! (Easy)
Rate the Problem! (Hard)

2135E1 - Beyond the Palindrome (Easy Version)

2135E2 - Beyond the Palindrome (Hard Version)

Idea & Preparation: Register
Full Solution: STUDENT0

Hint 1
Hint 2
Hint 3
Hint 4
Solution (Easy)
Code (Easy, C++)
Hint 5
Hint 6
Solution (Hard)
Code (Hard, C++)
Rate the Problem! (Easy)
Rate the Problem! (Hard)

2135F - To the Infinity

Idea: STUDENT0
Preparation: Register

Hint 1
Hint 2
Hint 3
Hint 4
Hint 5
Solution
Code (C++)
Rate the Problem!
  • Vote: I like it
  • +218
  • Vote: I do not like it

»
8 months ago, hide # |
 
Vote: I like it -28 Vote: I do not like it

Thank you for the problems, loved D and E, F seems cool too (hate A)

  • »
    »
    8 months ago, hide # ^ |
     
    Vote: I like it +9 Vote: I do not like it

    What's your problem with A? I'm curious.

    • »
      »
      »
      8 months ago, hide # ^ |
       
      Vote: I like it -25 Vote: I do not like it

      The problem is fine, I just took too long on it and then decided to read the other problems before finally submitting it

»
8 months ago, hide # |
 
Vote: I like it +10 Vote: I do not like it

thanks for nice problems and quick editorial.

»
8 months ago, hide # |
 
Vote: I like it -13 Vote: I do not like it

In problem-A, I thought the ratios were given a:b and c:d but they are just scores. That completely messed up my contest.

»
8 months ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

Thank you for the contest! C was a really very fun problem (I still don't get how 8000 people solved it but.. anyways)

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I was so getting a feeling to use dp in C, I wish I had gone forward with it and solved it

»
8 months ago, hide # |
Rev. 2  
Vote: I like it +12 Vote: I do not like it

How come a problem like Div2C has more than 8000 solves? Is it because it is a very standard problem?

»
8 months ago, hide # |
Rev. 5  
Vote: I like it 0 Vote: I do not like it
Spoiler

why does my logic fail for test case 5 in the div2 D ?? I think we can solve it by moving to extreme positions of the board (top right and bottom left) and then get 2 equations 2 variables to solve for the positions. Am I missing something here?

  • »
    »
    8 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    int can only hold till 2e9 approx. you might be getting overflows

  • »
    »
    8 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Please always use the spoiler feature when writing code in comments. That way your comment won't take so much space in the comment section. To do that, click the small CF icon present on the editor, then click "Spoiler".

  • »
    »
    8 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    you have k=1e9 and you are using 2*k it is 2e9 and it is mentioned that you can't use k more than 1e9 in one ope

  • »
    »
    8 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Your start position can be $$$(-10^9,10^9)$$$, so a single UR won't guarantee you to be at the top-right.

    • »
      »
      »
      8 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      lowkey fr fr, I just observed that, I gave my code to gpt and it solved it in 2 mins, I am 100% sure that gpt cannot take my job as no-one can write just bad code

  • »
    »
    8 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    K while querying should be <= 1e9. You are querying with 2*K which is 2e9

  • »
    »
    8 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    You have to go 1. ? R 1e9 2. ? R 1e9 3. ? U 1e9 4. ? U 1e9 Otherwise you're not guaranteed to reach the top right corner. You can start from (-1e9;-1e9) for example. I ran into the same problem and discovered it in the last 30 minutes.

    • »
      »
      »
      8 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      yeah , I understood my stuff now, it is sad that I did not see that I willl have to move 4 times at least

  • »
    »
    8 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    You should move up/right twice, after a single 1e9 move you might still be in the middle of the field

»
8 months ago, hide # |
 
Vote: I like it -11 Vote: I do not like it

Thank you for the contest! I enjoyed Div2F, I thought the idea was cool. I think there is a range of B values that work, mine worked with B = 120.

»
8 months ago, hide # |
 
Vote: I like it +6 Vote: I do not like it
Spoiler
»
8 months ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

Thanks for amazing problems and amazing round!

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it
  • »
    »
    8 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    In a map, you are grouping n elements by taking their modulo, for example (3 3 3), (3 3 3). However, you can also group them using any previous values. If you use a queue, after having the n value in the query, it would be much easier to do this by simply popping one element.

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I just don't get how to solve C... not even with the explanation. I knew I had to use DP. Sort of used it, but got time limit exceeded.

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

What an amazing contest! Enjoyed A-D problems :)

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

why does my logic fail in D

336052875

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Woow, so it was written 10 not 8 queries, for faking purposes then? haha I assumed that too, but I said there is a high chance they will not do that so maybe I am wrong

»
8 months ago, hide # |
Rev. 3  
Vote: I like it +8 Vote: I do not like it

In problem D's editorial.

Let's first use four operations (L,V), (L,V), (U,V), and (U,V). Since initially −V≤X,Y≤V, after the four operations, it's guaranteed that X′,Y′ ≤ −V.

How? isn't up mean add V to y? if my actual position is (0, 0) after this 4 operation my position will be (-20^9, +20^9). Then how it's gurantedd that X', Y' <= -V? .

»
8 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Why in Div2D/Div1B, moving the robot to top-left corner implies that $$$y_i - Y^\prime \ge 0$$$ if it suppose to $$$Y^\prime$$$ be the maximum possible. This isn't $$$Y^\prime - y_1 \ge 0$$$?

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I need some assistance regarding Problem D:

When I run the code on my device, it outputs correctly, but when I submit, I get surprised by the judge saying it was a wrong answer, only to find the response the judge received different than mine.

I tried debugging, searching for uninitialized variables, anything compiler dependent, but to no avail (it was a painful last 30 minutes during contest), could anyone help me find the issue?

submission link

  • »
    »
    8 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    Your X-axis is flipped (x decreases when going left, your code assumes it increases). I'm assuming that when testing locally, you also answered with this flipped X-axis in mind, which is why it worked locally.

    • »
      »
      »
      8 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      My approach was slightly different than the editorial's, I went UpLeft and DownLeft, which meant taking the highest $$$y_i + x_i$$$ value (marked by $$$dec$$$ for decreasing to mark highest negative slope line) for the top left anchor, and lowest $$$y_i - x_i$$$ value (marked by $$$inc$$$ for increasing to mark lowest positive slope line) for the bottom left anchor

      Explanation :

      $$$

      \left( (X + 2 \times 10^9) - x_{dec} \right) + \left( (Y + 2 \times 10^9) - y_{dec} \right) = UL \newline

      X + Y = UL + x_{dec} + y_{dec} - 4 \times 10^9 = UL + dec - 4 \times 10^9 = rhs1 \newline

      \left( (X + 2 \times 10^9) - x_{inc} \right) + \left( y_{inc} - (Y + 2 \times 10^9) \right) = DL \newline

      X - Y = DL + x_{inc} - y_{inc} - 4 \times 10^9 = DL - inc - 4 \times 10^9 = rhs2 \newline

      X = \frac{rhs1 + rhs2}{2} \newline

      Y = \frac{rhs1 - rhs2}{2} \newline

      $$$

      which is my solution

      • »
        »
        »
        »
        8 months ago, hide # ^ |
        Rev. 2  
        Vote: I like it +9 Vote: I do not like it

        Going left means X-2e9

        • »
          »
          »
          »
          »
          8 months ago, hide # ^ |
           
          Vote: I like it 0 Vote: I do not like it

          You are absolutely right, I was calculating for right while labeling it as left (I don't know how I messed this up), but I don't think this labeling switch changes the equations, does it?

        • »
          »
          »
          »
          »
          8 months ago, hide # ^ |
           
          Vote: I like it +1 Vote: I do not like it

          Update: This was the issue all along, the query I was sending says left L while I meant to say right R

          30 minutes only to have mixed left with right... outstanding performance, me

          Thanks for both of your helps, I really appreciate it

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

My D1 is failing cause of not flushing final output. It was passing with incorrect interactor during contest. I was given option to drop from rating calculation

»
8 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Learning from Today's contest,I came up with correct solution of Div2D(For the champion problem) and was using map to store y coordinates with same x and then sorting it using below code:

Without Reference

Here i is a copy of each key-value pair in the map. i.second only changes the copy,the original map is untouched,in turn not sorting the real map, giving me WA. So instead use reference next time:

With Reference

Wrong Submission:336043993 Accepted Submission:336058516

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

for the subproblem of d1E if we want to "exactly" touch x+r and x+l shouldn't we do PIE with l+1 and r-1 instead of l-1 and r+1?

»
8 months ago, hide # |
Rev. 2  
Vote: I like it +11 Vote: I do not like it

I kind of have a different solution for 2135C - By the Assignment

We can figure out that any odd cycle should have 0s and even cycles should have the same value, and this is necessary and sufficient for the graph to be balanced.

With an understanding of cycle bases, and DFS Tree, it's sufficient to only consider cycles created by back edges in the DFS tree.

So, what remains is to make a DSU and try to unite all those in odd cycles, and check if there is any violation (max value on component > 0). Otherwise, set all odd-cycled components to 0.

Then, unite all those in even cycles, and check if there is any violation (two different non -1 values).

After that, count components with max value = -1.

How do you unite cycles exactly?

Here is an accepted submission

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

D2 :skull

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

The contest has really good problems. I am very weak, so I believe that the contest is not very friendly to people that are not good at ad-hoc and interaction problems (like me)

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hi,is there anyone who can explain the state transition equation in the problem C to me?

  • »
    »
    8 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    imagine the arr is like this 2,2,3,2,4,3,2,1,3

    now if you are at last 3 .. and want to calculate ans ENDING exactly at this index

    if there are < three counts of value 3 then we can't have any answer ending there. but we do have 3 counts of 3 ... so if an answer is ending here, where might last block start .. it will have to contain exactly 3 counts of 3, so we need to find index of 3 which is 2 positions behind current index .. and this index is denoted by x in the editorial (and in our example value of x is 2 )so you start block for 3 at index 2. now you have to add maximum possible subsequence ending before that x

    now in the editorial dp[i] means answer ending at 'i' or before, ie for prefix upto index i so dp transition just looks at previous index i-1 and previous index where valid block might have started

    • »
      »
      »
      8 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      Sorry,I still don't understand the purpose of x.Can you explain it more,please

      • »
        »
        »
        »
        8 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        do you know DP ?

        if yes you should try to create a solution which is bad in time complexity first and then you can optimize it to reach here

        otherwise you can ask me which part was not clear, I can explain that , but explaining DP will be difficult over comments.

        • »
          »
          »
          »
          »
          8 months ago, hide # ^ |
           
          Vote: I like it 0 Vote: I do not like it

          Maybe I only understand the surface of DP.But can x take any value from 1 to i-1?

          • »
            »
            »
            »
            »
            »
            8 months ago, hide # ^ |
            Rev. 2  
            Vote: I like it 0 Vote: I do not like it

            no .. if we are looking at i-th element then x = a[i] ie value at i-th index.

            So we are at i-th index and we want to check answer ending here, so we look at value at i position only

            • »
              »
              »
              »
              »
              »
              »
              8 months ago, hide # ^ |
               
              Vote: I like it 0 Vote: I do not like it

              Thank you very much.You are so good at coding and English.

              • »
                »
                »
                »
                »
                »
                »
                »
                8 months ago, hide # ^ |
                 
                Vote: I like it 0 Vote: I do not like it

                no problem,

                also I struggle with understanding editorials so I paste the whole editorial and ask chatgpt to explain it to me

                but at the end I add the prompt assume I know basic DP and basic programming so don't explain those things

                and if I don't understand something I keep asking it again and again

                it can help with both coding and english.. you can ask it to explain in simple terms and like step by step

                like I am literally doing this right now to upsolve div2E

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  8 months ago, hide # ^ |
                   
                  Vote: I like it 0 Vote: I do not like it

                  Yep,I usually use other AI tool to help with my coding skills.But I found they would sometimes make stupid problems,which drove me crazy.

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  8 months ago, hide # ^ |
                   
                  Vote: I like it 0 Vote: I do not like it

                  yeah , that is something we have to deal with right now .. hope these tools get more awesome with time.

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

                  fingers crossed

»
8 months ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

Can anyone help me debug my code for problem C? Also many along with me are getting Jury's verdict as 102nd numbers differ for the 2nd test. Can anyone get the exact test case? That will also help..

Anyways, speaking of my solution, I believed to have followed what the editorial says. Still I am unable to crack it. Either my implementation is not matching the logic (for which I am unable to find a test case where the mismatch occurs) or there is a slight misunderstanding in the logic I used to solve.

My submission

Thanks

  • »
    »
    8 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Found the test case — 2 1 2 2 So my logic was at flaw, got it.

  • »
    »
    8 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    didn't look in detail but I think this is similar to one mistake I made

    in both the if and else case you HAVE to do dp[i+] = max(dp[i+1], dp[i]) .. I think you are not doing it in the 'if' condition

    • »
      »
      »
      8 months ago, hide # ^ |
      Rev. 2  
      Vote: I like it 0 Vote: I do not like it

      No, what you have mentioned is only partially right, as the main issue was that when I encountered 2 1 2, here I was emptying my queue which stored the locations of 2, before going ahead. My solution was not pure dp, as I realized I was using a greedy queue, so since a better solution was found at 2, the previously lying answer [1] which interfered with the subsequence [2, 2] was no longer in memory. And with the next 2, my queue was storing the starting index, which will be 3, eventually leading to a non-optimal answer. Thus when the queue is fixed to continuously keep track of all positions, and following the editorial's logic, then as you rightly mentioned, the if-else cases dissolve.

      Corrected Solution for Reference

      Anyway thanks for looking into it

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Nice round, enjoyed the problems. Div. 2 D is truly amazing!

Came up with the idea of E quickly but didn't know how to find these two-edge-connected components lmao

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Thank you for the wonderful problems and the detailed editorial! It is disheartening to see so many people cheat on problem C. Or maybe I am just pessimistic and assume everyone is a cheater. Yet 8k seems like a suspiciously high number.

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

theres no way they didnt weed out cheaters, 8k submissions on C problem is insane, how did i get negative delta after solving 3 problems as pupil wtf

  • »
    »
    8 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    wow negative delta after solving 3 problems FOR A PUPIL ... lol .. this is just mind blowing..

    I am doing CP before AI stuff, I am quite sure I rarely solved 4 questions before reaching expert

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it
MyCode

I wonder why this code gets Time limit exceeded on test 2.Is it because I used getchar() and puts() to interact ?

»
8 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

May I ask for better samples in the next contests please? I guess one of the reasons was that in this contest samples were much less informative than in others and that let me to many small bugs, which took a lot of time to find

In B I added the number of minimal diagonal instead of subtracting it, and ALL of the points in both testcases were on 0th diagonal, like, why?

In C I had written 2 similar solutions and both had small bugs, maybe there aren't any small samples which catch those.

I know that samples don't have to cover all special cases and all, but usually they do. In AtCoder contests there's also some big testcase in the end, that's usually used to check your answer because it takes a long time to observe something on the testcase. I'd appreciate if you did so next time

»
8 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

I solved div2 C using dp + data structures + binary search.. i know it is more redundant, but it comes down to what i'm most comfortable with during the contest :) https://mirror.codeforces.com/contest/2136/submission/336004436

»
8 months ago, hide # |
 
Vote: I like it +16 Vote: I do not like it

Why D2 gives the constraint so tight? I just check for B=142 and N*B=719660 and it gives 25012 operations , it takes me crazy Not saying D is a bad problem,just for some complaints of the constraints.

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Could someone suggest problems similar to Div. 2 C: 2136C - Against the Difference?

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

The solution code for this problem is incorrect (2135C — By the Assignment). It submitted the same code as for this problem (2135D2 — From the Unknown (Hard Version)), and I hope there is correct code.: 2135D2 — From the Unknown (Hard Version)

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I was really confused about why we use N=11343,B=116.In other words,how can I get them?

  • »
    »
    8 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    You can use brute force to get them, the running time in local is acceptable. The author said he get them by dp, but I don't clearly know how to dp hmmmmm.

»
8 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

336124323 in the first test case W = 20, I am outputting 160s in the first query and the interactor responds with 2, isn't it supposed to respond back with 0?

any help will be appreciated!

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int>v(n+1);
        vector<int>dp(n+1,0);
        vector<int>dem(n+1,0);
        vector<int>vitri(n+1,-1);
        for(int i=1;i<=n;i++)
            cin>>v[i];
        for(int i=1;i<=n;i++){
            dem[v[i]]++;
            if(vitri[v[i]]==-1)
                vitri[v[i]]=i;
            if(dem[v[i]]==v[i]){
                dp[i]=max(dp[i],dp[vitri[v[i]]-1]+v[i]);
                vitri[v[i]]=-1;
                dem[v[i]]=0;
            }
            else{
                dp[i]=dp[i-1];
            }
        }
        cout<<dp[n]<<"\n";
    }
    return 0;
}

why my code in problem C is wrong, pls check everyone :(((

»
8 months ago, hide # |
 
Vote: I like it +18 Vote: I do not like it

I think I have some ideas that can further reduce the $$$\sum n$$$ in Div. 1 D2.

The main observation is that when $$$W$$$ is small, instead of only using copies of $$$1$$$, we can actually insert $$$2$$$ in our second query (If $$$W=1$$$ we'd just get a $$$0$$$).
Assuming we'd be using a lot of $$$2$$$, the function of $$$1$$$ mostly becomes “distinguish odd and even $$$W$$$”, which would imply $$$1$$$ is very sparse (so that two $$$1$$$s wouldn't "neutralize" each other). From there on it's basically trial and error. For example, when $$$B=150$$$, you can generate an article that can distinguish all $$$W\in[1,B]$$$ by putting $$$1$$$ copy of $$$1$$$, $$$127$$$ copies of $$$2$$$, and repeat this for $$$75$$$ times. The rest are pretty much the same.

By choosing $$$N=10800$$$ and $$$B=150$$$, we can yield a $$$\sum n\leq21598$$$ solution. There's most likely room to reduce it even more by picking different $$$N,B$$$ and the article that deals with small $$$W$$$ .

(In fact when I was first solving this I mistakenly used a $$$n=3(R-L)$$$ query in the big $$$W$$$ case, but was somehow still able to pass with this optimization...)

»
8 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

Can someone help me understand what is wrong with my solution for Div2C 336218122

My logic was:

ans[i][action] denotes number of neat subsequences in the subarray indexed (0 indexed) [i, n — 1] such that the i'th element was taken according to the 'action'

Action is 0 if this element is the last of its block. Action is 1 if this element is somewhere in the middle (or beginning) of a block that ends at j, st. j >= i.

I increment ans only when a block is STARTED (since I am going backwards).

Recurrence:

If we want to end a block at i, then just take the maximum number of subsequences that have occured at any index after i (+1 if nums[i] is 1)

When considering i, let nxt[num] be the index of num at any index after i. And cum[i] be the number of numbers equal to nums[i] at indices j >= i.

Then if we want i to be a non-ending part of a block, then find the index of next number in this block, which is nxt[nums[i]], and use its cum to update cum[i].

If cum[i] after update becomes a multiple of nums[i], increment ans[i][?] by nums[i].

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

In problem E how For odd length cycle the nodes value must be zero ? Is there a proof ? I am Quite Confused ?

  • »
    »
    8 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    If you can see that, elements must be same in a cycle where i-th node is equal to the node i + 2, i + 4 and so on........ that way you can prove it to be zero for ODD cases.

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

how is div2 C rated less than 1200 on clist??????

»
8 months ago, hide # |
 
Vote: I like it +10 Vote: I do not like it

Div 1 B (Div 2 D) was such a beautiful problem with fairly easy solution. Loved solving this contest.

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

In the editorial for problem C, it says that we have to find the two-edge-connected-components. But the code provided for it uses strongly-connected-components. I tried to solve it using TECC but it gets WA. Here is a bit of the code:

void dfs(int u, int p) {
  visited[u] = true;
  tin[u] = low[u] = ++timer;

  for (const auto & [v, id]: adj[u]) {
    if (v == p) {
      continue;
    }

    if (visited[v]) {
      low[u] = std::min(low[u], tin[v]);
    } else {
      dfs(v, u);
      low[u] = std::min(low[u], low[v]);
      if (tin[u] < low[v]) {
        isBridge[id] = true;
      }
    }
  }
}

bool dfsColoring(int u, int p, int c) {
  color[u] = c;
  bool isOddCycle = false;

  if (nodeValue == -1 or nodeValue == weight[u]) {
    nodeValue = weight[u];
  } else if (weight[u] != -1) {
    allSame = false;
  }

  for (const auto & [v, id]: adj[u]) {
    if (isBridge[id] or v == p) {
      continue;
    }

    if (color[v] == -1) {
      isOddCycle = isOddCycle or dfsColoring(v, u, c ^ 1);
    } else if (color[u] == color[v]) {
      isOddCycle = true;
    }
  }

  return isOddCycle;
}    

Am I missing something? Can someone kindly help? I think I misunderstood something.

»
8 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

Why do I feel like the solution to problem 2135B might be incorrect? $$$\min\limits_{1 \leq i \leq n}(\lvert x_i - X'\rvert + \lvert y_i - Y'\rvert) = \min\limits_{1 \leq i \leq n}(X' - x_i + y_i - Y')$$$

I think it should

$$$\min\limits_{1 \leq i \leq n}(\lvert x_i - X'\rvert + \lvert y_i - Y'\rvert) = \min\limits_{1 \leq i \leq n}(x_i - X' + y_i - Y')$$$

»
8 months ago, hide # |
Rev. 4  
Vote: I like it 0 Vote: I do not like it

Problem F:

Test case: (n) 11, (1) 2 7, (2) 3 4, (3) 0 0, (4) 5 6, (5) 0 0, (6) 0 0, (7) 8 11, (8) 9 10, (9) 0 0, (10) 0 0, (11) 0 0

What should be the output? If I run it with the provided solution I get

3 5 6 9 10 11 4 8 7 2 1

But according to my understanding, here 2 and 7 has same value for f(x), so 2 should come first since 2 < 7. What am I missing here? img

»
8 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can anyone explain the Hint 2 of 1E

»
8 months ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

Deleted

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can someone tell me how can i optimise my code: https://mirror.codeforces.com/contest/2136/submission/337101177

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

In the 6th sample input in problem C shouldn't the blocks be [1][1][1][2,2][3,3,3] and the answer be 8?

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

In 2135C — By the Assignment, my submission has low[u]==low[v] in is_bipartite and get WA. Why is it wrong? I think that nodes in the same two-edge connected components have the same low values. If I set scc_id for each node and compare scc_id[u]==scc_id[v] then get AC.

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Thank you for providing such amazing problems especially D & E!

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

nice problem a)) before contest i should read football rules to understant that score after 1 half don't reset??

»
7 months ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

I want to ask div1 C. My solution is as follows.

  1. Make a DFS-tree from node 1. (preprocess parent, depth for each node)

  2. If the back edge length is odd, which is calculated by depth, allocate all node to zero. If there is any value a[i] > 0, return 0.

  3. If the back edge length is even, allocate all node to some value V, if all a[i] = -1. If there are two more value in a[i], return 0.

  4. I just use DSU for merging nodes in cycle.

Does this solution is different from two edge connected component solution? Even I heard this concept in this editiorial first.. Thank you in advance!

»
7 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Could you give the proof for the sufficient and necessary condition for problem div1E?

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Problems are amazing, it makes me feel very satisfied after solving them. Thank you, authors

»
4 months ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

C is Good.