Vectors_Master's blog

By Vectors_Master, 2 weeks ago, In English

We hope you enjoyed the problems! Thank you for participating in the contest! We would love to hear your feedback in the comments.


How did you find the contest?
Which problem was your favorite?
Which problem did you find the least enjoyable?


2071A - The Play Never Ends

Hints
Solution
Code
Rate the Problem

2071B - Perfecto

Hints
Solution
Code
Rate the Problem

2071C - Trapmigiano Reggiano

Hints
Solution
Code
Rate the Problem

2071D1 - Infinite Sequence (Easy Version)

Hints
Solution
Code
Rate the Problem

2071D2 - Infinite Sequence (Hard Version)

Hints
Solution
Code
Rate the Problem

2071E - LeaFall

Hints
Solution
Code
Rate the Problem

2071F - Towering Arrays

Hints
Solution
Code
Rate the Problem
  • Vote: I like it
  • +173
  • Vote: I do not like it

»
2 weeks ago, # |
  Vote: I like it +9 Vote: I do not like it

very interesting problems!, thanks you all

  • »
    »
    2 weeks ago, # ^ |
      Vote: I like it +16 Vote: I do not like it

    B was Cool!

    • »
      »
      »
      2 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Very true! When i finally solved, I felt very happy NGL!!

  • »
    »
    13 days ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    The difficulty level of the first four questions and the last three questions is a bit high, TT,Does anyone think like me that the color of Specialist is the best among all levels.

»
2 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Why is there no Hints on D???

»
2 weeks ago, # |
  Vote: I like it +3 Vote: I do not like it

How to come up with solutions for problems like C ? I figured en to be the last one in the permutation but couldn't progress further.

  • »
    »
    2 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    practice makes perfect

    • »
      »
      »
      2 weeks ago, # ^ |
      Rev. 2   Vote: I like it +2 Vote: I do not like it

      Obv, can you tell how you came up with solution for C ?

      • »
        »
        »
        »
        2 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        How do you write dfs? so in dfs you print root at before going to its childrens or after both are valid, since you thought en is last your brain needed to think how can i make en as last and make permuation which is ending at en so if you do a dfs from en that is your answer. so you are doing dfs and printing root at last and you wanted en to be last so en would be our root and since it is a tree path from st to en is always their.

      • »
        »
        »
        »
        2 weeks ago, # ^ |
        Rev. 2   Vote: I like it +1 Vote: I do not like it

        I actually got the same solution as the editorial

        Basically, by past problem solving experiences, I tried rooting "en" because it was my target, so measuring how distant I am from it would be easier if it was the root because the distance will simply be the height of the current node

        Then it was trial and error, initially I though about climbing the tree and then take turns on each neighbor of the root, until after some time testing I realized that if I did this backwards (starting from the deepest level) would make it easy to predict my height

        Tbh the advice will always end up on "solve more problems" Like, rooting a node is a standard idea that you will see in many other tree problems, so at some point you expect this will help

      • »
        »
        »
        »
        2 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Reverse dfs

  • »
    »
    2 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    You can do a simple post-order traversal on the tree and that would give you the answer.

»
2 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

What is the solution for D1?? is it standard typre problem??

»
2 weeks ago, # |
  Vote: I like it +3 Vote: I do not like it

I am shocked to find out that the answer for C doesn't depend on st

  • »
    »
    2 weeks ago, # ^ |
    Rev. 2   Vote: I like it +3 Vote: I do not like it

    Not all approaches, one may come up with some approach that really depends on st.

    Check my solution for example : 308367585

    • »
      »
      »
      2 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      ye mine relies on st too. But the tutorial solution is really nice to know.

»
2 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

https://codeforces.net/contest/2071/submission/308387650 why is my approach getting wa at tc 2 can anyone tell me what am i missing?

  • »
    »
    2 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Consider the tree 2<->1<->3<->4<->5 with st 3 and en 5. Your code would print it 1, 2, 3, 4, 5, since 1 and 2 are in rem and 3 4 5 are in ans1. The way the rat would move like 3 -> 2 -> 1 -> 2 -> 3 -> 4, failing to reach 5.

    The problem is that you are not printing the other nodes in order of their depth, but rather just the order of their number.

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

      Ohhh yea got it,the path you told about my rat i didn’t follow that can you elaborate ?

      • »
        »
        »
        »
        2 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Path should be 3->1->2->1->3->->4 and not reaching 5 so yea my ans ain’t right

»
2 weeks ago, # |
  Vote: I like it +30 Vote: I do not like it

what an amazing solution to C!

i had a completely different solution.

  • »
    »
    2 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    please share your approach

    • »
      »
      »
      2 weeks ago, # ^ |
      Rev. 2   Vote: I like it +1 Vote: I do not like it

      Key Observation: If we start at a vertex x and perform a postorder traversal rooted at x, we get all the vertices in x’s subtree and we end up at x. This can be verified with examples.

      Solution Approach:

      we root at st, If we are at en, we perform a postorder traversal and add all visited vertices to our answer. Otherwise, we perform a postorder traversal from each node between st and en, but we exclude the subtree containing en. We keep adding the visited nodes to our answer. Finally, we move into the subtree that contains en and continue the process. By following this approach recursively, we obtain the required answer.

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

        can u tell like how did you get such a observation that for any subtree doing postorder will eventually lead to the current node itself . I had a stupid idea of first going to the target node and then keep choosing the leafnodes rooted at st . Idk what i was thinking . I thought of it as the push/pull kind of system .

        • »
          »
          »
          »
          »
          2 weeks ago, # ^ |
            Vote: I like it +1 Vote: I do not like it

          i had the idea because i observed if we keep take lower nodes first, then go up from there, we would ultimately reach up as specified in the official solution, but then i realized, doing postorder which also lead to same conclusion.

        • »
          »
          »
          »
          »
          13 days ago, # ^ |
          Rev. 5   Vote: I like it +1 Vote: I do not like it

          you can visualize it with examples , its just that a reversed order

          of traversal will allow you to reach half the distance then comeback

          so if we take an example [1 , 2 , 3 , 4]

          Start at node 1.
          
          Cheese at 4:
              The mouse moves one edge: from 1 to 2.
          
          Cheese at 3:
              The mouse moves one edge: from 2 to 3.
          
          Cheese at 2: 
              The mouse moves one edge: from 3 back to 2.
          
          Cheese at 1:
              The mouse moves one edge: from 2 back to 1.

          therefore the solution is just process all the nodes that doesnt lead to the end node in a reversed order (so that you come back where you started ready to visit other paths) , and process the nodes that lead to the end node in a normal order

          you can also look at my code if you want https://codeforces.net/contest/2071/submission/308726433

          hope that helps !!

          • »
            »
            »
            »
            »
            »
            8 days ago, # ^ |
            Rev. 4   Vote: I like it 0 Vote: I do not like it

            My code is giving MLE , but the approach is same as that of yours

            can you suggest how to optimise it ? please suggest how to get rid of memory limit exceeded error submission

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

              i cant read cpp code unfortuantely , i am a python user

»
2 weeks ago, # |
  Vote: I like it +8 Vote: I do not like it

Will be added soon(

»
2 weeks ago, # |
  Vote: I like it +32 Vote: I do not like it

Love the problems thx guys (⁠。⁠♡⁠‿⁠♡⁠。⁠)

»
2 weeks ago, # |
  Vote: I like it +23 Vote: I do not like it

C was excellent. Really excellent.

»
2 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

what happened to D editorial

  • »
    »
    2 weeks ago, # ^ |
      Vote: I like it +19 Vote: I do not like it

    You can check it now. We added it.

    • »
      »
      »
      2 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      What's the significance of

      if ((x / 2 - n) % 2 == 0) {
                  break;
              }

      In D1 solution

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

        I think it is just the main idea of the solution. This line checks whether x/2 is an odd number. If it is, this means that a_x will be just equal to p (p = a1^a2^a3^...^an) and we can stop executimg the loop -> stoping the recursion -> we got the answer

        There is a very good explanation of that in a solution part

        • »
          »
          »
          »
          »
          2 weeks ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          But why to subtract from n first?

          • »
            »
            »
            »
            »
            »
            2 weeks ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            I do not know, but in any case n is odd, so (x / 2 — n) % 2 == 0 will be just equevalent to (x/2) % 2 == 1

          • »
            »
            »
            »
            »
            »
            12 days ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            Let x be current x, and x/2 is next x. We already made n as an odd number. if ((x / 2 — n) % 2 == 0) is true, that means the number of elements from n+1 to x/2 (next x) is even. Again, that means xor sum of a[n+1]^a[N+2]^.....^a[x/2] is 0 as every 2 elements are the same. So yeah, if above if statements gives us true, we dont need to go further.

»
2 weeks ago, # |
  Vote: I like it +5 Vote: I do not like it

Great round ! The problems were well-balanced and had interesting ideas. Really enjoyed solving them, especially 2071B - Perfecto.

Thanks to the Setters and Testers for the effort :)

»
2 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

During the contest, I read task C incorrectly, which made it seem very difficult to me and I decided to skip it. I thought the mouse could NOT pass through en earlier during the process. Now I'm wondering, if there's any elegant and easy solution for this task, because the solution I was able to come up with doesn't seem simple.

  • »
    »
    2 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Just Use Post Order Traversal from the end point and print the order. IG it works because when you try to the solve from the end point you have limited nodes to work with like 1 distance from end node and then 2... and so on.

    • »
      »
      »
      2 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      No, I was talking about a modified version of the task(where mouse cannot pass through en earlier). This solution does not work in this case.

      • »
        »
        »
        »
        12 days ago, # ^ |
        Rev. 2   Vote: I like it -8 Vote: I do not like it

        one solution to problem C is, rooting at en and placing the cheese at one of the remaining leaf nodes (if en becomes leaf we avoid it) and keep doing until en remains. finally place at en.

        let R be set of remaining nodes on which cheese hasnt been placed. it happens that rat will always be present in R or neighbours of nodes in R. i cant prove it, but proof by AC.

        you can similary use this theory for the modified version. let SZ be sum of all subtress of children of en. and SZV be size of the child subtree in which en is present. if SZ — SZV >= SZV, you will always pass en and have some remaining nodes. for SZ — SZV < SZV, we can call alternatingly and make SZ — SZV = 0, then the remaining tree will be tree rooted at en, and subtree in which en is present only. for this tree you can use my approach to reach en at the end.

        point out if anything was "unclear"

»
2 weeks ago, # |
  Vote: I like it +1 Vote: I do not like it

I think this round is harder than the Edu round 1006, but at least the problem is interesting. My friend encountered serveral corner cases which made him crazy!

»
2 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Thank you for the great problems! I really enjoyed problem C, it was very nice. For problem B, I used a randomized solution 308317488.

»
2 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Why should we double n when we solve problem D?

»
2 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Where can I see the testcases for problem B?

»
2 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

I had tried a different solution than the editorial, for Problem C. You can root the tree at node st, and then start a DFS traversal from the root, while pushing back values in an answer list. Say current node is u, then 3 cases arise:

  1. subtree of node u doesn't contain the en node: then first visit all children, and then pushback u (post-order)

  2. u is the en node: then again, do post-order

  3. subtree of u contains en node, but u is not en node: then first visit all branches of the tree that don't have the en node, and then pushback u, and then visit the branch containing en node (in-order).

https://codeforces.net/contest/2071/submission/308386874

The basic idea is that, if you are standing at root of a tree, and you place the cheese in the order of post-order traversal for the nodes of tree other than the root, then in the end, you will end up at an immediate chid of the root, and then placing cheese at the root, will bring you back to root.

»
2 weeks ago, # |
  Vote: I like it +8 Vote: I do not like it

Sir's, round was so cool and problems are good quality, if you add 2 more hard problems round will be definitely a good Div1+2 :)

»
2 weeks ago, # |
  Vote: I like it +8 Vote: I do not like it

For problem C I have taken the root as en and then the post order traversal of that tree gives the permutation. Not sure why this is working. Can someone help in building the intuition behind this approach?

https://codeforces.net/contest/2071/submission/308378910

»
2 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

For c , My approach was that we are starting with node start , then we will have one and only path from start to end , lets use this path at the very last in permutation , it means that after performing all non final path edge (ie nodes that are not in this path) we have to land on starting node , but how to do this ??

»
2 weeks ago, # |
Rev. 2   Vote: I like it +6 Vote: I do not like it

This might probably be the simplest solution to problem B (although very tough to come up with):

  1. First, ensure that n * (n + 1) / 2 is not a perfect square, as mentioned in the editorial (I personally used binary search. Had to use unsigned long long).
  2. After that, print all numbers from 1 to n, except the number 4. Swap 1 and 2 because 1 is a perfect square.
  3. Put 4 at the end of permutation. Done!!

I verified the solution by confirming that for all n from 5 to 5e5, (n * (n + 1) / 2) — 4 is not a perfect square. You can have a look at my submission here

»
2 weeks ago, # |
  Vote: I like it +6 Vote: I do not like it

Also in problem B if $$$\frac{n*(n + 1)}{2}$$$ is not a perfect square you can just generate random permutations submission

»
2 weeks ago, # |
  Vote: I like it +8 Vote: I do not like it

2071D1 - Infinite Sequence (Easy Version) can anyone tell me in D1 why n is needed to converted to odd . please explain the solution to me.

  • »
    »
    2 weeks ago, # ^ |
    Rev. 3   Vote: I like it +21 Vote: I do not like it

    Because each even number cancels out its subsequent odd number. When n is odd, (n+1) will be even and (n+2) is odd. Therefore, they will cancel out each other.

    It's just a trick to make the computations easier. You can solve the problem without it (but you will need to handle (n+1)-th term each time separately).

    • »
      »
      »
      2 weeks ago, # ^ |
        Vote: I like it +8 Vote: I do not like it

      Now I understand! Thanks for the explanation.

    • »
      »
      »
      2 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Why in D1 we extend a till (2 * n). Why can't we stop after making n odd and have the following condition instead of (x <= 2 * n)? if (x <= n) { ret ^= a[x]; break; }

»
2 weeks ago, # |
  Vote: I like it +5 Vote: I do not like it

Is it just me or B seems easier than average Div 2 contests cuz I usually take 1 hour to do this problem but for some reason, I did this B in 20 min

»
2 weeks ago, # |
  Vote: I like it +39 Vote: I do not like it

My solution for D2.

First, check the editorial of D1.

DP Approach
Code
»
2 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Thank you very much for the hints you left for each question. I wish all contests had this...

»
2 weeks ago, # |
  Vote: I like it +15 Vote: I do not like it

Alternative solution for B

Hint 1
Hint 2
Solution
»
2 weeks ago, # |
  Vote: I like it +23 Vote: I do not like it

For problem E, a vertex becomes a leaf if it is connected to exactly one edge. But in the editorial, for the third category all the neighbors are being removed. How would the vertex become a leaf with zero edges connected to it?

  • »
    »
    13 days ago, # ^ |
      Vote: I like it +14 Vote: I do not like it

    Thanks for catching this mistake, exactly one of the neighbours must not fall. Fixed.

    • »
      »
      »
      13 days ago, # ^ |
        Vote: I like it +8 Vote: I do not like it

      In the solution of problem E in order to calculate contribution2(u, v) you separate it to two cases: when u and v share a neighbor s,

      1. All neighbors of u and v are removed except for s
      2. s is removed and all but one of the neighbors of u and v are removed

      In the editorial, the value for the second case (2.) is

      $$$(1 - fall_{u})\cdot(1 - fall_{v})\cdot(1 - fall_{s})\cdot e_{u}\cdot e_{v}$$$

      However, $$$(1 - fall_{s})$$$ implies that s is not removed from the tree. Should this not be $$$fall_{s}$$$ instead? Thus, I think (2.) should be given by

      $$$(1 - fall_{u})\cdot(1 - fall_{v})\cdot fall_{s}\cdot e_{u}\cdot e_{v}$$$
»
13 days ago, # |
  Vote: I like it +16 Vote: I do not like it

I think there is a mistake in E's editorial (I might be wrong).

In the second category, u and v can share a common neighbour, but we need to calculate the probability that they become leaves whilst also having the common neighbour falls (it can happen that a neighbour of u doesn't fall (other than s) and a neighbour of v doesn't fall (other than s) and s falls and all other neighbours of u and v fall.

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it
import java.util.Scanner;

public class Q10072 {

    private static boolean isPerfect(long x){
        long sqrt = (long) Math.sqrt(x);
        return (sqrt*sqrt == x);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0) {
            long n = sc.nextInt();
            long sumTot = n*(n+1)/2;
            if (isPerfect(sumTot)) {
                System.out.println(-1);
            }else{
                long sum = 0;
                for (int i = 1; i <= n; i++){
                    sum += i;
                    if (isPerfect(sum)){
                        System.out.print((i+1) + " " + (i) + " ");
                        sum += i+1;
                        i++;
                    }else{
                        System.out.print((i) + " ");
                    }
                }
                System.out.println();
            }
        }
    }
}

this code giving TLE is it any but its time complexity is O(n)

»
13 days ago, # |
  Vote: I like it +8 Vote: I do not like it

(x+1)^2≤y^2 in problem B shouldn't it be ? (x+1)^2 > y^2

  • »
    »
    12 days ago, # ^ |
      Vote: I like it +26 Vote: I do not like it
    • $$$x^2$$$ is the sum of integers up to $$$k$$$.
    • $$$y^2$$$ should be the sum of integers up to $$$k+1$$$.

    Therefore, $$$(x+1)^2 \leq y^2$$$.

    However, the sum of integers up to $$$k+1$$$ cannot be a perfect square because this will lead to a contradiction $$$(x+1)^2 > y^2$$$

»
12 days ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Problem C can be solve by rooted en and doing postorder transversal Claim:I am new and not professional,so please correct me for wrong proof

If you are looking for not professional proof then you can skip this part. First,we need to do some heuristic observation,if we can't solve problem with n=1e5,then we can try solve with n is small for example n=3,assume a tree with n=3 vertex with edge (1,2),(1,3),we assume that 1 is the root,then no matter which vertex(1 or 2 or 3) we choose,the end point will always be 1,then we can try for n=4,n=5,...,the answer is still satisfy the criterion above,so this may be a correct idea,then we can try to do a simple prove.

Claim 1:If the mouse currently at point u and postorder transversal is at subtree of point u then the mouse will definitely end at root of subtree. As the observation before we found that no matter start point at where the end point always is root but why?The main reason is the characteristic of postorder,in postorder parent will located at the end so there is two thing will happen,after transversal at the last point,first we are at parent,in this problem if we transverse for A to A then we will not move,so obviouly we will at the parent,Second if we are at the child,then we will transverse from child to parent,so we will also end at parent,after this we prove for n=3 then you can generalized to n=k by mathematical induction

Claim 2:No matter start point at where,the transversal will meet the mouse. By the claim 1,if the transversal is currently at the point with mouse then mouse will end at the root,so we want to prove that this thing will definitely happen.

There is two condition,you can separate the child of the root into two part,let say L part and R part, Since postorder start from left part(from left to right,from bottom to root),then First if the mouse is also at L part, obviously when mouse is at L part then when postorder start,the transversal will start from bottom to top,and the mouse will move from top to bottom then they will meet. Second,if the mouse is al R part,there also two condtion which is,before L part end the mouse move from R part to L part then by the previous result if the mouse and transversal is at the same part they will meet,or when L part end mouse still at R part but transveral will move from L part to R part which is same part with mouse,so they will also meet. So mouse and the transversal will always meet.

This is a roughly proof and not professional 308771732

»
12 days ago, # |
  Vote: I like it +11 Vote: I do not like it

A video tutorial for E . Let me know if you have any feedback!

»
12 days ago, # |
  Vote: I like it +1 Vote: I do not like it

I didn't understand the editorial for D2, could someone explain it?

  • »
    »
    12 days ago, # ^ |
    Rev. 3   Vote: I like it +1 Vote: I do not like it

    I didn't understand the editorial either, especially the 1 mod 4 part but here's my solution:

    There are two key high level ideas used here. 1. whenever asked about ranges try calculating prefix sums. (This is highly useful in digit dp problems) 2. 1^x = 1-x if x $$$\in$$$ {0,1}

    now first observe nature of P (the prefix xors)

    for i > 2*n+1 you have BASE^$$$A_{2*n+2}$$$ , BASE, BASE^$$$A_{2*n+4}$$$, BASE .. (Notice how only even indices of A are used here!)

    where BASE = $$$P_n$$$ ^ $$$A_{n+1}$$$ (if n is even) and $$$P_n$$$ (if n is odd).

    now observe the nature of A

    for i > n you have $$$A_i$$$ = $$$P_{i/2}$$$ so for some 2*k > n $$$A_{2*k}$$$ = $$$A_{2*k+1}$$$ = $$$P_{k}$$$

    so if you're asked for the prefix sums of A -> you're actually asking the prefix sums of P for half the length. (This should brighten a bulb inside you which screams log(n) )

    now if you're asking to calculate the prefix sums of P upto k you realize its some recomputable term upto 2*n+1, and after that you alternate between BASE and BASE^(even term of A). you can count the number of BASE that would appear upto K and add it up and what's left are BASE^$$$A_{2*k}$$$ terms.

    since you know after n : $$$A_{2*k}$$$ = $$$A_{2*k+1}$$$ = $$$P_{k}$$$ you can use this to write down the prefix sum of A as a function of the sums upto n, the sum of even terms and odd terms after n. and this gives you a way of computing the sum of even terms !

    you now have all the recipes for your solution. when asked about prefix sum of A upto k => you ask what's the prefix sum of P upto k/2 which asks the sum of even terms upto k/2 and so on. The trick for computing sums where each term is xor'd with BASE when BASE = 1 is : term^1 = 1 — term.

    I leave the implementation details for you to figure out but here's my submission : 308654304

»
12 days ago, # |
  Vote: I like it 0 Vote: I do not like it

could someone explain the jiangly's solution to problem F?

»
12 days ago, # |
  Vote: I like it 0 Vote: I do not like it

If you need to eat as much cheese as possible for question C, is there a solution?

  • »
    »
    11 days ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    even tho , the solution will be the same , no ?

    As you can only move one edge per cheese location thus you can only collect half the cheese

    in a certain path , as you need to comeback for visiting other paths

    correct me if i am wrong !

    • »
      »
      »
      11 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      If the node where s is located has a large depth, should it be put into the subtree of s according to the depth first?

      • »
        »
        »
        »
        11 days ago, # ^ |
        Rev. 3   Vote: I like it 0 Vote: I do not like it

        i dont exactly understand what you mean by S ,

        i think cause of the traversing constraints of the problem , you can only

        collect half the cheese at each path (where en node is the root) , it

        doesnt really matter how deep that path is ,

        For example if this is your path 1 -> 2 -> 3 -> 4

        that should be the cheese distrubtion

        Cheese at 4: The mouse moves one edge: from 1 to 2.

        Cheese at 3: The mouse moves one edge: from 2 to 3.

        NOW you are gonna start collecting the cheese on your way back

        Cheese at 2: The mouse moves one edge: from 3 back to 2.

        Cheese at 1: The mouse moves one edge: from 2 back to 1.

        this cheese distribution permutation is pretty much needed as it is the only one that guarntees ending at en , any other permutation is risking going too deep into a path

        • »
          »
          »
          »
          »
          11 days ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          I'm sorry, I'm not very good at English, I mean whether a different starting point will lead to a better result for a different arrangement of nodes of the same depth, or an arrangement that can go back to the end point if it doesn't exactly follow the order of depth priority

          • »
            »
            »
            »
            »
            »
            10 days ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            good question , No a different starting node doesnt matter

            also we dont visit paths depending on there depths' , the

            whole idea is just to reverse all the paths connected to the

            end node , it doesnt matter which order you go in reversing

            them , you just need them reversed

»
11 days ago, # |
  Vote: I like it 0 Vote: I do not like it

When the submissions will be rejudged??

or detecting cheaters for this round??

»
11 days ago, # |
  Vote: I like it 0 Vote: I do not like it

In the editorial for F, in Elaboration, shouldn't the maximum "increasing" p-towering subsequence will look like this after processing 10th index: [6,3,8,5,7] (3 will be included as well, right?)

»
10 days ago, # |
  Vote: I like it 0 Vote: I do not like it

How to calculate $$$e$$$ in D2?

  • »
    »
    10 days ago, # ^ |
      Vote: I like it +14 Vote: I do not like it

    The sum over even-indexed elements in the range $$$[n + 1, \lfloor \frac{m}{2} \rfloor]$$$ is defined as:

    $$$ $$$
    $$$ e = \displaystyle\sum_{\substack{n < i \leq \lfloor \frac{m}{2} \rfloor \\ i \text{ even}}} a_i = a_{n+1} + a_{n+3} + \dots + a_{\lfloor \frac{m}{2} \rfloor}. $$$

    To compute this efficiently, we utilize the recursive function $$$\text{sum}(\lfloor \frac{m}{2} \rfloor)$$$ that returns two values: the sum of even-indexed and odd-indexed terms up to $$$\lfloor \frac{m}{2} \rfloor$$$. To exclude terms before $$$n + 1$$$, we subtract the prefix sum of even indices up to $$$n$$$:

    $$$ $$$
    $$$ e = \text{sum}(\lfloor \frac{m}{2} \rfloor)_{\text{even}} - prefix_{\text{even}}(n). $$$
»
10 days ago, # |
  Vote: I like it +8 Vote: I do not like it

I think D2 can be solved even if we allow array values to be up to 1e18, something like this https://codeforces.net/contest/2071/submission/308895384

since the sum of the interval to find can exceed long long limit maybe we could find mod of the value?

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

    Yeah but I think it's straightforward and not very interesting.

»
9 days ago, # |
  Vote: I like it +8 Vote: I do not like it

for B, you can simply find the values (say k) that such 1 + 2 + 3 ... + k is a perfect square (there are only a few). You can avoid this subarray by swapping k with the number ahead of it, ie making the sequence 1 + 2 + 3 ... k-1 + k+1 + k. If theres no "next" number, the answer is -1.

Like this

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

All you need is attention.For C,just dfs from en and output the index when backtracking.I found this after a long thought.

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

I think there is a typo in the solution of Problem A.

As a result, Fofo won't be able to spectate in the k-th match for any k of the form 3x+1.

It should be-

As a result, Fofo would be able to spectate in the k-th match for any k of the from 3x+1.

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

Why is java O(n) code for problem B giving TLE. submission

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

my code for second question i implemented differently 310238565 ~~~~~

int n;cin>>n;

int sum=(n*(n+1))/2;

if(floor(sqrt(sum))==ceil(sqrt(sum)))

{

cout<<-1<<"\n";

return;

}

else

{

if(n>8)

{

    cout<<2<<" "<<1<<" "<<"\n";

for (int i = 3; i <=n; ++i)

{ if(i!=8)

{

  cout<<i<<" ";

}

}

cout<<8<<" ";

cout<<"\n";

return;

}

cout<<2<<" "<<1<<" ";

for (int i = 3; i <=n; ++i)

{

cout<<i<<" ";

}

cout<<"\n"; } ~~~~~

»
2 days ago, # |
  Vote: I like it 0 Vote: I do not like it

why we must prove (k + 1)(k + 2) / 2 cannot also be a perfect square ? i don't understand

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

i received a warning for a submission but i haven't cheated i just formatted the code so may be the code looks same so it is humble request not to take any strict action against me. Hope you understand thank you.