NemanjaSo2005's blog

By NemanjaSo2005, 12 months ago, In English

2103A - Common Multiple

Author: NemanjaSo2005

Hint 0
Hint 1
Hint 2
Hint 3
Hint 4
Hint 5
Solution
Implementation (c++)
Implementation (python)
Bonus

2103B - Binary Typewriter

Author: Blagoj

Hint 1
Hint 2
Hint 3
Hint 4
Hint 5
Hint 6
Hint 7
Solution
Implementation (c++)
Implementation (python)
Bonus

2103C - Median Splits

Author: NemanjaSo2005

Hint 1
Hint 2
Hint 3
Hint 4
Hint 5
Hint 6
Solution
Implementation (c++)
Implementation (python)
Bonus

2103D - Local Construction

Author:NemanjaSo2005

Hint 1
Hint 2
Hint 3
Hint 4
Hint 5
Solution
Implementation O(N)
Implementation O(n log n) (prvocislo)
Bonus

2103E - Keep the Sum

Author:NemanjaSo2005

Hint 1
Hint 2
Hint 3
Hint 4
Solution part 1
Hint 5
Hint 6
Solution part 2
Implementation
Bonus

2103F - Maximize Nor

Author: NemanjaSo2005

Hint 1
Hint 2
Hint 3
Hint 4
Hint 5
Solution
Implementation
Bonus
  • Vote: I like it
  • +74
  • Vote: I do not like it

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

oh wow... quick editorial before system test finish... thanks

»
12 months ago, hide # |
 
Vote: I like it -167 Vote: I do not like it

It turned out to be a good competition. Task E is interesting

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

    You literally cheated. https://mirror.codeforces.com/contest/2103/submission/316575935 and https://mirror.codeforces.com/contest/2103/submission/316574644 have too large of an edit distance for a three-minute gap. Also, the macros at the top completely change.

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

      Yeah, it looks kind of suspicious. Also, If you take a look at his recent competitions, there is literally one competition, where all of his submissions got skipped.

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

      It's an accident

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

        could you kindly explain why you are using a different template in every submission?

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

          I don't have a common template. Each type of task has its own templates and macros. The macros in each template are sometimes different. If it's interesting, I can send you all my templates that I use

          • »
            »
            »
            »
            »
            »
            12 months ago, hide # ^ |
            Rev. 3  
            Vote: I like it +82 Vote: I do not like it

            I'm not buying it. We are talking about two submissions for the same problem. Why would you switch to a completely different template for the same problem?

            And again, the submission times are only 3 minutes and 4 seconds apart, which means practically you had less than 3 minutes to fix your code. In that small amount of time, not only did you manage to completely rework your solution, but you made a ton of totally unnecessary changes like:

            • reformat all the whitespace in your solution
            • rename the range() macro rng() (why?)
            • rename the test case counter from tc to T (why?????)
            • rename the input vector from stage to a (why???)
            • rename rounds to W (why?)

            None of these changes had anything to do with fixing your solution. The differences might make sense if you started from scratch with a different template, but in that case it would have taken significantly longer than 3 minutes.

            And that's just one submission. The previous 316563964 has a bunch of problems too: apparently this is some topological sort like approach. But why do you define a struct FastIn that you don't even use? You didn't use this in any of your other solutions. And there's a biggerIter lambda that unnecessarily maps INFVAL to INT_MAX. Why? None of this looks like a human wrote it.

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

              Hey! I get where you're coming from — the differences in style and structure between the two submissions are noticeable. But there's nothing shady going on here

              The first submission was just a quick draft. I wanted to test the idea fast, so I threw together a minimal version. When it failed on a pretest, it immediately pointed me to the issue — the grouping wasn't handled properly at certain stage boundaries.

              I have a pre-written template that includes a lot of useful utilities: clog2, doubly linked list handling with L/R, level-based grouping, etc. Once I saw what needed to be fixed, it took me less than 3 minutes to open my template, drop the core idea into place, tweak a few conditions, and submit. Totally doable when you already know what the bug is and have the infrastructure ready.

              As for the renaming — things like rng, T, a, W, ans, and mark are just part of my regular template. I stick with the naming for consistency and readability. No particular reason to rename them back to what I used in the draft.

              And again, this wasn’t a rewrite from scratch. It was more like "okay, I know the issue, let’s rebuild it properly using my usual tools."

              Regarding unused things like FastIn or biggerIter in other submissions — same story. My template includes them by default, and I don’t always clean up unused parts when I’m in a rush to submit. Doesn’t mean the code wasn’t written manually.

              So yeah — it’s all legit and hand-written. Just a quick fix, plugged into a familiar and efficient structure.

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

                dude...

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

                  Omg, I use translators with AI assistants to express my thoughts normally for people like you. We can communicate in my native language

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

      I accidentally filled in the wrong solution, for which I received a WA. I had a solution at that time

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

        You have very suspicious and AI-like variable names

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

        But how would you explain the difference in your code-style for each of the problems you have solved? It's very unusual to have a difference in code style if you have been programming for a while. Also, some of your problems have verdicts "Wrong answer on pretest 1". Like, who wouldn't want to test out their solution before submitting it. It's kind of strange to not test your solutions before submitting, and as the other guy have mentioned above, the edit distance between your two submissions is huge. How do you even type that fast, it's impossible.

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

      I checked the first code with AI code checker and it said the code was 85-90% written by AI

      The second code was 90-95% written by AI

      If you want to try it for yourself

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

        This is really a shit. It says that all my code is generated by AI( >= $$$85\%$$$ )

        UPD: It says the writer's code of prob E is $$$70\%\sim 80\%$$$ likely AI generated

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

        I provided a solution of my own to check. and it said, "This code is very likely generated by an AI model, possibly ChatGPT"

        so, these ai detections are not reliable at all.

        I faced something like this before. not related to coding though. I wrote a paragraph on a topic(an assignment) and checked for ai detection. then it said that it was ai generated too. then i provided the the paragraph to gpt and asked to rewrite it so the ai doesn't mark it as ai generated. and guess what this time it got around 30% ai generation score, whilst the first one(written by me) got over 80%. so they are not reliable at all.

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

    thank you sir I had a great laugh

    • »
      »
      »
      12 months ago, hide # ^ |
      Rev. 3  
      Vote: I like it -8 Vote: I do not like it

      Bro...to be honest, I laughed even harder when I saw this (in the picture) and your comment. Good job

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

        can somebody explain what is this loser trying to elaborate on

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

          you having wrong answer on pretests for 9 attempts straight i guess

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

            I think getting roasted constantly for blatantly cheating is funnier

»
12 months ago, hide # |
 
Vote: I like it -32 Vote: I do not like it

The F question is really terrible。

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

    Can you explain why you do not like it? If there's something I can change in the future I will make sure to do so.

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

      I believe most people passing it are not even proving the result, and AI can simply guess without giving it any second thoughts.

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

        Majority of none-AI solvers solved it in a much harder way, because it is not easy to guess the solution. Also please don't blame the authors with AI solving the problems.

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

          I want to be clear that I don’t blame the author at all—in fact, I’m truly grateful for all the creativity and hard work that went into these problems. The F question was certainly a tough nut to crack, but wrestling with it taught me a lot. Thank you again to everyone who contributed!

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

        Thank you for the feedback! Yes, I do agree that such stuff is not fun, but we couldn't find a way to stop it.

        I really appriciate you actually providing the reason as for a lot of people the only reason for disliking round is that they did bad in it.

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

          This is indeed not the fault of the author. I would suggest that perhaps the authors could consider providing the problems to AIs, such as O3 and so on, during the testing phase and observe their feedback — maybe this could be effective?

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

      Maybe he wants to say that there so many people slove it with AI, I guess

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

I think my solution for E works in $$$\frac{3n}{2}$$$ operations lol

Edit: Didn't see the bonus section. Cool!

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

Great learning experience. will upsolve C, i was trying out a completely different approach :)

PS: will the answer to C bonus be a binary search approach?

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

I have solved D by simulating the process and contstructing graph on elements (There is a directed edge from u -> v when u < v) and then order in topological sort is the answer. Overkilled I guess.

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

    That is, in fact, a valid solution, and there was a harder version that needed it. But we did not use it as it was not interesting enough.

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

    i tried this during the contest but there were some inconsistencies which I couldnt clear. for example:

    let adjacent indices during some iteration be 0, 1, 2 and index 1 is being removed (let it be an odd iteration). Now, we get either a[1] > a[0] or a[1] > a[2] or both. how do we verify which edge to add to our graph? Should we add both? I couldn't come up with a solid solution to resolve this

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

      You need both edges, otherwise 2 will also be removed during that iteration. Assume you have elements from 0 to 6 and only 2 and 5 remain after that odd iteration, the condition will be like this:

      $$$0 \gt 1 \gt [2] \lt 3 \lt 4 \gt [5] \lt 6$$$

      Note that you are free to change it to $$$3 \gt 4$$$, as long as the pattern between 2 remaining elements must be $$$ \lt \lt \lt ... \gt \gt \gt $$$

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

    Can you explain your solution? I did not understand it. Edit : I understood it from another comment. Thanks for the new idea.

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

Missing corner cases/ not doing casework properly cost me a lot of time and WAs... (problem B and C)

Anyway still a great problemset. Good caution for a while for people just submit without being carefully checking through code and cases like me.

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

    Just in the hurry of submitting fast, I submitted B's solution to C lol. Luckily, CF doesnt penalise on WA in 1st case :)

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

      I'm too, was guilty of submitting the wrong files/wrong problems.

      I switched my habit to copy the code to submit pages and manually select problems. This no longer happens.

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

Another way you could think about D is that we're trying to construct an acyclic graph where we have an edge from $$$a$$$ to $$$b$$$ if $$$p_a \lt p_b$$$. We process each layer individually. Assume that we are removing all non-local maximums. If an element $$$i$$$ is not removed in this layer, then we know that $$$p_i$$$ is a local maximum, then $$$p_{i+1} \lt p_i$$$ and $$$p_{i-1} \lt p_i$$$. We also have to insert edges for elements that are going to be removed, that will be done the same way the editorial describes it. Then we calculate a topological sort. The complexity will be $$$O(n*log(n))$$$. 316594585

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

Can anyone hack my solution for C since I believe it has worst case complexity of O(n^2): 316589874

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

    Can you please tell me what you did?

    If for cases $$$1$$$ and $$$2$$$ you iterated over start of the first one and then when you get good prefix you iterate at the end of the second one, it actually ends up being $$$O(n)$$$, because if you start the second loop more than 2 times, you would have already gotten yes in one of the previous runs.

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

      I didn't quite understand the explanation. In each of the last two nested loops , for each good prefix, it run from l+2 to n, and in worst case, can the number of good prefixes be close to n and none of the pairs l,r satisfy the conditions, so shouldn't it be O(n^2) ? What is it which guarantees O(n)?

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

        Let a and b be ends of first 2 good prefixes. Then [1, a] [a+1, b] [b+1, n] split works. There might be some edge cases, but they are not existant if there's like 5+ good prefixes. So the complexity is $$$O(n)$$$ if you actually do the break/return after finding first good split.

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

cool contest

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

F hint 2:

You can look at all the bits separately and answer for each.

Why is that? Let's assume for the oldest bit I found a segment $$$[l, r]$$$ covering $$$i$$$. For the next bit there may exist a segment $$$[l',r']$$$ covering $$$i$$$ that is not "compatible" with $$$[l, r]$$$. This can (?) happen if there is a 1 between $$$i$$$ and both $$$r$$$'s and number of zeroes in the suffix has different parity.

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

For problem F, I think the complexity of official solution should be $$$O(nk^2 + nk \log n)$$$ since calculating range nor takes $$$O(k)$$$ time.

btw, using push down on sparse table instead of segtree can reduce time complexity of processing range max updates from $$$O(nk\log n)$$$ to $$$O(nk + n\log n)$$$

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

can anyone explain why it says -2 here in problem B but it was actually accepted

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

With a tougher implementation it is possible to solve E in (3n/2) moves instead of 3n moves. (the bonus version of the problem)

Idea is somewhat like:

  • use 2 moves so that there is a pair (2 elements with sum = k) on first and last position. should be trivial to those who have solved the main version.
  • now make first element equal to any element that is not on its correct position — that's 1 operation, this will make a cycle of minimum 3 elements (including the first element). If the size of the cycle is P, it will take (P-1) more moves to put everything in the correct place and it will put (P-1) elements in their right place (because we're not counting the first element).

So basically, we can use P moves to put (P-1) elements in their right place. Since the smallest P is 3, in the worst case, it'll take 3 operations to put 2 elements in their correct position. Notice that we only need to put (n-2) elements in their place.

  • At last, use 1 operation to make the first and last element 0 and k
Why can't P be 2?
»
12 months ago, hide # |
 
Vote: I like it +16 Vote: I do not like it

As a complete newbie, I also confess that the contest was so good! Will upsolve B; it was so damn interesting (though I couldn't solve)!

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

C was too implementation heavy. Took 1 hour for 1 question. Damn!

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

Can somebody please help me finding out edge case for this solution 316608879 i have been thinking since 2 hours but i didnt get any edge cases, i would really be thankful, Thank you in advance

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

    you are not doing complete search

    a2 = pre[r][0] - pre[l-1][0];
    b2 = pre[r][1] - pre[l-1][1];
    

    there can be some segements $$$(l^\prime, r^\prime)$$$ where $$$l \lt = l^\prime$$$ or $$$r^\prime \lt = r$$$ or both

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

You should include Editorial link into "Contest Materials"

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

In problem D , for the test case:

1 6 2 1 1 -1 2 1

The author's constructed perumtation is:

1 4 5 3 2 6

Why is this a valid permutation , will 3 not get deleted in the first iteration itself since its not a local minima?

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

For anyone wondering about the solution of the Bonus Problem for Task C, We can simply binary search on k and use the current solution as the check function. It will be an O(n * log(n)) Solution!

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

F is really nice!

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

hello my fellow competitive programmers, this morning i was looking for some youtube videos to understand and upsolve the problems which i could not solve in 1019 Div 2 contest, then suddenly i saw this youtube channel. this man has uploaded all the solutions till problem F excluding problem E, solved all of them, and i am damn sure he has cheated, also he runs a telegram channel which is mentioned in his youtube channel where he uploads the source code of all the problems, and he has just registered some hours ago, he is — 777dimasik777. and even if he has not cheated, whats the need to upload solutions on youtube and telegram during the contest. such people ruin our community and this platform. please, someone take strict action against such cheaters, so this platform is free from them.

»
12 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it
Bonus section of problem F:
  • »
    »
    12 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Yes. It is a well known problem. But I still think it's fun if you didn't see it before. (And I couldn't think of CP problem as a bonus)

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

nice editorial

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

My methods to do A:

  1. O(n log n): Sort the array and if a[i] != a[i+1] then result += 1

  2. O(n log n): Insert all elements into an array and then print out the size of the set

  3. O(n): Make an array to store the number of appearances of a certain element in an array. Then count the number of i such that count[i] > 0

They all just count number of distinct elements in the array.

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

can anyone send me a answer for median splits using dp

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

Solving the questions without participating in the contest, it was a bit shocking to see how pretty much no one solved E, given the solves for F. For reference, E took me about 15 minutes to solve on paper where F took a couple hours or so.

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

    I also think that E is easier than F for humans. Sadly, that's not the case for AI, which lead to more ACs on F and therefore also more legit solves on F.

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

      But when it comes to a person who's extremely bad at greedy/constructives(like me) its exactly the opposite case xD

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

    One of them abuses the OCaml language to avoid plagiarism, while the other manages to think, solve, and code a Div2 F problem within 20 minutes.

    Impressive ngl, could you check them? NemanjaSo2005

»
12 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
const int MOD = 1e9 + 7;
using namespace std;
using namespace __gnu_pbds;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef map<int,int> mi;
typedef vector<ll> vl;
typedef map<int, vector<int>> Graph;
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
bool even(int n) {
    return (n & 1) == 0;
}

bool odd(int n){
    return (n & 1) != 0;
}

//For uppercase to lowercase
char tolower(char a) { return (a | ' '); }

// For lowercase to uppercase
char toupper(char a) { return (a & '_'); }

bool ipo2(int a) { return (a & (a - 1)) == 0; }

int gcd(int a,int b)
{
    if(b==0)
        return a;
    return gcd(b, a % b);
}

int binExp(int a,int b)
{
    int ans = 1;
    while(b)
    {
        if(b&1)
        {
            ans = ans * a;
        }

        a = a * a;
        b >>= 1;
    }

    return ans;
}

int ceil_division(int a,int b)
{
    return (a + b - 1) / b;
}


void sieve(ll n)
{
    vector<bool>isPrime(n+10,true);
     for (int i = 2; i<=n;i++)
    {
        if(isPrime[i]==true)
        {
            for (int j = 2 * i; j <=n;j+=i)
            {
                isPrime[j] = false;
            }
        }
    }
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin >> t;
    while (t--)
    {
        int n,k;
        cin >> n>>k;
        vi arr(n);
        for (int i = 0; i < n;i++)
            cin >> arr[i];
        int len = 0;
        int ele = 0;
        int count = 0;
        vi temp;
        for (int i = 0; i < n;i++)
        {
            len++;
            if(arr[i]>k){
                ele++;
            }
            if(ele<=len/2) {
                count++;
                if(len%2 && i<n-1 && arr[i+1]>k){
                    i++;
                    temp.push_back(i);
                }
                else
                    temp.push_back(i);
                ele = 0;
                len = 0;
            }
        }

        int count2 = 0;
        len = 0;
        ele = 0;
        for (int i = n-1; i >= 0;i--)
        {
            len++;
            if(arr[i]>k){
                ele++;
            }
            if(ele<=len/2) {
                if(!temp.empty() && i<=temp[temp.size()-1]){
                    break;
                }
                
                else{
                count2++;
                 if(len%2 && i>0 && arr[i-1]>k){
                    i--;
                }
                ele = 0;
                len = 0;
                }
            }
        }
       

        if(count>=2)
            cout << "YES" << endl;
        else if(count2>=2)
            cout << "YES" << endl;
        else if(count>=1 && count2>=1)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
        
}

FOR PROBLEM C can anyone tell me why my code is giving WA i am basically trying to partition it from first left side then right side and count the partition on left and right and make sure it doesnot overlaps and also of the length of the partition is odd i can add the next element if its not <=k cause it wont change my median.

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

For D you can just sort indices based on p[i] and break ties based on distance to the last element (with value $$$-1$$$). Then, iterate the sorted array and assign the highest number to odd values and lowest to even values.

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

In problem D O(n) implementation, we are sorting the array, wouldn't that make the implementation O(nlog(n))?

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

Great Editorial....those hints really helps

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

I can solve the third bonus.I was happy to enter this div.2 round.

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

010 <-- i can't focus on problem B cause i keep noticing this little face

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

can someone provide me easier implementation of C problem of this contest