Codeforces Round 1130 (Div. 1 + Div. 2)

Hi, Codeforces!

On Oct/09/2026 17:35 (Moscow time) we will host Codeforces Round 1130 (Div. 1 + Div. 2). The round is combined and rated for all participants.

You will be given 8 problems and 2 hours 30 minutes to solve them. One of the problems is interactive, so please read the guide for interactive problems if you are not familiar with them.

The problems were authored and prepared by kaleido and shiomi. Thanks to:

Score distribution: 250 – 500 – 1000 – 1500 – 2000 – 2500 – 3000 – 3500.

UPD: the editorial will be published right after system testing.

+412
389 Full text and comments »

Educational Codeforces Round 196 — Editorial

Thank you for participating! Hints come before the tutorials, so open them one at a time if you want to keep thinking.

2304A — Odd One Out

Hint 1

How many distinct values can the array contain?

Tutorial

Compare the first three elements to find the majority value, then scan for the element that differs.

Solution

O(n) per test case.

2304B — Monocarp and Coins

Hint 1

Look at the coins from the largest to the smallest. When is it never worse to take the current coin?

Hint 2

An exchange argument works here.

Tutorial

Sort, then take greedily.

Full text and comments »

+187
96 Full text and comments »

Iterating over submasks: why the total is O(3n)

A short note, because I keep seeing this in my students' code. To process all pairs (mask, submask), people loop over all 2n values twice and check (s & mask) == s. That is 4n iterations. The standard idiom:

for (int mask = 0; mask < (1 << n); mask++) {
    for (int s = mask; s > 0; s = (s - 1) & mask) {
        // s is a non-empty submask of mask
    }
}

Every bit is in one of three states: not in mask, in mask but not in s, or in both. So the inner loop runs 3n times in total: for n = 18 that is about 3.9·108 instead of 6.9·1010.

Full text and comments »

+264
41
Full text and comments »