AmShZ's blog

By AmShZ, history, 23 hours ago, In English

I and Amoo_Safar always discuss our lazy segment tree logic.

The difference is this:

When I enter a node, I first apply its pending lazy value to the node itself.

But Amoo_Safar's assumption is that when he enters a node, the lazy value has already been applied before.

Below I show how this difference appears in implementation.

Amoo_Safar's style

In this style, the node is considered already updated correctly. The lazy value only means that this effect still has to be pushed to the children later.

So before going deeper, we call shift(id).

void upd(int id, int val) {
    seg[id] += val;
    lazy[id] += val;
}

void shift(int id) {
    if (!lazy[id]) return;
    upd(id << 1, lazy[id]);
    upd(id << 1 | 1, lazy[id]);
    lazy[id] = 0;
}

void update(int id, int l, int r, int ql, int qr, int val) {
    if (qr <= l || r <= ql) return;
    if (ql <= l && r <= qr) {
        upd(id, val);
        return;
    }
    shift(id);
    int mid = (l + r) >> 1;
    update(id << 1, l, mid, ql, qr, val);
    update(id << 1 | 1, mid, r, ql, qr, val);
    seg[id] = pull(seg[id << 1], seg[id << 1 | 1]);
}

My style

In this style, when I enter a node, I do not assume its pending lazy has already been applied to the node itself.

So the first step is to call shift(id, l, r) and make the node clean at that moment.

void shift(int id, int l, int r) {
    if (!lazy[id]) return;
    seg[id] += lazy[id];
    if (r - l > 1) {
        lazy[id << 1] += lazy[id];
        lazy[id << 1 | 1] += lazy[id];
    }
    lazy[id] = 0;
}

void update(int id, int l, int r, int ql, int qr, int val) {
    shift(id, l, r);
    if (qr <= l || r <= ql) return;
    if (ql <= l && r <= qr) {
        lazy[id] += val;
        shift(id, l, r);
        return;
    }
    int mid = (l + r) >> 1;
    update(id << 1, l, mid, ql, qr, val);
    update(id << 1 | 1, mid, r, ql, qr, val);
    seg[id] = pull(seg[id << 1], seg[id << 1 | 1]);
}

Both are correct. The main difference is just the invariant you keep in your head while writing the code.

Which one do you use, and why?

Full text and comments »

  • Vote: I like it
  • +38
  • Vote: I do not like it

By AmShZ, 10 days ago, In English

Hello everyone!

We are back!

Due to the ongoing war in Iran, we had to postpone Repovive Standard Round 2.
While the situation prevented us from hosting the contest on time, we used this period to fix several technical issues and improve the platform.

We are now ready to host Repovive Standard Round 2. We hope you enjoy it!

The contest is rated for everyone.

See you on the leaderboard!

UPD1: Fortunately, the contest went smoothly without any issues. You can view the solutions in the Learn tab.

Congratulations to the top participants:

Full text and comments »

  • Vote: I like it
  • +37
  • Vote: I do not like it

By AmShZ, history, 11 days ago, In English

Hi everyone,

I’ve been wondering about a question that might be quite useful for contest platform organizers. If a contest is held on a Sunday, what starting time do you prefer the most?

If you had to choose between these options:

  • 10:00 UTC
  • 12:00 UTC (Usual AtCoder time)
  • 14:30 UTC (Usual Codeforces time)
  • 16:00 UTC

Or if you prefer a completely different time, please let me know the time as well as your time zone.

Full text and comments »

  • Vote: I like it
  • +72
  • Vote: I do not like it

By AmShZ, 2 months ago, In English

We’re excited to announce our upcoming contest, Repovive Standard Round 1!

UPD: Due to a schedule conflict with a Codeforces contest, the start time has been changed.

UPD2: The contest has been postponed by one more day.

The contest is rated for everyone.

The Innovation Game (TIG) is sponsoring this contest!

To make this contest even more exciting, TIG is dropping some rewards:

  • 1st Place: $100 in TIG tokens
  • 2nd Place: $50 in TIG tokens
  • 3 random participants from the Top 100 will each receive $20 in TIG tokens
  • 3 random participants will each receive $20 in TIG tokens

When you finish competing, check out what TIG is building. They run a continuous, 24/7 algorithmic competition to ensure frontier algorithms remain open-source. You can submit optimized code to win from their weekly prize pools (currently $9K in TIG Tokens). Learn more and start earning on their network here.

Full text and comments »

  • Vote: I like it
  • -13
  • Vote: I do not like it

By AmShZ, history, 2 months ago, In English

We’re excited to announce our upcoming contest, Repovive Premier Round 2!

The contest is rated.

We’re looking forward to seeing you in the contest!

Full text and comments »

  • Vote: I like it
  • +61
  • Vote: I do not like it

By AmShZ, history, 3 months ago, In English

We’re excited to announce our upcoming contest, Repovive Premier Round 1!

We apologize for the judge issues that occurred in our previous contest, and we truly hope everything runs smoothly this time. Regarding the contest being rated, we decided to keep it rated despite the recent problems, since making it unrated would also come with its own negative consequences. Also, the Hello 2026 Round was cancelled because the internet was cut nationwide in Iran by the government, and our problem-setters were Iranian. We’re very sorry for the inconvenience and hope you can understand our difficult situation. Finally, we want to sincerely thank everyone who continues to support us.

More details about our contest series and what the Premier Rounds are can be found in this blog.

We will also have the full solution discussion with Um_nik on Repovive TV.

Good luck, and we’re looking forward to seeing you in the contest!

Full text and comments »

  • Vote: I like it
  • +50
  • Vote: I do not like it

By AmShZ, 4 months ago, In English

We’re excited to announce our upcoming contest, Repovive Hello 2026 Round!

The contest is rated.

We’re looking forward to your participation! Happy new year!

Update: We have to postpone our contest to the next Sunday. There is an internet blackout outgoing in Iran, and since most of our authors reside in Iran, we could not hear back from them till now.

Full text and comments »

  • Vote: I like it
  • +2
  • Vote: I do not like it

By AmShZ, 4 months ago, In English

We’re super excited to announce our upcoming contest, Repovive Goodbye 2025 Round!

The contest is rated. You can also check out the problems from Repovive Opening Round, here: https://repovive.com/contests/4.

If you’d like to become a tester and help us hold future contests, please let us know in the comments.

Prizes (total: $500 USD):

  • 1st place: $200
  • 2nd place: $100
  • 3rd place: $50
  • 3 random participants from the top 100: $25 each
  • 3 random participants from all contestants: $25 each

All participants with at least one submission: 100 veltos

Veltos can turn into many things, including t-shirts, mugs, and saving your streaks.

The prize winners of Repovive Goodbye 2025 Round:

  • 1: Um_nik — $200
  • 2: dXqwq — $100
  • 3: Golovanov399 — $50
  • 10: Isaac Chan — $25

  • 59: Null — $25
  • 98: Prateek Verma — $25
  • 159: Ilya Ghadiri Anari — $25
  • 197: Shuvo Morsalin — $25
  • 223: Dharun Kaarthick S — $25

If you are a winner, we will reach out to you by email.

We’re looking forward to your participation! Merry Christmas!

Full text and comments »

  • Vote: I like it
  • +56
  • Vote: I do not like it

By AmShZ, history, 5 months ago, In English

Hey everyone,

We are organizing Repovive Testing Round #2. This is the second of three testing rounds that will take place before our Opening Round.

All problems are original and authored by us. While we have reserved some of our best problems for the Opening Round, we hope you will enjoy this set as well.

Start time: December 10th at 14:35 UTC.

Registration: https://repovive.com/contests.

We would also appreciate any feedback on the problems and the platform after the round.

Full text and comments »

  • Vote: I like it
  • +34
  • Vote: I do not like it

By AmShZ, 4 years ago, In English

Hi Codeforces!

Keshi, alireza_kaviani and I are delighted to invite you to participate in Codeforces Round 800 (Div. 1) and Codeforces Round 800 (Div. 2).

  • Start time: Jun/16/2022 17:35 (Moscow time)
  • Duration: $$$120$$$ minutes
  • Number of Tasks: $$$6$$$ for both divisions
  • Rated range: ($$$-\infty$$$,$$$1899$$$] for Div2, [$$$1900$$$, $$$\infty$$$) for Div1

We are honored to have set the 800th Codeforces round. We wish this wonderful platform all the best along with many other exciting rounds.

Huge thanks to the following people:

Thanks to NEAR for supporting this round, details can be found in this post.

We have worked hard to keep the statements clean and the pretests strong!

Please read all of the problems and their notes, enjoy your time and solve as many as you can! Good luck have fun to everyone!

The scoring distributions will be announced later.

UPD: Here are the scoring distributions:

  • Div. 1: 750 1000 1500 2250 2500 3000

  • Div. 2: 500 1000 1500 1750 2250 3000

UPD: Editorial is out!

Full text and comments »

  • Vote: I like it
  • +796
  • Vote: I do not like it

By AmShZ, history, 5 years ago, In English

Hi Codeforces!

Dio, Keshi, Tet, alireza_kaviani, Davoth, AliShahali1382 and I are delighted to invite you to participate in Codeforces Round 722 (Div. 1) and Codeforces Round 722 (Div. 2), which will be held at May/24/2021 17:35 (Moscow time). Each division will have 6 problems and 2 hours and 15 minutes to solve them.

The curse has finally been lifted! We are proud to announce that antontrygubO_o didn't reject even a single task from the Div. 1 part!

Huge thanks to the following people:

For the sake of having short statements, this round does not have a theme. The characters featured in the statements are: Soroush (Tet), Sifid (Davoth), Parsa (Dio), Nima (N.N_2004), AaParsa (AaParsa), Haj Davood (davooddkareshki), Kavi (alireza_kaviani), Keshi (Keshi), Mashtali (AliShahali1382) and AmShZ (AmShZ).

Please read all of the problems and their notes, enjoy your time and solve as many as you can! Good luck have fun to everyone!

The scoring distributions will be announced later.

UPD: Here are the scoring distributions:

  • Div. 1: 750 1000 1750 2000 2750 3000

  • Div. 2: 500 1250 1750 2000 2750 3000

UPD: Editorial is out!

Full text and comments »

  • Vote: I like it
  • +1145
  • Vote: I do not like it

By AmShZ, history, 5 years ago, In English

l" Nowruz ", The Ancient Persian New year and the harmony of new birth of the nature,

has been celebrated for over 3000 years!

Happy new year 1400 to Iranians of all relligious and cultures and all other nations : )

(This will be also our last year of the 14th's century!)

ز کوی یار می آید نسیم باد نوروزی

ازین باد ار مدد خواهی چراغ دل برافروزی

Translation :

The fragrant breeze of the nowruz came from a friend

if desire aid from this breeze, you will kindle the lamp of your heart.

" The Iranian poet, Hafez Shirazi "

Full text and comments »

  • Vote: I like it
  • +266
  • Vote: I do not like it

By AmShZ, 6 years ago, In English

Hi everyone!

I'm writing this blog to give some "constructive" feedback on the current state of the tasks in the recent CF rounds. Personally speaking, I believe that tasks are becoming more and more theoretical contest after contest (by theoretical I mean tasks that are not challenging to code).

Nowadays we rarely see tasks that require algorithmic thinking or coding skills.

I personally blame this on the procedure of proposing contests, it's natural for setters to start with proposing tasks that require some coding and later on replace them with theoretical tasks (which are easier to come up with) after their first set of tasks gets rejected by the coordinators.

In fact, some setters might presume that the vast number of theoretical tasks means that they are more probable to get accepted by the coordinators.

The point I'm trying to make is that WE are the ones who are creating these tasks, therefore WE are responsible for creating this mess. Hence, I humbly request the setters to try and come up with tasks that have a rather challenging code.

Full text and comments »

  • Vote: I like it
  • +58
  • Vote: I do not like it

By AmShZ, history, 6 years ago, In English

Hi

First of all congrats too Codeforces community for having more than 23000 participants in an official round

If I want to be honest I'm not really okay with Codeforces right now, cause recently its servers went down a lot and even in the contests there's a queue that is really annoying, I have no idea about Codeforces problems or why they don't fix these issues but, as a participant I wanted to ask Mike Mirzayanov to solve these issues (like the one that was solved before about the queues and system test speed, thnx btw ). Cause with COVID 19 out there, I spend most of my time in Codeforces right now, I am sure that there are others that are like me.

And last but not least just wanted to end this blog by some beautiful quotes:

*Dab when you cough *Dab when you sneeze *Dab to beat coronavirus

-Paul Pogba 2020

Full text and comments »

  • Vote: I like it
  • +97
  • Vote: I do not like it

By AmShZ, history, 7 years ago, In English

The last contest's Codeforces Round 590 (Div. 3) was very slow; every submit, was in queuing about 10 minutes. I've lost a lot of time.

Please fix these problems :)

Full text and comments »

  • Vote: I like it
  • +50
  • Vote: I do not like it

By AmShZ, history, 7 years ago, In English

What's your favorite problem or contest?

Please Comment it ;)

Full text and comments »

  • Vote: I like it
  • +46
  • Vote: I do not like it