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

Автор Error_Yuan, 12 месяцев назад, По-английски
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!
Разбор задач Codeforces Round 1046 (Div. 1)
Разбор задач Codeforces Round 1046 (Div. 2)
  • Проголосовать: нравится
  • +218
  • Проголосовать: не нравится

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

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

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

thanks for nice problems and quick editorial.

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

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

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

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

»
12 месяцев назад, скрыть # |
Rev. 5  
Проголосовать: нравится 0 Проголосовать: не нравится
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?

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

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.

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

Thanks for amazing problems and amazing round!

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

    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.

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

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

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

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

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

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? .

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

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$$$?

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

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

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

    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.

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

      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

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

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

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

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

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

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?

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

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

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

D2 :skull

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

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)

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

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

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

    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

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

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

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

    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

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

      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

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

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

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

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

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

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

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

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://codeforces.me/contest/2136/submission/336004436

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

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.

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

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

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

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)

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

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

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

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!

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

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...)

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

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

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

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

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

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.

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

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

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

Can anyone explain the Hint 2 of 1E

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

Deleted

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

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

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

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?

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

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.

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

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

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

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

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

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!

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

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

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

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

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

C is Good.

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

I don't know if I'm crazy, but the editorial for 2135B has to wrong right? How can it claim that by going up twice Y' is gonna be less or equal to 10^9? Y' should actually be greater or equal to 10^9