Vectors_Master's blog

By Vectors_Master, 14 months 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
  • +181
  • Vote: I do not like it

| Write comment?
»
14 months ago, hide # |
 
Vote: I like it +9 Vote: I do not like it

very interesting problems!, thanks you all

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

    B was Cool!

  • »
    »
    14 months ago, hide # ^ |
     
    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.

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

Why is there no Hints on D???

»
14 months ago, hide # |
 
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.

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

    practice makes perfect

    • »
      »
      »
      14 months ago, hide # ^ |
      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 ?

      • »
        »
        »
        »
        14 months ago, hide # ^ |
        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

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

        Reverse dfs

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

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

»
14 months ago, hide # |
 
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

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

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

  • »
    »
    14 months ago, hide # ^ |
     
    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.

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

what an amazing solution to C!

i had a completely different solution.

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

    please share your approach

    • »
      »
      »
      14 months ago, hide # ^ |
      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.

      • »
        »
        »
        »
        14 months ago, hide # ^ |
        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 .

        • »
          »
          »
          »
          »
          14 months ago, hide # ^ |
           
          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.

        • »
          »
          »
          »
          »
          14 months ago, hide # ^ |
          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://mirror.codeforces.com/contest/2071/submission/308726433

          hope that helps !!

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

Will be added soon(

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

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

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

C was excellent. Really excellent.

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

what happened to D editorial

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

    You can check it now. We added it.

    • »
      »
      »
      14 months ago, hide # ^ |
       
      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

      • »
        »
        »
        »
        14 months ago, hide # ^ |
        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

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

          But why to subtract from n first?

          • »
            »
            »
            »
            »
            »
            14 months ago, hide # ^ |
             
            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

          • »
            »
            »
            »
            »
            »
            14 months ago, hide # ^ |
             
            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.

»
14 months ago, hide # |
 
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 :)

»
14 months ago, hide # |
 
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.

  • »
    »
    14 months ago, hide # ^ |
     
    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.

    • »
      »
      »
      14 months ago, hide # ^ |
       
      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.

      • »
        »
        »
        »
        14 months ago, hide # ^ |
        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"

»
14 months ago, hide # |
 
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!

»
14 months ago, hide # |
 
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.

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

Why should we double n when we solve problem D?

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

    Same question

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

    actually you dont't

    #include<bits/stdc++.h>
    using namespace std;
    
    
    void solve(){
        int n;
        long long l, r;
        cin >> n >> l >> r;
        vector<int> a(n+1);
        for(int i=1;i<=n;i++) cin>>a[i];
        vector<int> pre(n+1);
        for(int i=1;i<=n;i++){
            pre[i]=pre[i-1]^a[i];
        }
        if(n%2==0){
            n++;
            a.push_back(pre[n/2]);
            pre.push_back(pre.back()^pre[n/2]);
        }
        
        int p=pre[n];
        function<int(long long)> get=[&](long long x)->int{
            if(x<=n) return a[(int)x];
            long long hf=x/2;
            if(hf<=n) return pre[hf];
            if(hf%2==0){
                return p^get(hf);
            }
            else return p;
    
        };
        cout<<get(l)<<'\n';
       
    }
    
    int main(){
        int t;
        cin >> t;
        while (t--) solve();
        system("pause");
        return 0;
    }
    void inc(int pos, int d) {
        for (; pos < n; pos |= pos + 1)
            f[pos] += d;
    }
    
»
14 months ago, hide # |
 
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://mirror.codeforces.com/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.

»
14 months ago, hide # |
 
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 :)

»
14 months ago, hide # |
 
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://mirror.codeforces.com/contest/2071/submission/308378910

»
14 months ago, hide # |
 
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 ??

»
14 months ago, hide # |
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

»
14 months ago, hide # |
 
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

»
14 months ago, hide # |
 
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.

  • »
    »
    14 months ago, hide # ^ |
    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).

»
14 months ago, hide # |
 
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

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

My solution for D2.

First, check the editorial of D1.

DP Approach
Code
»
14 months ago, hide # |
 
Vote: I like it +15 Vote: I do not like it

Alternative solution for B

Hint 1
Hint 2
Solution
»
14 months ago, hide # |
 
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?

  • »
    »
    14 months ago, hide # ^ |
     
    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.

    • »
      »
      »
      14 months ago, hide # ^ |
       
      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}$$$
»
14 months ago, hide # |
 
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.

»
14 months ago, hide # |
 
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

  • »
    »
    14 months ago, hide # ^ |
     
    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 \gt y^2$$$

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

      Sorry this is so late but could you explain this in greater detail? How can we prove that (x+1)**2 <= y**2? Maybe I am misunderstanding

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

        Sorry don't waste your time I understand now

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

          If anyone is interested I think the key is that y**2 = x**2 + k + 1, which means that y**2 > x**2. In this case, because x and y are integers if y**2 > x**2 then y**2 >= (x+1)**2. This is because increasing x by 1 can only equal the y**2 because if y**2 > x**2 y must be at least x+1.

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

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

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

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

  • »
    »
    14 months ago, hide # ^ |
    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

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

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

»
14 months ago, hide # |
 
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?

  • »
    »
    14 months ago, hide # ^ |
    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 !

    • »
      »
      »
      14 months ago, hide # ^ |
       
      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?

      • »
        »
        »
        »
        14 months ago, hide # ^ |
        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

        • »
          »
          »
          »
          »
          14 months ago, hide # ^ |
           
          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

»
14 months ago, hide # |
 
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?)

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

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

  • »
    »
    14 months ago, hide # ^ |
     
    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 \lt 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). $$$
»
14 months ago, hide # |
 
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://mirror.codeforces.com/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?

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

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

»
14 months ago, hide # |
 
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

»
14 months ago, hide # |
 
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.

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

C with Topo sortsubmission link

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

Thanks for the A

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

Actually I spent a lot of time on Problem C, I think it is not easy to find the solution...Anyway I have to guess..And i didn't notice D's solution at all! All problems are good!

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

problem E can be solved with a simple re-root dp: 343755312