nik_exists's blog

By nik_exists, 3 weeks ago, In English

Thank y'all so much for participating!

2259A - Moo Language School

Solution
Code
Difficulty
Quality

2259B - Minus Two

Hint 1
Hint 2
Solution
Code
Difficulty
Quality

2259C - 101

Hint 1
Hint 2
Solution
Code
Difficulty
Quality

2259D - MEX Multiset

Hint 1
Hint 2
Solution
Code
Difficulty
Quality

2259E - Treasure Map Destruction (Constructive Version)

Hint 1
Hint 2
Solution
Code
Difficulty
Quality

2259F - Binary Bubble Sort Inversions

Hint 1
Hint 2
Hint 3
Solution
Code
Difficulty
Quality

2259G - Index Removal

Hint 1
Hint 2
Solution
Code
Difficulty
Quality

2259H - Treasure Map Destruction (Counting Version)

Read the solution to problem E first

Hint 1
Hint 2
Hint 3
Solution
Code
Difficulty
Quality
  • Vote: I like it
  • +200
  • Vote: I do not like it

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

Auto comment: topic has been updated by nik_exists (previous revision, new revision, compare).

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

good contest!

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

nice round thanks !

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

good problems, C was kind of annoying to implement

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

Amazing round. Ty king

»
3 weeks ago, hide # |
← Rev. 4  
Vote: I like it +5 Vote: I do not like it

Maybe you are missing the space after [tutorial:2259B]?

It works for me:

Tutorial is loading...

nik_exists

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

W contest

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

2259E code ... cpp :skull:

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

The editorial isn't working because it doesn't use the announcement format /j

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

C is harder than D. But still orz round by nik_exists

»
3 weeks ago, hide # |
 
Vote: I like it +6 Vote: I do not like it
#include "codeforces.h"
#include <chrono>
#include <vector>

using namespace std;
using namespace cf;

int main() {
    comment << "\nGreat contest!\n";
}

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

E can be solved with 2-SAT

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

    Can you explain more

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

      Lets forget about the -1 for a moment cause they dont really matter at all in problem E. Just some border cases.

      We want i-A[i] or A[i]+i to be '1' in our string ans.

      When both i-A[i] or A[i]+i fits in the array we can choose any of them, can be both or exactly one. (.either() method in the code)

      When only one of them fits in the array it must be equal to '1' in our ans (SetValue method in the code)

      When neither of them fits theres no answer

      The conditions above are not suficient as we have to ensure in the range [i-A[i]+1,i+A[i]-1] there are no 1's in our solution. The way to solve this is an array diference to know the unvalid positions. SetValue(-i)

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

        Explain deeper how to solve the range [i-A[i]+1,i+A[i]-1] without getting TLE

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

          The main idea in the array diference is to simulate a assignment in ranges.

          We want to put in our array 'p' on the range [i-A[i]+1,i+A[i]-1] a 1 to know this range is unvalid. Instead of iterating over the range (because TLE) or having a Lazy Segment Tree, we can sum a 1 in the begining of the range and a -1 immediately after the range. Then do a prefix sum and the array going to become the desire one.

          Do some cases to convice yourself

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

        Thanks,it's a nice explanation :)

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

          I did it using stacks and queue

          Intialize the array ans of size n which are all 1 intialize the queue with {2,3,4.....n} intialize empty stack

          for i in 1,2,3 .... n if a[i] > 0 then ans[i] = 0

          in the stack keep poping until i - top < a[i] and ans[top] = 0
          
           in the queue if i is present pop it , and after that keep  poping until front - i < a[i] and ans[front] = 0
          
            push i in stack(s)

          after the loop just check if ans is a valid answer

          intuition behind this is that stack allows you to look at indexes from right to left(but less than i) which were not forced to be zero before and queue let's you look at indexes from left to right (>i) which were not forced to be zero before.

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

    i thought of 2SAT and then went for other solution (because i think we don't need 2SAT at all).

    Basically if a[i] == 0, then there should be treasure at position i. Otherwise if a[i] > 0, there should be a treasure at i — a[i] OR i + a[i]. So you just need to add a OR clause and let 2SAT solve it.

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

      if i — a[i] <= 0. Then i + a[i] MUST be treasure. if i + a[i] > n. Then i — a[i] MUST be treasure. otherwise either of them can be a treasure.

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

It Was a fun contest , but i got struck at E for almost the whole contest :-(

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

I cared too much about my rating. That's why I wanted to solve C as fast as I could and made many silly mistakes

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

Thanks for the contest! I enjoyed it

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

should i try to upsolve E? current rating is 1072 and max is 1100.

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

Nice contest!

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

i dont know why i found it hard to understand E statement otherwise amazing round!

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

Please elaborate more on the editorial of $$$E$$$.

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

    let the given array be v and the final string be s for each v[i]>0 the closest island to it should be at position i-v[i] or i+v[i] if there is an island (v[j]=0) in the range ]i-v[i],i+v[i][ then that element j will be closer to v[i] which will be a contradiction so you should output -1 then for each -1 outside of the union of these ranges you can consider it as an island (set it to 1 in s and its valid given that it does'nt influence other elements) the -1 inside the union of the ranges will be set to 0 in the final string because they cant be set to 1 after that you need to check for every element i with v[i]>0 if there is an island in i-v[i] or i+v[i]

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

      [commented twice by mistake]

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

      how to check in a range if there is $$$0$$$ while updating $$$i+v[i]$$$ or $$$i-v[i]$$$ to $$$0$$$ greedily? because if we dont greedily assign 0 to left side or right side then some other index might contradict previous indices.

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

The problems were amazing and realized I need to improve myself, java was kind of problematic at times

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

Why does the system testing so long?

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

good contest, but G is too easy in Div.3

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

I liked this round a lot, but B felt easier to implement than A xd. And G was really easy compared to E for me.

Good work!

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

E took me longer than F and almost had G on time but still it was a great round!

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

Amazing contest, A-D was very easy.The jump from D to E was pretty big for a div 3.

Question F was really fun!

»
3 weeks ago, hide # |
 
Vote: I like it -28 Vote: I do not like it

i got WA on test case 2 which was n=3 -1 1 1 i got answer as 1 0 0 Placing a treasure at island 1 (100) gives: Distance from island 1 to nearest treasure = 0. Distance from island 2 to nearest treasure = 1 (which is >=1). Distance from island 3 to nearest treasure = 2 (which is >=1). As question has clearly stated that ai means treasure is 'ATLEAST' distance away from ith island so my answer should be valid why jury's answer is -1

nik_exists explain this

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

    As question has clearly stated that ai means treasure is 'ATLEAST' distance away

    this is not what the question says

    ai indicates the minimum number of islands that Bessie would need to travel through

    The minimum distance that Bessie would have to travel from Island 3 to reach a treasure is 2, not 1

    • »
      »
      »
      3 weeks ago, hide # ^ |
      ← Rev. 3  
      Vote: I like it -28 Vote: I do not like it

      so 'minimum' no of islands that bassie would need to travel from island 3 to reach treasure is should be 1 .. in my solution it is 2 which is (>=1) i think that meaning is also valid it should be accepted also please do consider this perpective as well.

      nik_exists

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

        if the questions asks for the minimum and you give an answer greater than the minimum your answer is wrong

        • »
          »
          »
          »
          »
          3 weeks ago, hide # ^ |
          ← Rev. 3  
          Vote: I like it -16 Vote: I do not like it

          ai indicates the minimum number of islands that Bessie would need to travel through

          so Bessie has travlled minimum distance of ai so it should be valid .. i don't care about getting accepted but just think of this sentence and valid solution for it .. if we wanted that distance to be exactly ai we should have mentioned it that

          ai indicates the exact number of islands that Bessie would need to travel through to get treasure

          nik_exists

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

            The minimum distance Bessie would have to travel in your answer is 2 islands. This does not match the array a, which requires the minimum distance be 1 island, so it is not a valid solution

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

            ai indicates the minimum number of islands that Bessie would need to travel through

            This means, ai is equal to(=) min number of islands travelled

            Not min dist of ai

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

    the distance of the nearest treasure from j should be exactly b[j] (if b[j] is not -1). not >=b[j]

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

    Agree, how is everybody here under mass psychosis, it says minimum distance not EXACT distance

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

      the minimum distance (i.e. shortest path) between two positions in an array is $$$\lvert i - j \rvert$$$

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

AMAZING E and F! I had a lot of fun solving them :3

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

My contest discussion stream here for ABCDEFG

»
3 weeks ago, hide # |
← Rev. 2  
Vote: I like it -12 Vote: I do not like it

.

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

    btw which AI u used during contest. seems pretty dumb.

    • »
      »
      »
      3 weeks ago, hide # ^ |
       
      Vote: I like it -14 Vote: I do not like it

      im trainning for ICPC so now im practicing mostly on thinking harder problems, i mostly implement the problems, sometimes i really on IA but just for a little bit of help in implementation

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

        DNR

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

          as im seeing in the rules this is allowed, i didnt write the core logic with AI, and ever let AI think a problem for me, i know that this will be cheating and its bad.

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

Fantastic round, enjoy it

»
3 weeks ago, hide # |
← Rev. 2  
Vote: I like it +13 Vote: I do not like it

In $$$G$$$ the last-moving index will always increase, so it can be done in $$$O(n)$$$ with two-pointers rather than binary search. (I found it easier to think in terms of the "slack", $$$k-(a_{i+1}-a_{i})$$$ equivalently you are finding the position at which the total slack from your current position hits $$$k$$$; the fact this increases is then immediate from the slack always being positive).

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

I tried to construct the graph in H and do some kind of DP on it, but I got stuck in the cycles part... It took me a while to realizes the graph's cycles has a special structure: they are disjoint segments and all edges in the cycles already has their 0/1 values. At that point, I just needed to prune the cycles to do DP.

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

After solving F and G post contest, i think F<G<E. Aside from getting cooked by E, really great contest!

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

the markdown formatting is incorrect. Here’s the code for problem E in case anyone needs it :33

code here
»
3 weeks ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

during the event i solved 4 questions i thought my rating would be 1050+ but due to the checkbox i didnt read it and i participated in unrated contest.THE FEELING cant be described :(

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

What would be the approximate rating for all the problems? I gave this contest after around 6 months of inactivity and solved 4.

»
3 weeks ago, hide # |
 
Vote: I like it -25 Vote: I do not like it

Hello nik_exists,

This letter is about my skip from the contest.

First, I want to make clear that I didn’t cheat or use any external programs during the competition. I made my solutions by myself relying only on my knowledge.

Of course, the anti-cheat can find some similarities or something strange, and I fully understand the necessity of this measure. Nevertheless, I think that I was flagged by mistake.

If there was something in my code which attracted your attention, I will be grateful if you could tell me what it was. Besides, I am fully ready to explain my solutions and every line of my code so that you could see that I understood everything by myself.

Thank you for your consideration.

nik_exists

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

nik_exists

Amazing round, I enjoyed it , thanks a lot

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

Nice contest

»
3 weeks ago, hide # |
 
Vote: I like it 0 Vote: I do not like it
#include "codeforces.h"
#include <chrono>
#include <vector>

using namespace std;
using namespace cf;

int main() {
    comment << "\nGreat contest! && thank you\n";
}
»
3 weeks ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

What a contest man! Got to learn many things. Thank you!!

»
3 weeks ago, hide # |
← Rev. 2  
Vote: I like it -11 Vote: I do not like it

Can anyone help me, i solved a-e in this contest but all my submissions are skipped and i got a message that it was due to some violation in rule. here are my submissions 389498525,389511176,389531255,389539799 i don't understand why they are skipped but they seems fine to me.

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

nice , thanks for this useful contest =)

»
3 weeks ago, hide # |
← Rev. 3  
Vote: I like it -12 Vote: I do not like it

Heyy..I gave the whole contest fairly but today I received the message "your responses are not being considered due to rule violations". Can anyone tell why I got this? I didn't cheat at all.

nik_exists please look at this.

Bro......I just checked the AI flagged solutions for all codes and in code e, just the name treasure_map_fin matches, that is a pure coincidence. The logic was really simple for the problem and that's what I did step by step...find the possible indices, if none is possible flag as -1, check for exact presence......just the name of vector got same

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

    Could you please tell me what the violation notice looks like on your side? I performed well in this contest, but my rating did not change — it seems my participation was skipped. I did not receive any notification explaining why. Is it possible that I just do not know where to find the violation information?

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

first time solved 4 problems yeeepie but after the contest got a runtime error on c but still happy

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

can someone explain why TLE ?389511024 and here where went wrong ? 389560130

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

    1-Fast I/O: Use sys.stdin.read().split() instead of input().split(). Reading input line by line in multiple test cases is very slow.

    2-Hash Collisions: In Codeforces, Python's dict and Counter are vulnerable to anti-hash tests. Hackers can force hash collisions that degrade operations from $$$O(1)$$$ to $$$O(N)$$$, causing an $$$O(N^2)$$$ TLE.

    3-Unnecessary Dict: In your codes, for example, in the second code you don't need Counter at all since you only count zeros (using arr.count(0) or a basic loop).

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

nice contest! code?

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

My alternative solution for Problem H (no 2-sat, dsu required):

1) A valid treasure placement configuration must follow a specific zig-zag pattern:
- It starts with a strictly decreasing sequence (step -1) down to $$$0$$$.
- Then, it strictly increases (step +1).Then, it strictly decreases (step -1) back to $$$0$$$.
- This pattern alternates, ending with a strictly increasing sequence.
- At the transition points (the "peaks" and "valleys" between segments), the absolute difference between adjacent elements cannot exceed 1.
- Example of a valid configuration: 3 2 1 0 1 2 3 4 5 4 3 2 1 0 0 1 2 2 1 0 1 2 3 4.

2) Since each valid configuration corresponds to a distinct placement strategy, the problem reduces to counting the number of ways to replace all (-1)s with non-negative integers such that the resulting array satisfies the conditions above.

3) For each index $$$i$$$ from $$$1$$$ to $$$n$$$:
- Define $$$L[i] = k$$$ as the maximum length $$$k$$$ extending to the left of $$$i$$$ such that this segment can be validly filled as a strictly decreasing sequence from $$$k-1$$$ down to $$$0$$$. This can be computed using Binary Search + Sparse Table.
- Similarly, define $$$R[i] = k$$$ as the maximum length $$$k$$$ extending to the right of $$$i$$$ such that this segment can be validly filled as a strictly increasing sequence from $$$0$$$ up to $$$k-1$$$. This can also be computed using Binary Search + Sparse Table.

4) Let $$$dp[i]$$$ be the number of valid ways to fill the prefix from $$$1$$$ to $$$i$$$, given that $$$a[i] = 0$$$.
- Obviously, if $$$a[i] \gt 0$$$, then $$$dp[i]=0$$$.
- If the prefix is just a single decreasing sequence down to $$$0$$$, then $$$dp[i] = 1$$$ if $$$L[i] = i$$$, otherwise $$$0$$$.
- For other valid configurations, $$$dp[i]$$$ is the sum of $$$dp[j]$$$ for all $$$1 \le j \lt i$$$ where the gap between $$$j$$$ and $$$i$$$ can form a valid "mountain" (an increasing segment followed by a decreasing segment). The condition for this is $$$\min(L[i], R[j]) \ge \lceil \frac{i - j + 1}{2} \rceil$$$, which can be rewritten as: $$$2 \times \min(L[i], R[j]) \ge i - j + 1$$$. This can be optimized from $$$O(n^2)$$$ to $$$O(nlogn)$$$ by using CDQ or Sweepline.
- If $$$R[i] = N - i + 1$$$, it means the remaining suffix (from $$$i$$$ to $$$N$$$) can be formed as a strictly increasing sequence starting from $$$0$$$. Thus, this $$$dp[i]$$$ contributes to the final answer.

5) Code: https://codeforces.me/contest/2259/submission/389626088

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

Why is there no code?

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

I failed E purely for the reason of misunderstanding this line " a[i] ** indicates the minimum number of islands that Bessie would need to travel** ". I thought it meant that treasure can exist anywhere other than range i-a[i]+1 and i+a[i]-1. Hate myself.

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

Great contest, hope more like this one :)

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

nice contest, learn a lot tysm

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

honestly, problem A was harder than B, what do you think?

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

bullshit problems

»
3 weeks ago, hide # |
 
Vote: I like it -11 Vote: I do not like it

Hello, I participated in this contest as an official contestant (handle: SXWisON). I solved 8/8 problems and finished around rank 15, but I am not in the rating changes list and my rating is still 1325. Could you please check if my rating update was missed? Thank you.

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

solution to G using two lazy segment trees

using SS = pair<ll, ll>;
using F = ll;
SS e_() {
    return {0, 0};
}
 
SS op_(SS a, SS b) {
    return {a.first + b.first, a.second + b.second};
}
 
SS mapping_(F f, SS x) {
    SS res;
    res.first = x.first + f * x.second;
    res.second = x.second;
    return res;
}
 
F composition_(F f, F g) {
    return f + g;
}
 
F id_() {
    return 0LL;
}
 
using S = ll;
S e() {
    return 4e18;
}
 
S op(S a, S b) {
    return min(a, b);
}
 
S mapping(F f, S x) {
    return x + f;
}
 
F composition(F f, F g) {
    return f + g;
}
 
F id() {
    return 0LL;
}
 
void solve() {
    int n; ll k; cin >> n >> k;
    vector<ll> dif(n - 1);
    vector<ll>a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }    
    for (int i = 0; i < n - 1; i++) {
        dif[i] = a[i + 1] - a[i];
    }
    vector<ll> ans;
    atcoder::lazy_segtree<SS, op_, e_, F, mapping_, composition_, id_> seg1(n - 1);
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(n - 1);
    for (int i = 0; i < n - 1; i++) {
        seg1.set(i, make_pair(0LL, 1LL));
        seg.set(i, 0LL);
    }
    for (int i = n - 2; i > 0; i--) {
        seg.apply(i, n - 1, a[i + 1] - a[i - 1]);
        seg1.apply(i, n - 1, a[i + 1] - a[i - 1]);
        if (i + 1 <= n - 2) {
            seg.apply(i + 1, n - 1, -k);
            seg1.apply(i + 1, n - 1, -k);
        }
        int j = seg.max_right(i, [&](ll x) {
            return x > k;
        });
        ans.push_back(max(0LL,seg1.prod(i, j).first - k*(j-i)));
        seg.apply(i, n - 1, -a[i + 1] + a[i - 1]);
        seg1.apply(i, n - 1, -a[i + 1] + a[i - 1]);
        seg.apply(i, n - 1, dif[i]);
        seg1.apply(i, n - 1, dif[i]);
    }
    ans.push_back(0);
    ans.insert(ans.begin(),0);
    reverse(ans.begin(),ans.end());
    for(ll x:ans){
        cout<<x<<' ';
    }
    cout<<'\n';
}
  • »
    »
    3 weeks ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    in both rounds I've set, half the problems had unintended segtree solutions... (in my div4 D, E, F, and H, in this one, E, F, G, and H)

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

just gave it as virtual, great contest keep up the great work <3

»
3 weeks ago, hide # |
 
Vote: I like it -12 Vote: I do not like it

Can we demonstrate the correctness of the solution for problem D?

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

D is interesting but a bit difficult for me.

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

Problem E was a good one. Really enjoyed solving it!

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

F is easier than E !!!!

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

thanks for the editorial

»
13 days ago, hide # |
 
Vote: I like it -12 Vote: I do not like it

It seems editorial solution for 2259C is not correct. It is giving wrong output for this case: 7 -1 0 1 -1 0 0 1

output: 1 0 1 0 0 0 1

expected output: 0 0 1 0 0 0 1