You can use several words in query to find by all of them at the same time. In addition, if you are lucky search understands word forms and some synonyms. It supports search by title and author. Examples:

  • 305 — search for 305, most probably it will find blogs about the Round 305
  • andrew stankevich contests — search for words "andrew", "stankevich" and "contests" at the same time
  • user:mikemirzayanov title:testlib — search containing "testlib" in title by MikeMirzayanov
  • "vk cup" — use quotes to find phrase as is
  • title:educational — search in title

Results

1.
By lotusblume, 16 months ago, In English
Worst-Case Graphs for Maximum Flow Algorithms Maximum flow algorithms are known to perform significantly better in practice than their worst-case time complexities would suggest. So in this blog, I will present graphs on which the following maximum flow algorithms actually achieve their worst-case running time: | Algorithm | Time Complexity | | ----------------------- | ------------------------------ | | Ford-Fulkerson with DFS | $\mathcal{O}\big(m^2 \cdot U)$ | | Edmonds-Karp | $\mathcal{O}\big(n \cdot m^2\big)$ | | Dinic | $\mathcal{O}\big(n^2 \cdot m\big)$ | | DFS with Scaling | $\mathcal{O}\big(m^2 \cdot \log(U)\big)$ | | Dinic with Scaling | $\mathcal{O}\big(n \cdot m \cdot \log(U)\big)$ | | Most Improving Augmenting Paths | $\mathcal{O}\big(m \cdot \log(U) \cdot (m + n \cdot \log(n))\big)$ | | FIFO Preflow Push | $\mathcal{O}\big(n^3\big)$ | | Highest-Label Preflow Push | $\mathcal{O}\big(n^2 \cdot \sqrt{m}\big)$ | Here and in the rest of this blog: - $n =$ number of vertices, ...
, ab, gh, ct$ | $\sum_{i=1}^{k} F_{3i-2}$ | | $af, hc

Full text and comments »

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

2.
By Vladithur, history, 4 years ago, In English
Codeforces Round #813 (Div. 2) Editorial Thanks for participating in the round, we hope you liked the problems! <spoiler summary="Solve count predictions (official div. 2)"> Handle | A | B | C | D | E1 | E2 | F --- | --- | --- | --- | --- | --- | --- | --- [user:Vladithur,2022-08-13] | 16K | 8K | 3K | 900 | 500 | 50 | 4 [user:_dlbm17,2022-08-13] | 14K | 9K | 5K | 500 | ? | ? | ? [user:thanhchauns2,2022-08-13] | 14K | 8K | 2K | 1K | 500 | ? | ? [user:QuangBuiCP,2022-08-13] | 14K | 7K | 2K | 1K | 500 | 24 | 5 [user:welleyth,2022-08-13] | 16K | 10K | 4K | 1.5K | 600 | 130 | 2 [user:Kon567889,2022-08-13] | 14K | 10K | 5K | 2K | ? | ? | 5 </spoiler> [problem:1712A] <spoiler summary="Hint"> The smallest possible sum is $1 + 2 + \ldots + k$. </spoiler> <spoiler summary="Tutorial"> [tutorial:1712A] </spoiler> <spoiler summary="Solution"> ~~~~~ #include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define allr(x) (x).rbegin(), (x).rend() #define gsize(x) (int)((x).size()) const ch...
// Update ST for (auto [r, ct]: segs[i]) { update(0, 0, maxn + 1, r, ct); }, ; if (i + j > k || (k % i == 0 && k % j == 0)) ct++; }, ][ti], ct = 0;, if (ct > 0) { segs[i].emplace_back(k, ct); } } }

Full text and comments »

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

3.
By jdurie, 3 years ago, In English
Codeforces Round #941 (Div. 1, Div. 2) Editorial [problem:1966A] <spoiler summary="Solution"> [tutorial:1966A] </spoiler> <spoiler summary="Code"> ~~~~~ t = int(input()) for tc in range(t): n, k = map(int, input().split()) cards = list(map(int, input().split())) ct = {} ans = n for c in cards: if c in ct: ct.update({c: ct[c] + 1}) else: ct.update({c: 1}) if ct[c] >= k: ans = k - 1 print(ans) ~~~~~ </spoiler> [problem:1966B] <spoiler summary="Solution"> [tutorial:1966B] </spoiler> <spoiler summary="Code"> ~~~~~ t = int(input()) for tc in range(t): n, m = map(int, input().split()) gr = [] for i in range(n): gr.append(input()) ans = "YES" if gr[0][0] != gr[n - 1][m - 1]: impossible = True for j in range(m - 1): if gr[0][j] != gr[0][j + 1] or gr[n - 1][j] != gr[n - 1][j + 1]: impossible = False if...
cards = list(map(int, input().split())) ct = {}, for c in cards: if c in ct: ct.update({c: ct[c] + 1}) else, for ct in cts: if len(odds) > 0 and ct == odds[-1]: odds.pop() else

Full text and comments »

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

4.
By -Morass-, history, 9 years ago, In English
Problem Topics Good Day to you! I've been asked to make some topic-wise list of problems I've solved. Even though I couldn't involve all problems, I've tried to involve at least "few" problems at each topic I thought up (I'm sorry if I forgot about something "easy"). I've alredy made such list once anyway I've tried to include more problems now &mdash; so here it is: <spoiler summary="aho"> http://www.spoj.com/problems/ADAJOBS/ URI 2226 (5) //[NICE][NUMBERS][DP] http://www.spoj.com/problems/SUB_PROB/en/ http://codeforces.me/contest/696/problem/D 8 http://www.spoj.com/problems/AHOCUR/ 5 //Aho-Corassic + DP https://www.codechef.com/problems/LYRC (5) //Sample aho-brute-force http://codeforces.me/problemset/problem/346/B //Proposed by [user:bradyawn,2019-08-03] </spoiler> <spoiler summary="automat"> 6861 [LA] //CYK UVA 10679 //Suffix Automat http://www.spoj.com/problems/STRMATCH/ //Suffix Automat &mdash; trie might do too http://www.spoj.com/problems/NSUBST...
Gym 101252C [2014-2015 CT S02E05: Codeforces Trainings Season 2 Episode 5 — 2009-2010 ACM

Full text and comments »

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

5.
By nikgaevoy, 4 years ago, In English
Push-Free Segment Tree ![ ](/predownloaded/95/ad/95ad3397de22cc8b20c52a1eccc87ac0c34e76cb.jpg) Figure 1: Tiffany A pdf version of this text could be found [here](https://acm.math.spbu.ru/trains/push_free_segment_tree.pdf). Prerequisites ------------- First of all, who this article is aimed at. This article assumes you already know what a segment tree is. Have you never heard about the segment tree, the Fenwick tree (aka binary indexed tree, BIT) or the RMQ problem, you should better read about it [somewhere else](https://codeforces.me/catalog) and then come back here right after to learn a bunch of cool stuff. The model target audience is the people able to solve [this problem](https://judge.yosupo.jp/problem/range_affine_range_sum) at least in theory. But even if you can't, this article could still be helpful. However, I think this article contains some ideas that were never published before, thus making it interesting even for people who are closely familiar with different variants o...
auto add = rectangle_add(l, r, bot, top, cl, ct, 2 * v, x) + rectangle_add(l, r, bot, auto ans = range_sum(l, r, cl, ct, 2 * v) + range_sum(l, r, ct, cr, 2 * v + 1);, auto ans = rectangle_sum(l, r, bot, top, cl, ct, 2 * v) + rectangle_sum(l, r, bot, auto ct = midpoint(cl, cr);

Full text and comments »

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

6.
By awoo, history, 4 years ago, In English
Educational Codeforces Round 143 Editorial [problem:1795A] Idea: [user:BledDest,2023-02-17] <spoiler summary="Tutorial"> [tutorial:1795A] </spoiler> <spoiler summary="Solution (Neon) 1"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { auto ok = [](string s) { for (int i = 1; i < (int)s.size(); ++i) if (s[i - 1] == s[i]) return false; return true; }; int t; cin >> t; while (t--) { int n, m; string s, t; cin >> n >> m >> s >> t; bool f = false; for (int x = 0; x < 2; ++x) { string cs = s, ct = t; for (int i = 0; i < n; ++i) { f |= ok(cs) && ok(ct); ct.push_back(cs.back()); cs.pop_back(); } swap(n, m); swap(s, t); } cout << (f ? "YES\n" : "NO\n"); } } ~~~~~ </spoiler> <spoiler summary="Solution (Neon) 2"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, m; string ...
= false; for (int x = 0; x < 2; ++x) { string cs = s, ct = t; for (int i = 0; i < n, ; bool f = false; for (int x = 0; x < 2; ++x) { string cs = s, ct = t; for, ; for (int x = 0; x < 2; ++x) { string cs = s, ct = t; for (int i = 0; i < n; ++i

Full text and comments »

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

7.
By awoo, history, 6 years ago, translation, In English
Educational Codeforces Round 88 [Rated for Div. 2] Hello Codeforces! On [contest_time:1359] [contest:1359] will start. Series of Educational Rounds continue being held as [Harbour.Space University](https://harbour.space/) initiative! You can read the details about the cooperation between [Harbour.Space University](https://harbour.space/) and Codeforces in the <a href="http://codeforces.me/blog/entry/51208">blog post</a>. This round will be **rated for the participants with rating lower than 2100**. It will be held on extended ICPC rules. The penalty for each incorrect submission until the submission with a full solution is 10 minutes. After the end of the contest you will have 12 hours to hack any solution you want. You will have access to copy any solution and test it locally. You will be given **6 or 7 problems** and **2 hours** to solve them. The problems were invented and prepared by Roman [user:Roms,2020-05-27] Glazov, Adilbek [user:adedalic,2020-05-27] Dalabaev, Vladimir [user:vovuh,2020-05-27] Petrov, Ivan [us...
Imaging for CT analysis, diagnosis and mass surveillance._, , exploring topics like Medical Imaging for CT analysis, diagnosis and mass surveillance._ _By

Full text and comments »

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

8.
By BledDest, 19 months ago, In English
Kotlin Heroes 12 - Editorial The contest was prepared by [user:adedalic,2025-04-08], [user:awoo,2025-04-08], [user:Neon,2025-04-08] and me. We had a great team of testers: [user:shnirelman,2025-04-08], [user:ashmelev,2025-04-08], [user:FelixArg,2025-04-08], [user:KIRIJIJI,2025-04-08], [user:Alenochka,2025-04-08], [user:alyoks1,2025-04-08], [user:Vladosiya,2025-04-08], [user:mariibykova,2025-04-08] &mdash; huge thanks to all of you! <spoiler summary="One insane moment from the testing phase"> One day before the contest, [user:shnirelman,2025-04-08] completely destroyed problem H in less than 15 minutes. Thankfully, I had an idea of a replacement problem. </spoiler> Thanks to all competitors for participation, I hope you enjoyed the problems we made! And last but not least, I would like to express my gratitude to [user:MikeMirzayanov,2025-04-08] for keeping Codeforces and Polygon running even under unprecedented pressure from the bots. Okay, now for the editorial itself: [problem:2087A] Idea: [us...
dp[nt].forEach { it.fill(INF) } for (i in 0 until N) for (j in 0 until N) { if (dp[ct, for (t in 0 until 2 * n) { val ct = t and 1 val nt = ct xor 1

Full text and comments »

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

9.
By cry, 15 months ago, In English
Codeforces Round 1050 (Div. 4) Editorial #### [problem:2148A] <spoiler summary="Solution (written by cry)"> Notice that if we pair each odd-indexed element with an even-indexed element, it sums to $0$. Therefore, our strategy is to pair the $2i$'th element with the $(2i+1)$th element until there are no more elements to pair. Note that if $n$ is odd, then there exists an unpaired odd element at the end. In this case, the answer will just be that ending element, which will be $x$. Otherwise, when $n$ is even, we paired every element perfectly and the sum will be $0$. Time complexity: $\mathcal{O}(1)$ per test case. </spoiler> <spoiler summary="Code (C++) (MikeMirzayanov)"> ```cpp #include <bits/stdc++.h> using namespace std; #define forn(i, n) for (int i = 0; i < int(n); i++) int main() { int t; cin >> t; forn(tt, t) { int x, n; cin >> x >> n; if (n % 2 == 0) cout << 0; else cout << x; cout << endl; } } ``` </...
, k; cin >> n >> k; vector a(n), cnt(n + 1), ct(n + 1); for (int i = 0; i < n; i, void solve() { int n, k; cin >> n >> k; vector a(n), cnt(n + 1), ct(n + 1

Full text and comments »

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

10.
By awoo, history, 7 years ago, translation, In English
Educational Codeforces Round 72 Editorial [problem:1217A] <spoiler summary="Tutorial"> [tutorial:1217A] </spoiler> <spoiler summary="Solution (adedalic)"> ~~~~~ fun main() { val t = readLine()!!.toInt() for (ct in 1..t) { val (str, int, exp) = readLine()!!.split(' ').map { it.toInt() } val minAddStr = maxOf(0, (exp + int - str + 2) / 2) println(maxOf(exp - minAddStr + 1, 0)) } } ~~~~~ </spoiler> [problem:1217B] Idea: [user:Roms,2019-09-06] <spoiler summary="Tutorial"> [tutorial:1217B] </spoiler> <spoiler summary="Solution (Roms)"> ~~~~~ #include <bits/stdc++.h> using namespace std; const int N = 105; int t; int n, m; int d[N], h[N]; int main() { cin >> t; for(int tc = 0; tc < t; ++tc){ cin >> n >> m; int maxDH = -2e9; for(int i = 0; i < n; ++i){ cin >> d[i] >> h[i]; maxDH = max(maxDH, d[i] - h[i]); } int res = 1; int maxD = *max_element(d, d + n); m -= maxD; if(m > 0){ if(maxDH <= 0) res = -1;...
="Solution (adedalic)"> ~~~~~ fun main() { val t = readLine()!!.toInt() for (ct in 1..t, ="Решение (adedalic)"> ~~~~~ fun main() { val t = readLine()!!.toInt() for (ct in 1..t, ~~~~~ fun main() { val t = readLine()!!.toInt() for (ct in 1..t) { val (str

Full text and comments »

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

11.
By catalystgma, history, 2 years ago, In English
Exponential Length Substrings in Pattern Matching Hi all, I would like to share with you a part of my undergraduate thesis on a Multi-String Pattern Matcher data structure. In my opinion, it's easy to understand and hard to implement correctly and efficiently. It's (relatively) competitive against other MSPM data structures (Aho-Corasick, suffix array/automaton/tree to name a few) when the dictionary size is specifically (uncommonly) large. I would also like to sign up this entry to [user:bashkort,2024-10-04]'s [Month of Blog Posts](https://codeforces.me/blog/entry/133806):-) Many thanks to him and peltorator for supporting this initiative. #### Abstract This work describes a hash-based mass-searching algorithm, finding (count, location of first match) entries from a dictionary against a string $s$ of length $n$. The presented implementation makes use of all substrings of $s$ whose lengths are powers of $2$ to construct an offline algorithm that can, in some cases, reach a complexity of $O(n \log^2n)$ even if there are $O...
We want the $NT$ function to depend on both $n$ and $m$, such as $NT(m) = ct \cdot n^{\alpha} m

Full text and comments »

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

12.
By kevinsogo, history, 7 years ago, In English
Codeforces Round #607 Editorial I hope you enjoyed the problems! Thanks to the onsite teams and coaches who gave feedback; I'm glad the reception was positive. Interestingly, in the onsite ICPC round, while "Kirchhoff" got several accepted solutions, "Miss Punyverse" got no accepted submissions at all! It is the reverse here. (Kirchhoff even has a trickier output format in the onsite round compared to the version presented in Codeforces.) It seems the ICPC scoreboard really affects the results greatly; what the top few teams are working on influences what everyone else will be working on. I am planning on releasing the full, untouched ICPC Manila 2019 problem set in the gym sometime in the future, so you can see which problems you missed. The Intergalactic Sliding Puzzle is _not_ the hardest problem in the round! [problem:1281A] <spoiler summary="Solution Sketch"> [tutorial:1281A] </spoiler> <spoiler summary="Accepted Code"> ~~~~~ for cas in range(int(input())): print({'o': "FILIPINO", 'a': "KOREAN...
for v in range(2, 4*k + 2): ct = flat.index(v), if ct >= 1: st += 'G' flat = flat[1:3] + flat[:1] + flat[3:], if ct >= 2: st += 'L'*(ct - 2) + 'GR'*(ct - 2) + 'G' flat = flat[ct - 1

Full text and comments »

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

13.
By OtterZ, history, 11 months ago, In English
Border Theory:There's a fast approach to bruteforce on borders UPD:Thanks to comment from [user:arvindf232,2025-12-20] and [user:pajenegod,2025-12-20],I rewrote parts of this post to improve clarity with the help of Chatgpt. I hope it reads more smoothly now. # Preface In this blog, I want to share Border Theory, a useful and elegant insight about string borders that often appears in competitive programming. Although this idea deserves to be as well-known as the KMP algorithm, many people today aren’t aware of it or how to use it to speed up their solutions. # Main Theoretical Result of Border Theory ## Main Result For a string $S$, a border is a substring that is both a prefix of $S$ and a suffix of $S$. For a string $S$, we define that: $$ \{b_i\}_{i=1}^n$$ is the sequence of all lengths of the border of $S$, sorted in increasing order. According to the theory,it's garenteed that for all possible $S$, ${B_i}_{i = 1}^n$ can be partitioned into $\operatorname{O}(\log |S|)$ continuous subsequences where each subsequence f...
[1000009],diff[1000009],cnt; char s[500009],t[500009],ct[500009]; int dp[1000009],las[1000009],mn, ][26],tp[1000009],len[1000009],diff[1000009],cnt; char s[500009],t[500009],ct [500009]; int dp

Full text and comments »

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

14.
By awoo, history, 7 years ago, translation, In English
Educational Codeforces Round 76 Editorial [problem:1257A] Idea: [user:Roms,2019-11-14] <spoiler summary="Tutorial"> [tutorial:1257A] </spoiler> <spoiler summary="Solution (adedalic)"> ~~~~~ import kotlin.math.abs fun main() { val q = readLine()!!.toInt() for (ct in 1..q) { val (n, x, a, b) = readLine()!!.split(' ').map { it.toInt() } println(minOf(n - 1, abs(a - b) + x)) } } ~~~~~ </spoiler> [problem:1257B] Idea: [user:BledDest,2019-11-14] <spoiler summary="Tutorial"> [tutorial:1257B] </spoiler> <spoiler summary="Solution (Ne0n25)"> ~~~~~ #include <bits/stdc++.h> using namespace std; void solve() { int x, y; cin >> x >> y; if (x > 3) puts("YES"); else if (x == 1) puts(y == 1 ? "YES" : "NO"); else puts(y <= 3 ? "YES" : "NO"); } int main() { int tc; cin >> tc; while (tc--) solve(); } ~~~~~ </spoiler> [problem:1257C] Idea: [user:adedalic,2019-11-14] <spoiler summary="Tutorial"> [tutorial:1257C] </spoiler> <s...
~~~~~ import kotlin.math.abs fun main() { val q = readLine()!!.toInt() for (ct in 1..q

Full text and comments »

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

15.
By Vladosiya, history, 4 years ago, translation, In English
Codeforces Round #826 (Div. 3) Editorial [problem:1741A] Idea: [user:MikeMirzayanov,2022-10-12] <spoiler summary="Tutorial"> [tutorial:1741A] </spoiler> <spoiler summary="Solution"> ~~~~~ #include <bits/stdc++.h> using namespace std; #define forn(i, n) for (int i = 0; i < int(n); i++) #define sz(v) (int)v.size() #define all(v) v.begin(),v.end() #define eb emplace_back void ct(char c) { cout << c << '\n'; } void solve() { string a,b; cin >> a >> b; char ca = a.back(); char cb = b.back(); if (ca == cb) { if (sz(a) == sz(b)) cout << '='; else if (ca == 'S') { cout << (sz(a) < sz(b) ? '>' : '<'); } else { cout << (sz(a) < sz(b) ? '<' : '>'); } }else cout << (ca < cb ? '>' : '<'); cout << '\n'; } int main() { int t; cin >> t; forn(tt, t) { solve(); } } ~~~~~ </spoiler> [problem:1741B] Idea: [user:MikeMirzayanov,2022-10-12] <spoiler summary="Tutorial"> ...
void ct(char c) { cout << c << '\n'; }

Full text and comments »

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

16.
By Edvard, history, 11 years ago, translation, In English
Editorial of Educational Codeforces Round 12 ### [problem:665A] The problem was suggested by Sergey Erlikh [user:unprost,2016-04-21]. Consider the time interval when Simion will be on the road strictly between cities $(x_1, y_1)$ ($x_1=60h+m, y_1=x_1+t_a$). Let's iterate over the oncoming buses. Let $(x_2, y_2)$ be the time interval when the oncoming bus will be strictly between two cities. If the intersection of that intervals $(x=max(x_1, x_2), y=min(y_1, y_2))$ is not empty than Simion will count that bus. <spoiler summary="С++ solution"> ~~~~~ int a, ta; int b, tb; int h, m; bool read() { if (!(cin >> a >> ta)) return false; assert(cin >> b >> tb); assert(scanf("%d:%d", &h, &m) == 2); return true; } void solve() { int x1 = h * 60 + m; int y1 = x1 + ta; int ans = 0; for (int x2 = 5 * 60 + 0; x2 < 24 * 60; x2 += b) { int y2 = x2 + tb; int x = max(x1, x2), y = min(y1, y2); if (x < y) ans++; } cout << ans << endl; } ~~~~~ </spoiler> ...
/ 2) continue; forn(nj, A - 1) { if (nj == j) continue; int ct = nj != c; if (z[i, ; forn(nj, A - 1) { if (nj == j) continue; int ct = nj != c; if (z[i + 1][nj] > dv, ]; if (dv > INF / 2) continue; forn(nj, A - 1) { if (nj == j) continue; int ct = nj

Full text and comments »

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

17.
By rahulgoel, history, 4 years ago, In English
Editorial for CodeCraft-22 and Codeforces Round #795 (Div. 2) [problem:1691A] ================== **[Video Editorial](https://youtu.be/CwsYQXjIwDg)** **Idea:** [user:amul_agrawal,2022-05-26] **Problem Setting:** [user:menavlikar.rutvij,2022-05-26] [user:JadeReaper,2022-05-26] [user:rahulgoel,2022-05-26] [user:amul_agrawal,2022-05-26] **Editorial**: [user:menavlikar.rutvij,2022-05-26] [user:rahulgoel,2022-05-26] **Video Editorial**: [user:rahulgoel,2022-05-26] <spoiler summary="Hint 1"> Sum of two odd numbers is even and sum of two even numbers is also even. </spoiler> <spoiler summary="Hint 2"> If all consecutive pairs have even sum, can we generalize something about the sequence using the above hint? </spoiler> <spoiler summary="Solution"> [tutorial:1691A] </spoiler> <spoiler summary="C++ Code"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; int num...
num_comps(){ int ct = 0; for(int i=0; ict

Full text and comments »

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

18.
By applepi216, 2 weeks ago, In English
Codeforces Round 1133 (Div. 1, Div. 2) Editorial Thank you everyone for participating in the round! We hope you enjoyed the problems :) ### [problem:2280A] Problem author: [user:conqueror_of_tourist,2026-11-07] <spoiler summary="Hint"> What happens when $k$ is even? What happens when $k$ is odd? </spoiler> <spoiler summary="Solution"> [tutorial:2280A] </spoiler> <spoiler summary="Code"> ~~~~~ for _ in range(int(input())): n, k = list(map(int, input().split())) a = list(map(lambda x: int(x) % 2, input().split())) b = list(map(lambda x: int(x) % 2, input().split())) if k % 2 == 0: print("YES" if a.count(0) <= b.count(0) else "NO") else: print("YES" if b.count(0) <= a.count(0) else "NO") ~~~~~ </spoiler> ### [problem:2280B] Problem author: [user:applepi216,2026-11-07] <spoiler summary="Hint"> What must all strings whose answer is ``NO'' look like? </spoiler> <spoiler summary="Solution"> [tutorial:2280B] </spoiler> <spoiler summary="Code"> ~~...
() ct = int(input()) if ct == 0: print("! NO") continue print("?", 1, ) sys.stdout.flush() ct = int(input()) if ct == 0: print("! NO") continue

Full text and comments »

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

19.
By greateric, history, 3 months ago, In English
Useless CP Information #10: Shuffling Poker Chips Backstory: "Problem statement v2" was a problem I tried to propose for our round. Unfortunately, a really similar version ("Problem statement v1") has been used before. But then we had the question of if these two problem statements were actually the same or different. Are the answers to both problems always going to be the same, or is there an example out there where they differ? Problem statement v1 ------------------ This is a problem you might have seen before. Eric has $n$ (where $n$ is even) poker chips. They are currently in a stack, the bottom one is numbered $1$, the second-bottom one is numbered $2$, ..., the top one is numbered $n$. Eric will shuffle the poker chips by interleaving the bottom half and the top half together. Formally, this permutes the stack from $$1, 2, ..., n$$ to $$1, \frac{n}{2}+1, 2, \frac{n}{2}+2, 3, \frac{n}{2}+3, ..., \frac{n}{2}, n.$$ How many shuffles must he perform to revert to the starting position? (Find the minimum number)...
set, but that's not possible since $t < \frac{N}{2} < c$. - If $c < \frac{N}{2}$ and $ct < N$, then, the set, but that's not possible since $t < \frac{N}{2} < c$. - If $c < \frac{N}{2}$ and $ct < N

Full text and comments »

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

20.
By Qingyu, 2 years ago, In English
IOI 2025 China Team Selection — Current Standings Hi, everyone. The first stage of the IOI 2025 China Team Selection began yesterday. The top 50 participants from the 2024 National Olympiad in Informatics (NOI) will compete for a spot on the Chinese national team for IOI 2025. The rule of selecting CHN team this year: + Homework (10%): also known as mutual tests, where the students were asked to prepare a task (5%), and participate in the contests made by other students (5%) + First stage (<b>CTT</b>; 54%; Dec 3, 2024 &mdash; Dec 5, 2024): three contests in classic olympiad format, where each contest worthes 18% of the score. Top 30 participants will advance to the final stage. + Final stage (<b>CTS</b>; 36%; Jan 20, 2025 &mdash; Jan 22, 2025): two contests in classic olympiad format, where each contest worthes 18% of the score. The current scoreboard can be found [here](https://docs.google.com/spreadsheets/d/11Sh6zczubJ9eJxgSkyBcDL_EaZhHuwbyyZNlkLx1Avc). Past problems of the China IOI Team Selections can be found her...

Full text and comments »

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

21.
By awoo, history, 7 years ago, translation, In English
Educational Codeforces Round 75 Editorial [problem:1251A] Idea: [user:BledDest,2019-10-25] <spoiler summary="Tutorial"> [tutorial:1251A] </spoiler> <spoiler summary="Solution (Ne0n25)"> ~~~~~ #include <bits/stdc++.h> using namespace std; bool ans[26]; void solve() { string s; cin >> s; memset(ans, 0, sizeof(ans)); for (int i = 0; i < s.size(); i++) { int j = i; while (j + 1 < s.size() && s[j + 1] == s[i]) j++; if ((j - i) % 2 == 0) ans[s[i] - 'a'] = true; i = j; } for (int i = 0; i < 26; i++) if (ans[i]) cout << char('a' + i); cout << endl; } int main() { int q; cin >> q; while (q--) solve(); } ~~~~~ </spoiler> [problem:1251B] Idea: [user:adedalic,2019-10-25] <spoiler summary="Tutorial"> [tutorial:1251B] </spoiler> <spoiler summary="Solution (adedalic)"> ~~~~~ fun main() { val q = readLine()!!.toInt() for (ct in 1..q) { val n = readLine()!!.toInt() var (odd, evenGood, evenBad) = listOf(0, 0, 0) ...
~~~~~ fun main() { val q = readLine()!!.toInt() for (ct in 1..q) { val n

Full text and comments »

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

22.
By simplelife, 8 months ago, In English
Codeforces Round 1089 (Div. 2) Editorial Thank you for participating in our round. We apologise for C2 being too hard compared to C1. UPD : Added an alternative solution to B, which contains the original solution with a diagram for better understanding. [problem:2210A] Idea: [user:ritam1234,2026-03-27], Preparation: [user:ritam1234,2026-03-27] <spoiler summary="Solution"> We observe that $$x \bmod (x-1) = \begin{cases} 1 & \text{if } x > 2 \\ 0 & \text{if } x = 2 \end{cases}$$ Now observe that the sequence $n, n-1, \dots, 1$ satisfies the problem's condition (since $1 \ge 1 \ge \dots \ge 0$). Hence, the sequence $n, n-1, \dots, 1$ works. </spoiler> [problem:2210B] Idea: [user:ritam1234,2026-03-27], Preparation: [user:ritam1234,2026-03-27], [user:Argentum47,2026-03-27] <spoiler summary="Hint 1"> Suppose the game ends at chair $k$ (or chair $n+1$ if the game ends after successfully visiting the $n-th$ chair) , try to find the maximum number of chairs you can visit as a function of $k$. </spoil...
count_adjacent_pairs = [](string &s) -> int { int m=s.size(); int ct=0; for(int i=0;i, n+1$. For now consider $kct$ denote the count of chairs such that $p_i\ge k,i, ); s[i-1]=((s[i-2]-'0')^type1^type2)+'0'; } } int la=ask(1+(n&1),n); int ct=0, Let $ct$ denote the count of chairs such that $p_i\ge k,i, Now according to exchange argument, there should be atleast $ct$ chairs to right of k such that

Full text and comments »

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

23.
By RobinFromTheHood, history, 2 years ago, In English
Codeforces Round 974 (Div. 3) Editorial Thank you all for participating in the round! We hope you had fun, as we did thinking of the problems. We would like to again thank our coordinator [user:Vladosiya,2024-09-18] who made many suggestions for improving all problems here, and rejecting others. [problem:2014A] Author: [user:RobinFromTheHood,2024-09-18] <spoiler summary="solution"> This problem requires a simple implementation. Set a variable (initially $0$) to represent the gold Robin has, and update it according to the rules as he scans through $a_i$, adding $1$ to answer whenever Robin gives away a gold. </spoiler> <spoiler summary="code python"> ~~~~~ import sys input = lambda: sys.stdin.readline().rstrip("\r\n") sint = lambda: int(input()) mint = lambda: map(int, input().split()) aint = lambda: list(map(int, input().split())) ############################################### t = sint() for _ in range(t): n,k=mint() a=aint() cur=0 ans=0 for ai in a: if ai >= k: ...
(t): n,d,k=mint() ct=[0]*(n+2) for _ in range(k): L,R=mint() ct[max

Full text and comments »

24.
By Crysfly, history, 12 months ago, In English
IOI 2026 China Team Selection — Current Standings Hi, everyone. The first stage of the IOI 2026 China Team Selection has ended today. The top 48 participants from the 2025 National Olympiad in Informatics (NOI) will compete for a spot on the Chinese national team for IOI 2026. The rule of selecting CHN team this year: - Homework (10%). The participants are asked to choose 4 tasks for [homework](https://qoj.ac/contest/2550) and complete 60 tasks of them. - First stage (CTT; 54%; Dec 2, 2025 — Dec 4, 2025): three contests in classic olympiad format, where each contest worthes 18% of the score. Top 30 participants will advance to the final stage. - Final stage (CTS; 36%; Feb 10, 2026 — Feb 12, 2026): two contests in classic olympiad format, where each contest worthes 18% of the score. The current scoreboard can be found [here](https://docs.google.com/spreadsheets/d/1RW3yH8TGjACzyxOG3I1XvqrKROTRLQ2YpvRVS4fY4Z4/edit?gid=0#gid=0). Tasks of the first round can be found [here](https://qoj.ac/category/606) --- UPD1: The Day...

Full text and comments »

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

25.
By shiny_shine, 2 years ago, In English
Luogu Elementary Round #14 & Flanksy Round I Editorial by Redshift_Shine × SyuAyaka (PARTIAL) ## 1. Up to the Clouds <spoiler summary="Hint 1"> $x\oplus x=0$ </spoiler> <spoiler summary="Hint 2"> $x\oplus x\oplus x=x$ </spoiler> <spoiler summary="Hint 3"> The answer depends on parity. </spoiler> <spoiler summary="Solution"> If $m$ is even, then the result of the formula is always $0$. Otherwise, it can be any **positive** integer, because all the elements in the sequence $a$ is positive. </spoiler> <spoiler summary="Code"> ```c++ #include <iostream> using namespace std; const int N = 1e5 + 10; int n, m; void run() { scanf("%d%d", &n, &m); puts((m & 1) ^ (!n) ? "Yes" : "No"); } int main() { int T = 1; scanf("%d", &T); while (T--) run(); } ``` </spoiler> ## 2. Song of Silent River <spoiler summary="Hint 1"> **Lexicographically** smallest. </spoiler> <spoiler summary="Hint 2"> If you can keep the current character `a`, then do it. </spoiler> <spoiler summary="Solution"...

Full text and comments »

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

26.
By Lever, history, 5 weeks ago, In English
How to be able to propose a contest without talent With the new change, and the clarifications it is now possible to set without having talent. The following are claims which will be referenced: 1: We consider "competency" to be the ability to get 1600+, and "talent" to be the minimum description for someone that can get 1900+ 2: We may safely assume that EV of reaching blue for anyone competent(1) is <=6 months, i.e. you should be expected to get blue every 6 months. 3: If you are not competent(1), this is likely not because of innate problems, you just need to practice more and put in effort. 4: I claim we can add two expected values together despite their independence, it seems to work but I have no proof for this. As such, For someone to reach blue k times with EV 6 months, we can expect them to reach blue k times in 6*k months. 5: As stated we interpret the threshold for being able to propose a contest to be 6: Unlike competency, talent is innate and I could write a whole research paper on it (let me know if you'...
understanding of what happens. ~~~~~ ct = 0; for(int i = 0; i < ratedContest; i++) {ct, ~~~~~ ct = 0; for(int i = 0; i < ratedContest; i++) { ct+=(newRating[i]>=1600); } return

Full text and comments »

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

27.
By Roms, history, 7 years ago, In English
Сodeforces Round 591 (and Technocup 2020 — Elimination Round 1) Editorial [problem:1223A] Idea: [user:Roms,2019-10-06] <spoiler summary="Tutorial"> [tutorial:1223A] </spoiler> <spoiler summary="Solution (Roms)"> ~~~~~ for t in range(int(input())): n = int(input()) print(2 if n == 2 else (n & 1)) ~~~~~ </spoiler> [problem:1223B] Idea: [user:Roms,2019-10-06] <spoiler summary="Tutorial"> [tutorial:1223B] </spoiler> <spoiler summary="Solution (Roms)"> ~~~~~ for t in range(int(input())): print('NO' if len(set(input()) & set(input())) == 0 else 'YES') ~~~~~ </spoiler> [problem:1223C] Idea: [user:MikeMirzayanov,2019-10-06] <spoiler summary="Tutorial"> [tutorial:1223C] </spoiler> <spoiler summary="Solution (adedalic)"> ~~~~~ fun calc(p: IntArray, len: Int, x: Int, a: Int, y: Int, b: Int): Long { var ans = 0L var (cX, cY, cXY) = listOf(0, 0, 0) for (i in 1..len) { if (i % a == 0 && i % b == 0) cXY++ else if (i % a == 0) cX++ else if (i % b == 0) cY++ ...
fun main() { val q = readLine()!!.toInt() for (ct in 1..q) { val n = readLine

Full text and comments »

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

28.
By awoo, history, 7 years ago, translation, In English
Educational Codeforces Round 87 [Rated for Div. 2] Hello Codeforces! On [contest_time:1354] [contest:1354] will start. **Please notice the unusual time.** Series of Educational Rounds continue being held as [Harbour.Space University](https://harbour.space/) initiative! You can read the details about the cooperation between [Harbour.Space University](https://harbour.space/) and Codeforces in the <a href="http://codeforces.me/blog/entry/51208">blog post</a>. This round will be **rated for the participants with rating lower than 2100**. It will be held on extended ICPC rules. The penalty for each incorrect submission until the submission with a full solution is 10 minutes. After the end of the contest you will have 12 hours to hack any solution you want. You will have access to copy any solution and test it locally. You will be given **6 or 7 problems** and **2 hours** to solve them. The problems were invented and prepared by Roman [user:Roms,2020-05-15] Glazov, Adilbek [user:adedalic,2020-05-15] Dalabaev, Vladimir [...
Medical Imaging for CT analysis, diagnosis and mass surveillance._, , exploring topics like Medical Imaging for CT analysis, diagnosis and mass surveillance._ _Join us on

Full text and comments »

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

29.
By akhan42, history, 5 years ago, In Russian
ICPC 2021 Finals Разбор I- Quests Допустим что ваша последовательность выполнения квестов выглядит как то так, `1 с с 1 с 1 ...`. Где единицы соответствуют тому что вы выполнили квесты без бонуса, а `с` с бонусом. Тогда можно единицы передвинуть в конец, таким образом если вы выполнили квест с бонусом он так и останется с бонусом, если без бонуса вы и в конце его без бонуса выполните. То есть можно решать задачу так что в начале вы выполняете все с бонусом, а в конце без бонуса. Если `x[1] ... x[k]` это xps полученные с бонусом, а `x[k+1] ... x[n]` без бонуса, ваш общий xp в конце игры будет `c * (x[1] + ... x[k]) + x[k+1] + ... + x[n]`, где `x[1] + ... x[k] + x[k+1] + ... + x[n]` фиксированная величина. Значит вам надо максимизировать `(c - 1) * (x[1] + ... x[k])` или `x[1] + ... x[k]`. Заметим если мы выполнили квесты `1 ... k` с бонусом, то должны были выполняться следующие неравенства: `c * (x[1] + ... + x[k]) < v * d[k] + c * x[k]` для всех `k`. Потому что после выполнения `x[k - 1]` квеста у вас `c * (x[1]...
; int sumx = 0; for(int ct = 0; ct < n; ct++) { int x, d; cin >> x >> d, for(int ct = 0; ct < n; ct++) { int x, d; cin >> x >> d; arr.insert(mp(v

Full text and comments »

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

30.
By wasa855, history, 6 years ago, In English
Are there any mistakes in the special judge of problem 1078E? Are there any mistakes in the special judge of problem 1078E? I wrote my own special judge to check my answer and it passed, so I think the special judge is wrong. Or anyone can find mistakes in my code or my special judge? Thanks a lot. If you can help me, I believe you can find a girlfriend easily. ( **upd: My construct method also passed special judges written by my friends. But my friends and I submitted different construct methods, and discoverd that the official special judge might don't support doing operation `t` many times.** My Code: ```cpp #include<bits/stdc++.h> using namespace std; #define pb push_back #define eb emplace_back #define mp make_pair #define Fast_IO ios::sync_with_stdio(false); #define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__) //mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); #define fir first #define sec second #define mod 998244353 #define ll long long #define inf 0x...
(int i=1;i<=32;i++) cout<<"r"; cout<<"dd"; } void cpy(char m) {printf("10%ct ",m);} void getd, ) {printf("10%ct",m);} void getd() { cout<<"uu"; cout<<"100dsdttt"; cout<<"u"; cpy('d'); cout<<"u, ; } typedef pair pii; #define N 1000005 map a; int opt[N],res[N],ct; char ans_file[N

Full text and comments »

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

31.
By akhan42, history, 5 years ago, In Russian
ICPC finals 2021 - problem F, Ley lines Задача геометрическая. Мы решим ее за `n ^ 2 * log n` время. Назовем линию шириной t, полоской шириной t или просто полоской. Пусть у нас есть какое то решение и наша полоса не содержит на краю никакие точки. Тогда мы ее можем двигать до тех пор пока она станет содержать на краю у себя какую то точку. Теперь решение будет в форме что у нас есть какая то точка `P`, через нее мы провели полоску (так что `P` на краю полоски) и эта полоска содержит максимальное количество точек. Давайте выберем точку `P`, и заметим что полоску можно определять через угол и соответственно вращать на все 360 градусов и это будут различные полоски, давайте представлять такие полоски через угол. Ключевое наблюдение в задаче, пусть есть другая точка `Q`. Вот пока мы вращаем нашу полоску начиная с какого то угла альфа она будет содержать точку `Q`. Потом пройдя какой то угол бетта она перестанет ее содержать. То есть существует отрезок [альфа, бетта] и если взять любой угол из этого отрезка и представить ...
)); /// right end of a segment } int ct = 0; /// compute the number of segments which, for(auto iter = tochki.begin(); iter != tochki.end(); ++iter) { ct += -2 * (iter, int ct = 0; /// compute the number of segments which contain -179.99... point /// (those

Full text and comments »

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

32.
By Ashrayy, history, 3 years ago, In English
My Solution to 1972C Permutation Counting Hey everyone, I appeared for the contest and solved [1972C](https://codeforces.me/contest/1972/problem/C). I made a stupid error that got me lagging behind int the contest but I found a solution in time. I'm pretty sure, other people might have also come up with this idea but my version makes it easier for beginners to understand. You can refer to my solution [here](https://codeforces.me/contest/1972/submission/258910359) . First things first, we start with making maximum number of permutations that we can. We maintain the count of used coins and deduct them whenever used, we break the loop when we reach a point where we have insufficient coins. sort the array ~~~~~ // ct1 is the number of type of coins passed until now int ct=a[0],ct1=1;; for (int i=1;i<n;i++){ if(a[i]>a[i-1]){ int add = ct1*(a[i]-a[i-1]); if(m<add){ ct+=m/ct1; m-=(m/ct1)*ct1; break; } ...
, i.e., 1..n. This implies [ct] permutations will require [ct] occurances of every type of card., - ct : number of permutations we made (full permutations with n elements), Now we just subtract ct from the available coins, and get the extra coins that we are left with, we, ~~~~~ // ct1 is the number of type of coins passed until now int ct =a[0],ct1=1;; for, ~~~~~ int n2=0,n1=0; for(int i=0;ict); if(k>=2

Full text and comments »

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

33.
By gwgdg, 18 months ago, In English
A Beginner's Guide to Number Theory Concepts in Competitive Programming through a Single Problem! To understand these concepts, you just need basic arithmetic knowledge, typically covered up to 10th-grade mathematics. I'll start straight away by introducing the problem. First, the easier version, and then we'll move to the harder version, which is just the easier version with increased constraints. **Problem Statement** – Given an array $A$ of size $N$ and a positive integer $M$, perform these steps: - First, create array $B$ such that $B_i = A_i \times M!$ ($M!$ denotes the [factorial](https://en.wikipedia.org/wiki/Factorial) of $M$). - Then, for each element in array $B$, calculate $F(B_i)$, where $F(x)$ represents the number of divisors of $x$. Since these values can be large, output each $F(B_i) \bmod (1e9+7)$. - Output $N$ space-separated integers representing $F(B_i) \bmod (1e9+7)$. ### Constraints - $1 \leq N \leq 1e5$ - $1 \leq M \leq 100$ - $1 \leq A_i \leq 1e5$ --- What's the first thing that comes to your mind after reading the problem stat...
// prime factorization of A[i] for (ll j = 2; j * j <= v[i]; j++) { ll ct = 0

Full text and comments »

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

34.
By LMydd0225, history, 2 years ago, In English
Codeforces Round 969 (Div. 1, Div. 2) Editorial [problem:2007A] <spoiler summary="Hint 1"> How many odd integers are there in a pair $(a, b, c)$? <spoiler summary="Answer"> At least 2. </spoiler> </spoiler> <spoiler summary="Hint 2"> It's always better to put **exactly $2$** odd integers and **exactly $1$** even integer in one pair of $(a, b, c)$. Is there a way to always choose optimal $(a, b, c)$? </spoiler> <spoiler summary="Hint 3"> Try consecutive integers. </spoiler> <spoiler summary="Tutorial"> [tutorial:2007A] </spoiler> <spoiler summary="Implementation"> ```py T = int(input()) for _ in range(T) : l, r = map(int, input().split()) print(((r + 1) // 2 - l // 2) // 2) ``` </spoiler> [problem:2007B] <spoiler summary="Hint"> Consider the position of the maximum value in one array. If there's multiple maximum values, choose any. What can you observe? <spoiler summary="Answer"> The position of the maximum value never changes. That is, if one element is the maximum value...
; std::pmr::vectortnc{&pool},tmc{&pool}; tmc.emplace_back(a[0].size()); int ct =0; for, }; tmc.emplace_back(a[0].size()); int ct=0; for(int x=0;x

Full text and comments »

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

35.
By Abra, 16 years ago, translation, In English
Codeforces Beta Round #34 (Div. 2) Разбор Привет, мир! Это мой первый разбор, просьба сильно не пинать. =)<div><div><span class="Apple-style-span" style="font-family: arial; font-size: 21px; line-height: 21px; ">A. Разведка 2</span></div></div><div>Нахождение минимума в массиве, с одим дополнительным сравнением первого и последнего элементов.</div><div><span class="Apple-style-span" style="font-family: arial; font-size: 21px; line-height: 21px; ">B. Распродажа</span><br></div><div>Отрицательные элементы складываем в массив, сортируем, находим сумму m наибольших по модулю.</div><div><span class="Apple-style-span" style="font-family: arial; font-size: 21px; line-height: 21px; ">C. Список</span><br></div><div><span class="Apple-style-span" style="font-family: arial; font-size: 21px; line-height: 21px; "><span class="Apple-style-span" style="font-family: 'Times New Roman'; line-height: normal; font-size: medium; ">Решается массивом булей, единственная заковыка - с выводом, но вполне преодолима.</span><br></span></div><div><span cl...
: 21px; line-height: 21px; ">E. СтолкновенияЗаведем переменную времени ct, которая, Заведем переменную времени ct, которая вначале равна 0., Повторять, пока ct не сравняется с t., Пусть dt равен t - ct, просматриваем все пары шариков, по формуле

Full text and comments »

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

36.
By gaurav172, history, 7 years ago, In English
Codecraft-20 (Div.2) Editorial ### [problem:1316A] **Author:** [user:gaurav172,2020-03-04] **Development:** [user:gaurav172,2020-03-04], [user:ishita_3110,2020-03-04], [user:night_fury208,2020-03-04] <spoiler summary="Tutorial"> [tutorial:1316A] </spoiler> <spoiler summary="Solution"> ~~~~~ #include <bits/stdc++.h> using namespace std; #define ll long long int int main() { ll test; cin>>test; while(test--) { ll n,m; cin>>n>>m; ll s=0; for(ll i=1;i<=n;i++) { ll x; cin>>x; s=s+x; } cout<<min(s,m)<<"\n"; } return 0; } ~~~~~ </spoiler> ###[problem:1316B] **Author:** [user:preet_t,2020-03-04] **Development:** [user:preet_t,2020-03-04], [user:shaanknight,2020-03-04], [user:night_fury208,2020-03-04] <spoiler summary="Tutorial"> [tutorial:1316B] </spoiler> <spoiler summary="Solution"> ~~~~~ #include <bits/stdc++.h> using namespace std; string modified(string& s, int n, int k) { string result_prefix = s.substr(k - 1, n - k ...
++) { ll ct=0; for(ll j=0;jct++; ll z=(i-1)-ct; if(z, <(1<ct=0; for(ll j=0;jct++; ll

Full text and comments »

Tutorial of CodeCraft-20 (Div. 2)
  • Vote: I like it
  • +141
  • Vote: I do not like it

37.
By aymanrs, 4 years ago, In English
[Tutorial] Cartesian tree on arbitrary graphs If you're not familiar with cartesian trees on arrays I recommend to read this [blog](https://codeforces.me/blog/entry/112664). Assume the graph is simple and connected and every node $v$ has a value $a_v$.The way we construct a cartesian tree on a graph is kinda similar to the construction of a centroid tree, here's how it works: Find any node with maximum value let's call it $u$, it'll be the root of the tree. Removing $u$ and its edges leaves us with several (possibly only 0) connected components, for each of those components, construct a cartesian tree and add edges from $u$ to the roots of the cartesian trees. Here's an example: ![ ](/predownloaded/73/d9/73d9999e6c516ef37e81c45d4e80d13975b7c535.png) <br> On the left, the graph, where vertices are labeled $v,a_v$ and on the right, one of the corresponding cartesian trees where vertices are labeled by their index. How to optimize the construction: --------------------------------- If you naively apply the algorithm describe...
cartesian tree (which I will refer to as CT from now on) can be very deep. Thankfully we can construct it in

Full text and comments »

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

38.
By Jelly.bean, 7 months ago, In English
AlgoThugs 2026 — Editorial ### Contest announcement blog: [Link](https://codeforces.me/blog/entry/152857) ### [problem:669000A] Author: [user:Krishnadev44,2026-04-15] <spoiler summary="Hint 1"> We claim that the answer is always `YES`. </spoiler> <spoiler summary="Hint 2"> Let the direct path from vertex $u$ to vertex $v$ consist of $d$ edges. Since $u$ and $v$ are distinct, $d \ge 1$. Let the sequence of costs along these edges be $C = (c_1, c_2, \dots, c_d)$. We claim that there always exists a contiguous subarray of $C$ whose sum is perfectly divisible by $d$. </spoiler> <spoiler summary="Solution"> Let $S$ denote the prefix sum array of $C$, where the $k$-th prefix sum is defined as: $$S_k = \sum_{i=1}^{k} c_i \quad \text{for } 1 \le k \le d$$ Consider the values of these prefix sums modulo $d$. There are two cases: * Case $1$: There exists an index $k$ such that $S_k \equiv 0 \pmod d$. In this case, the sum of the prefix subarray $(c_1, c_2, \dots, c_k)$ is directly divisi...
); map, int> ct; for (int i = 0; i < n - 1; i++) { int a, b, c; cin, for (int i = 0; i < l - 1; i++) { cost[i] = ct[{path[i], path[i + 1]}] % (l - 1); if

Full text and comments »

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

39.
By Ecrade_, 20 months ago, In English
Codeforces Round 1010 (Div. 1, Div. 2, based on Zhili Cup 2025) Editorial Sorry for the late editorial. Our problem setters were so exhausted with the offline competition yesterday that they really need some good rest. Despite the unexpected and unpleasant incidents that occurred, we are truly surprised and grateful that so many of you still participated in this competition! We sincerely hope you enjoyed it! (Gratitude for all you guys from [user:Ecrade_,2025-03-16]: I felt so heartbroken when I heard about the unexpected issues, but seeing so many people in the comments comforting us, sharing thoughtful and positive messages that showed genuine empathy, and continuing to fully support our competition even after the wasted time, I was deeply moved. Thank you all! Codeforces truly embodies such a positive and uplifting community spirit!) [problem:2082A] <br> Idea: [user:Ecrade_,2025-03-16] <spoiler summary="Hint"> Do we really have to consider the problem on the whole matrix? </spoiler> <spoiler summary="Solution"> Let $r$ be the num...
ll; const int p=998244353; int T,n,m,fa[5005],col[5005],d[5005],stk[5005],top, ct[5005][2]; int C

Full text and comments »

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

40.
By usernameson, history, 10 years ago, In English
Bitmasks and Counting Problems #### Introduction Generally bitmasking is used to solve optimisation problems with the following procedure. Store all possible states then pick the best one. Doing this cleverly can sometimes reduce a brute force approach that takes $O(N!)$ to something that takes $O(2^{N})$. However, if you apply the standard bitmasking approach to counting problems you can run into issues. #### A Simple Case Let's consider a simple case where we have three balls, two are red and one is blue and there are two problems. For the first problem we have a function $f$ that takes balls and spits out a value and we want to optimise $f$. For the second problem we want to count the number of selections of balls we can make where the order of the selection does not matter and the two red balls are indistinguishable. Bitmasking in the usual way works perfectly fine for the first problem. However if we encode each of the balls with its own bit and try to solve the second problem we will get an answer that is...
; int ct=vi[i]; while(ct>=1<, =0; for(int i=0; ict=charCt[pos[i]]; if(i, comp=comp&m; tot+=comp; if(comp>ct) return, int tot=0; for(int i=0; ict=charCt[pos[i

Full text and comments »

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

41.
By garakchy, 13 years ago, In English
rng_58's hardest problem [user:rng_58,2014-03-04]'s blog The hardest problem I've ever seen ================================== By [user:rng_58,2014-03-04], 8 days ago, In English. Hello. Today I want to tell you about the hardest problem I've ever seen. I found the problem four years ago when I entered a university. The problem was used in Japanese Domestic Contest of ICPC. When I checked previous year's problemset before my first domestic contest, I found one problem that looked very scary: [statement.](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1164) I doubted my eyes. What does it say? Tighten Up??? Does it really ask us to tighten up a string on a computer??? Can you come up with a solution that works in finite time? The problem looks extremely scary even if we ignore the time limit. This problem was used in a 3-hour contest. You don't have time to go to "Tokyu Hands" (a famous Japanese shop that sells various kind of things) and buy strings and pins to simulate it manually! (I'v...
://webcache.googleusercontent.com/search?q=cache:Jl82J-CskWAJ:codeforces.com/blog/entry/10810+&cd=1&hl=en& ct

Full text and comments »

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

42.
By I_love_Hoang_Yen, 12 years ago, In English
[GYM] 2014-2015 CT S02E11 — Editorial [problem:100540A] Let's restate the problem statement: - You need to maintain a set of alive soldiers. - You are asked to perform some queries [L, R]: remove all soldiers with index in range [L, R]. And then find the soldier with maximum index which is still less than L, and the soldier with minimum index which is still greater than R. The most simple way to implement this is to use C++ set. For each query: - Find one soldier whose index is in range [L, R]. - Remove that soldier - Repeat until there is no soldier in range [L, R]. This implementation runs in $O(N*logN)$, because: - For each soldier, he is only removed once from the set. - For each query, if we remove k soldiers, we need to do binary search (lower_bound) on the set k+1 times. So the total number of times we binary search is at most $N + Q$. [Code](http://ideone.com/2aWywr) [problem:100540B] Consider the figure in the problem statement. In here we have 4 columns: - Column 1: 3, -5, -8, 3 ...
[GYM] 2014-2015 CT S02E11 — Editorial

Full text and comments »

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

43.
By harshith_04, 17 months ago, In English
Codeforces Round 1033 (Div. 2) and CodeNite 2025 Editorial Thanks for participating in our CodeNite 2025. ####[2120A &mdash; Square of Rectangles](https://codeforces.me/contest/2120/problem/A) Idea: [user:aryansanghi,2025-06-11] Solution: [user:aryansanghi,2025-06-11] Prepared by: [user:aryansanghi,2025-06-11] <spoiler summary="Hint"> There are only two possible ways to arrange rectangles into a square if possible. </spoiler> <spoiler summary="Solution"> The only cases possible to arrange rectangles into a square are: 1. All three rectangles are put side by side, i.e. $l_1=l_2=l_3=b_1+b_2+b_3$ or $b_1=b_2=b_3=l_1+l_2+l_3$. 2. Rectangles $2$ and $3$ are side by side with rectangle $1$ above it, i.e. $l_1+l_2=l_1+l_3=b_1=b_2+b_3$ or $b_1+b_2=b_1+b_3=l_1=l_2+l_3$. Check both these cases, and if either is true, output YES, otherwise NO. Complexity is $O(1)$ per test. </spoiler> <spoiler summary="Code - aryansanghi"> ~~~~ //Written By Aryan Sanghi #include<bits/stdc++.h> using namespace std; #define ll long...
i64 ct = ans.size(); for(i64 i = 0; i < n - ct; ++i) ans.push_back(1);, nsum += (n - ct);

Full text and comments »

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

44.
By usernameson, history, 10 years ago, In English
Max Flow Implementation #### Overview In this post I will explain with an example one way to code the Edmonds Karp max flow algorithm to solve a problem. #### The Problem The problem we study is Array and Operations http://codeforces.me/problemset/problem/498/C. The basic idea is you have a sequence of numbers and a bunch of special pairs taken from the sequence. For any of the pairs you can divide each number by a common factor greater than 1 and replace the elements in the pair with the result of this division. The question asks what is the maximum number of times you can do this. #### Converting this to a max flow problem This section is specific to the problem. You can skip it if you just want to know how to implement Edmonds Karp on a given flow network. Before we convert this problem to a max flow problem we make some observations. First if we have a pair of numbers the maximum amount of times we can perform the operation described on this pair is equal to the number of prime divisors the p...
(!(cur%ps[i])){ cur=cur/ps[i]; found=true; ct, ) return 0; int ct=0;, for(int i=1; i<=n; i++){ int ct=0; long long cur=sequence[i]; for(int j

Full text and comments »

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

45.
By samudra_mitra, history, 3 years ago, In English
CSES Graph Algorithms solution Hello Codeforces, this is my first blog and here I have given my solution of the complete CSES Graph Algorithms section. [This](https://github.com/SamudraMitra/cses) is the github repo where I have pushed all the cpp files: Counting Rooms ------------------ <spoiler summary="Thinking"> used simple bfs in a grid </spoiler> <spoiler summary="Code"> ~~~~~ #include <bits/stdc++.h> using namespace std; typedef long long ll; ll dx[] = {1, 0, -1, 0}; ll dy[] = {0, 1, 0, -1}; bool inrange(ll x, ll y, ll n, ll m) { if (((0 <= x) && (x < n)) && ((0 <= y) && (y < m))) return true; return false; } int main() { ll n, m; cin >> n >> m; vector<string> v(n); vector<vector<ll>> vis(n, vector<ll>(m)); for (auto &i : v) { cin >> i; } ll cnt = 0; queue<pair<ll, ll>> q; for (ll i = 0; i < n; i++) { for (ll j = 0; j < m; j++) { if (v[i][j] == '#') co...
(100001, 0); vector team(100001, 0); bool dfs(ll node, ll ct) { vis[node] = 1; team

Full text and comments »

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

46.
By I_love_Hoang_Yen, 12 years ago, In English
[GYM] 2014-2015 CT S02E06 — Solution [problem:100506A] For this problem, you need to calculate: $sum(distance(u, v)) / (some_constant)$ How to calculte $sum(distance(u, v))$ efficiently? Obviously, you cannot iterate through all pair of vertices u and v. That would take at least $O(N^2)$. When calculating the sum, notice that you need to add one edge multiple times. There are only N edges, but for each edge, in naive solution, you added it multiple times. So now you can see an idea for optimizing the naive solution: For each edge, count how many times it appear in $sum(distance(u, v))$ and add it to result. Turns out this is quite simple: For edge $(u, v)$ where u is parent of v in the tree, the path going through it must have the form: "something --> u --> v --> something". The number of such path is $size(subtree(v)) * (n - subtree(v))$. [My code](http://ideone.com/DLQFOJ) [cut] [problem:100506B] Let's call the vertices which at least one bus trip go through "important vertices". It is easy to...
[GYM] 2014-2015 CT S02E06 — Solution

Full text and comments »

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

47.
By I_love_Hoang_Yen, 12 years ago, In English
[GYM] 2014-2015 CT S02E10 — Solution [problem:100534A] This problem is the easiest amongst the problems. Since you need to choose different polygon types, the optimal way (meaning you would spend minimum amount of coins) is choosing polygon with sizes $3, 4, 5, 6, ...$ in this increasing order. [Code](http://ideone.com/X4Jlxz) [cut] [problem:100534B] Since the length of the string is at most 1000, you can loop through all generated code. This can be done by looping through the first and second index of the code. How to check if two code are equal? One way to do this is to use polynomial hash. For each code, you need to calculate its hash value, which can be done by using simple DP: Let $Hash(i, j)$ be polynomial hash of string starts at indices i and j, then: $Hash(i, j) = s(i) + Hash(j, i+j) * BASE$ After calculating all the hashes, you only need to count how many different hashes are there. [Code](http://ideone.com/5EBfLI) [problem:100534C] Let f(a, b) = the length of the shortest pat...
[GYM] 2014-2015 CT S02E10 — Solution

Full text and comments »

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

48.
By CutieSmileHaruka, history, 7 months ago, In English
Spectral::Cup 2026 Round 1 (Codeforces Round 1094, Div. 1 + Div. 2) Editorial We hope you enjoyed these problems! [problem:2222A] Author: [user:Lyz09,2026-04-26] <spoiler summary="Hint 1"> Consider the case where $k=1$. </spoiler> <spoiler summary="Tutorial"> [tutorial:2222A] </spoiler> <spoiler summary="Implementation"> ~~~~~ #include<iostream> using namespace std; int t,n; int main() { cin>>t; while(t--) { cin>>n; bool ans=false; for(int i=1;i<=n;i++) { int x; cin>>x; if(x==100) ans=true; } if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl; } } ~~~~~ </spoiler> [problem:2222B] Author: [user:lizhous,2026-04-26] <spoiler summary="Hint 1"> Consider for a given $p$, which elements can be placed at $p$ with one reversal operation. </spoiler> <spoiler summary="Tutorial"> [tutorial:2222B] </spoiler> <spoiler summary="Implementation"> ~~~~~ #include<iostream> #include<cstdio> #include<algorithm> #include<queue> #define int long long using namespace std; int n,...
], bb[N], ps[M][N], sk[N], tmp[N], sm[M], ct[M], dep[M]; void dfs(int p, int sm){ if (p > n){m, ], sm[M], ct[M], dep[M]; void dfs(int p, int sm){ if (p > n){m ++; memcpy(ps[m], sk, sizeof(sk

Full text and comments »

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

49.
By bsdsdb, 16 months ago, In English
Are macros difficult to debug That was the way I used to build a centroid tree (a tree that connects all the adjacent centroids during centroid decomposition, used in [problem:342E]): <spoiler summary="That"> ```cpp ll n, ctroot, ctp[MAXN]; vector<ll> e[MAXN], ct[MAXN]; namespace centree { ll sz[MAXN], mxs[MAXN]; bool vis[MAXN]; void clear(ll x, ll pr) { sz[x] = mxs[x] = 0, mxs[0] = inf; for (ll i : e[x]) { if (i == pr || vis[i]) { continue; } clear(i, x); } } void setsz(ll x, ll pr) { sz[x] = 1; for (ll i : e[x]) { if (i == pr || vis[i]) { continue; } setsz(i, x); sz[x] += sz[i]; mxs[x] = max(mxs[x], sz[i]); } } void fndct(ll x, ll pr, ll crt, ll &ret) { mxs[x] = max(mxs[x], sz[crt] - sz[x]); if (mxs[ret] > mxs[x]) { ret = x; } for (ll i : e[x]) { if (i == pr || vis[i]) { continue; } fndct(i, x, crt, ret); } } void bdct(ll x, ll pr) { ll cur = 0; clear(x, pr), setsz(x, pr), fndct(x, pr, x,...
```cpp ll n, ctroot, ctp[MAXN]; vector e[MAXN], ct[MAXN, , ctroot, ctp[MAXN]; vector e[MAXN], ct[MAXN]; namespace centree { ll sz[MAXN], mxs[MAXN

Full text and comments »

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

50.
By Knight_master, 6 months ago, In English
C2 Seating Arrangement (Hard) — O(n) Greedy with Floating Ambiverts [Codeforces Round 1101 Div. 2] Introduction ================ The editorial for this problem offers two approaches: a min/max table range tracker and a binary-search-over-ambiverts solution. This blog presents a third, independently derived O(n) greedy that feels more intuitive — at least to me. The central idea is tracking floating ambiverts: ambiverts who sat down in an already-occupied table but haven't been committed to a specific role yet, and can retroactively "become" introverts to rescue a future extrovert. Key observation =============== An extrovert needs a non-empty table. An introvert needs a completely empty table. An ambivert can do either. The tricky part is the order of decisions: we can't look ahead, so we must make lazy commitments. Core insight ============ When an ambivert sits at an already-occupied table (acting like an extrovert), we don't need to commit them yet. If a later extrovert arrives with no free seat, we can retroactively declare one of those ambiverts an introvert — openi...
seats across all occupied tables (i.e. tables with ≥ 1 person seated). **ct** -> Count of "floating, with ≥ 1 person seated). **ct** -> Count of "floating" ambiverts — ambiverts currently occupying, **Order of redemption doesn't matter.** We only track the count ct, not which specific ambivert is, --. - If rem == 0 but ct > 0 and unoccupied > 0: redeem a floating ambivert as an introvert. That, 0 E rem=0, ct=0 → kick out 2 0 0 1 1 I, : ct++. - If rem == 0 and unoccupied > 0: treat as introvert — open a new table. unoccupied--, rem, =2, rem=0, ct=0, ans=0. i char action unocc. rem ct ans

Full text and comments »

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

51.
By amrSamir, 13 years ago, In English
2013-2014 CT S01E010: Codeforces Trainings Season 1 Episode 10 <img src="http://a400.idata.over-blog.com/300x300/1/42/93/74/columbo/bakkar02.jpg" style="float:right;margin:0.25em 1em;"/> Hello from Egypt! Welcome to 2013-2014 CT S01E010: Codeforces Trainings Season 1 Episode 10. The training duration is 5 hours, to be held on [Wednesday, 13th of November, 16:10](http://timeanddate.com/worldclock/fixedtime.html?day=13&month=11&year=2013&hour=16&min=10&sec=0&p1=166). It is opened for teams as well as for individual participants. After the end you may use the practice mode to complete problem solving. Also it will be available as a virtual contest for whose of you who can't take part today. Please, do not cheat. Only fair play! It is possible that the problems will be too easy for some participants, it is possible that we will add some problems. The [registration](http://codeforces.me/gymRegistration/100283) will be available on the [Gym page](http://codeforces.me/gyms) and will be opened until the end of the training. Be careful register...
2013-2014 CT S01E010: Codeforces Trainings Season 1 Episode 10, ="float:right;margin:0.25em 1em;"/> Hello from Egypt! Welcome to 2013-2014 CT S01E010: Codeforces Trainings

Full text and comments »

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

52.
By NahC0el, 19 months ago, In English
Codeforces Round 1023 (Div 2) Editorial Hope you enjoyed the round! [problem:2107A] <spoiler summary = "Solution"> When all the elements of the array are equal, the solution is trivially impossible since the $\gcd$ of any subset will always be equal to $a_1$. That is infact the only $\texttt{No}$ case. We show a construction otherwise. Let $\operatorname{mx} = \max(a)$. Put all the elements equal to $\operatorname{mx}$ in one set, and all the other elements in the other set. Then, the $\gcd$ of the first set is $\operatorname{mx}$ while the other set will have a strictly smaller $\gcd$ (because $\gcd(a, b) \le \min(a, b)$) Time complexity is $O(n)$. </spoiler> <spoiler summary = "Code"> ```cpp #include <bits/stdc++.h> using namespace std; int main(){ int t; cin >> t; while (t--){ int n; cin >> n; vector <int> a(n); for (int i = 0; i < n; i++){ cin >> a[i]; } int mn = *min_element(a.begin(), a.end()); int mx = *max_el...
,int>; using ti = tuple; int T,n,u,v,del[N],fa[N],ct; vector g[N]; set t

Full text and comments »

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

53.
By MikaMisono, history, 6 months ago, In English
Recheck Kylume's Code!!! Hi Mike, I’m appealing the situation where Kylume’s contest result was skipped and unrated. We’re confused by this judgment and ask for detailed violation explanations. Kylume receives professional algorithm training in Macau and has solid contest skills. He even got 1st place in MOIC2026 and qualified for the Macau IOI team. with his real strength, which fully proves his ability. Please note that his low rating is totally misleading. He rarely participates in these competitions so his low rating isn't a sign of cheating. After the competition, he showed me the code, and I think there are no problems. ```cpp #include<bits/stdc++.h> #define int long long #define double long double using namespace std; int T,n,a[110]; signed main(){ ios::sync_with_stdio(false); cin.tie(0),cout.tie(0); cin>>T; while(T--){ cin>>n; unordered_map<int,int> mp,vis; int cnt=1e18; for(int i=1;i<=n;i++) cin>>a[i],mp[a[i]]++; sort(a+1,a+1+n); for(int i=1;i<=n;i++){ i...
; }; struct res{ int w,ct,e; }; vector a; vector t; vector cnt; int build(int l,int, { int w,ct,e; }; vector a; vector t; vector cnt; int build(int l,int r,int pl

Full text and comments »

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

54.
By EndlessDreams, 4 years ago, In English
TheForces Rounds Editorials Here's the editorials of [TheForces Rounds](https://t.me/TheForcesOfficial): <spoiler summary="Round 1"> <spoiler summary="Problem A"> For a number $x$, as long as $2\le x$, it can be squared to any large number. For $0$ and $1$, the square of both numbers is equal to themselves. So just compare $0$ and $1$. <spoiler summary="Code"> ~~~ void elysia() { cin >> n; bool flag=true; for(int i=1;i<=n;++i) { cin >> a[i]; a[i]=min(a[i],2ll); if(i!=1&&a[i]<a[i-1]) flag=false; } if(flag) cout << "YES" << endl; else cout << "NO" << endl; } ~~~ </spoiler> </spoiler> <spoiler summary="Problem B"> Consider the number of times each $a_i$ is XOR in the answer. for $a_i$, calculated $i(n-i+1)$ times in the answer. Two same XOR will disappear, so checking is this an odd number then done. <spoiler summary="Code"> ~~~ void elysia() { int answer=0; cin >> n; for(int i=1;i<=n;++i) { cin >> a[i]; ...
&ct){sz[x]=1;we[x]=0;for(int i:tree[x])if(i!=f){gc_dfs(i,x,sz,we,ct );sz[x]+=sz[i];we[x]=max(we[x

Full text and comments »

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

55.
By vedang12d, history, 4 years ago, In English
Distributing fruits | CodeHive Contest | 8th Question ### **Links:** [Contest](https://www.hackerrank.com/contests/codehive/)<br> [Problem](https://www.hackerrank.com/contests/codehive/challenges/distributing-fruits/) **Author, Tester and Editorialist**: [Vedang Dadape](https://www.linkedin.com/in/vedang-dadape/) ### **Difficulty:** Hard ### **Prerequisites:** - [Legendre's Formula](https://en.wikipedia.org/wiki/Legendre%27s_formula/) - Prime Factorization - Exponents ### **Problem:** The [Yovo fruit](https://james-camerons-avatar.fandom.com/wiki/Yovo_Fruit/) grows on the [Home Tree](https://james-camerons-avatar.fandom.com/wiki/Hometree/) in Pandora. Every day, the number of Yovo fruits gets multiplied by the age of the Home Tree(in days). _Ex_: If $Y_{n}$ denotes the number of Yovo fruits on the $n_{th}$ day, then $Y_{n} = Y_{n-1} * n.$ It is a fact that the Home Tree had 1 fruit on its first day. You want to distribute these Yovo fruits with entire [Na'vi](https://james-camerons-avatar.fandom.com/wiki/Na%27v...
) { ll res = LLONG_MAX; ll ct = 0; if (k % 2 == 0) { while (k % 2 == 0, ll largestPowerOfCompositeInFactorial(ll n, ll k) { ll res = LLONG_MAX; ll ct = 0

Full text and comments »

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

56.
By DR.MANHATTAN, 9 years ago, In English
Codeforces Round #430 (Div. 2) My 9th contest . **Highlight**: Successfully did Problem &mdash; B, but failed to do Problem &mdash; A( Awkward !! ) I remember the first time I'd been to an onsite contest ( almost 1 year ago ), the drive to solve the questions the fastest was so high that my brain and my hands literally got paralyzed and I was unable to do anything after attempting the First Question. Thanks to my team mate, we still managed to get the 3rd place and a Cash prize with it ( sweet !! ). What's sad, is that I did not lack in knowledge or skill to solve all the problems in time ( It was not a hard contest ) and could have easily managed to get the first prize and some SERIOUS BOUNTY !! However, winning the 3rd prize too got me enough bounty to buy this beauty for myself !! ![ ](/predownloaded/97/7b/977b111450cf126de957058313f772df2e624aef.jpg) Since then, thanks to [user:petr,2017-08-31] and his YouTube contest Video's[ Petr's competitive programming video with commentary ](https://www.youtube.com/watch?v=N...
; cin>>r>>d; int ct=0; test(t){ double x,y,r_s; cin>>x>>y>>r_s, cout<<ct; } ~~~~~, if(length(x,y,r_s,r,d))ct++; }, int r,d; cin>>r>>d; int ct=0; test(t){

Full text and comments »

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

57.
By sapta0506, 5 years ago, In English
SPC Round #003 Editorial <p></p> Link to contest : [SPC Round #003](https://codeforces.me/contestInvitation/205bc917cbe2a2aadff6424228fcc04b027cb683) <p></p> ### [A. SPC Gifts](https://codeforces.me/group/xK9ngmaNEM/contest/337838/problem/A) Problem Author : [user:sapta0506,2021-07-25] <spoiler summary="Tutorial"> [tutorial: 337838A] </spoiler> <spoiler summary="Solution Code"> ~~~~~ #include<bits/stdc++.h> using namespace std; #define int long long #define rep(i,a,b) for(int i=a; i<b; ++i) #define all(x) x.begin(),x.end() #define mp make_pair const long long INF=1e18; const int32_t M=1e9+7; const int32_t MM=998244353; const int32_t N = 1e6+1; void solve() { int a,b,k; cin >> a >> b >> k; cout << min(a,b)/k << endl; } int32_t main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int t; cin >> t; while (t--) solve(); return 0; } ~~~~~ </spoiler> <p></p> ### [B. Void Knight](https://codeforces.me/g...
int N = n+2*k; int ct = nCr(N, k); //Total number of ways int ca = nCr(N, k-1

Full text and comments »

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

58.
By heavylightdecomp, history, 4 years ago, In English
Alternative Nlog^2(N) solution to IPSC 2015 G — Generating Synergy using 1D Segment Tree Hello Codeforces, Recently I was solving some more problems and came across [IPSC 2015 G, Generating Synergy](https://ipsc.ksp.sk/2015/real/problems/g.html). I think the problem and my alternative solution are pretty cool. TLDR: Store decreasing `maxdepth` monostack in each segtree node, for query, binary search $log N$ monostacks and get maximum update. <spoiler summary="Code"> ```cpp #include<bits/stdc++.h> using namespace std; using ll = long long; const int maxn = 1e6+5; const ll mod = 1e9+7; int uc[maxn], ul[maxn], N, C, Q, tin[maxn], tout[maxn], lv[maxn], rv[maxn], ct, cl; vector<int> tr[maxn], st[4 * maxn]; void upd(int l, int r, int q, int x = 1, int tl = 1, int tr = N) { if(l > r) return; if(tl == l and tr == r) { //if earler update has lower maxdepth, //it will be completely overwritten by current update //so no need to store it anymore while(st[x].size() and ul[st[x].back()] <= ul[q]) { st[x].pop_back(); } st[x].push_back(q); r...
; const ll mod = 1e9+7; int uc[maxn], ul[maxn], N, C, Q, tin[maxn], tout[maxn], lv[maxn], rv[maxn],ct, ], tout[maxn], lv[maxn], rv[maxn], ct, cl; vector tr[maxn], st[4 * maxn]; void upd(int l, int r

Full text and comments »

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

59.
By Nickolas, 15 years ago, translation, In English
TCO 2011 глазами блоггера, ч.2 <a href="http://codeforces.me/blog/entry/2788">Часть 1</a> <br /><br /> Мое дальнейшее повествование несколько утратит стройность и последовательность изложения, свойственную первой части. В основном потому, что о самих раундах достаточно много написано в официальном блоге, да и не за всеми из них я следила от начала и до конца, все время отвлекаясь на что-нибудь интересное. Так что здесь я постараюсь рассказать только о том самом &quot;интересном&quot;, что происходило между раундами, после, а иногда и вместо них :-) <br /><br /> <i>Заранее прошу прощения за ухудшившийся стиль изложения; у нас внезапно похолодало, и события, происходящие в +30 на берегу океана, кажутся совершеннейшей фантастикой, и писать о них становится сложнее.</i> <br /><br /> В конце июля в Студии проводился <a href="http://studio.topcoder.com/?module=ViewContestDetails&amp;ct=30022930">контест</a> на лучшую идею того, чем можно развлекать людей на онсайте. Через чудовищно неудачный интерфейс голосования (интерес...
;ct=30022930">контест на лучшую идею того, чем можно развлекать людей на онсайте. Через, =ViewContestDetails&ct=30022930">contest to get some ideas of how to entertain people at the onsites. The

Full text and comments »

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

60.
By xgf, history, 3 years ago, In English
Need help in CodeTON Round 6 (Div. 1 + Div. 2, Rated, Prizes!) G. MEXanization In my code,I have set a limit on the number of iterations but it still Time limit exceeded. Can anyone tell me how to find the next faster or explain that my code complexity is incorrect. ```cpp #include <bits/stdc++.h> //#define int long long #define pb push_back using namespace std; const int M=(int)(2e5),N=(int)(2e5+5); #define ls ((cur)<<1) #define rs ((ls)|1) int n,a[N],mi[N<<2],sum[N],MX,ct0,ct[N]; inline void upt(int x,int v) { ct[x]+=v; while(x<=MX) sum[x]+=v,x+=(x&(-x)); } inline int qry(int x) { int res=0; while(x) res+=sum[x],x-=(x&(-x)); return res; } void push_up(int cur) { mi[cur]=min(mi[ls],mi[rs]); } void upt_add(int cur,int l,int r,int pos,int v) { if(l==r) { mi[cur]+=v; upt(l,v); return ; } int mid=(l+r)>>1; if(pos<=mid) upt_add(ls,l,mid,pos,v); else upt_add(rs,mid+1,r,pos,v); push_up(cur); } int qry_nex(int cur,int l,int r,int cl,int cr,int v) { if(mi[cur]>=v) return -1; if(l==r) return l; int mid=(l...
#define ls ((cur)<<1) #define rs ((ls)|1) int n,a[N],mi[N<<2],sum[N],MX,ct0,ct [N];, '; memset(mi,0,sizeof(int)*(4*n+1)); memset(sum,0,sizeof(int)*(n+1)); memset(ct ,0,sizeof(int)*(n, -pos)*need; } need+=need-(ct[pos]); if(need>re) { return 0; } nw=pos-1; } bool, <<2],sum[N],MX,ct0,ct[N]; inline void upt(int x,int v) { ct[x]+=v; while(x<=MX) sum[x]+=v,x, inline void upt(int x,int v) { ct[x]+=v; while(x<=MX) sum[x]+=v,x+=(x&(-x)); }

Full text and comments »

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

61.
By Milkcat2009, history, 5 months ago, In English
Codeforces Round 1105 (Div. 1, Div. 2) Editorial Thanks everybody for participating in the round! ### [Div2A. Another Popcount Problem](https://codeforces.me/contest/2240/problem/A) Author: [user:wangmarui,2026-06-27] Preparation: [user:wangmarui,2026-06-27] <spoiler summary="Hint 1"> Consider each binary bit independently. </spoiler> <spoiler summary="Hint 2"> Think about a greedy approach. </spoiler> <spoiler summary="Solution"> [tutorial:2240A] </spoiler> <spoiler summary="Code (by wangmarui)"> ~~~~~ /* author: Yuneko time: 2026/5/5 contest: Tips: RE, MLE? greedy, dp? natural time? map, umap? giveup rating, get score. brute force, right solution? %mod? std/run/maker/checker? add bruteforce? clear? double, long double? O(n)? O(n^2)! make data! last but not least. bruteforce -> SegTree? Think more. */ //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #include<bits/st...
]; int ct; inline void add_edge(cint u,cint v) { ve[++ct]={v,head[u]}; head[u]= ct; ve

Full text and comments »

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

62.
By Learner99, 7 years ago, In English
Gym Contest with Editorial While giving team contest we try to find Gym contest which has editorial available, but it takes plenty of time for finding such contests. ( We can add a gym contest to a personal group and look at others submission but still, editorials are more effective) So I thought of making a list of Gym Contest which has editorials available. Can you help me make a list of such contests? Thanks in advance. Happy Coding :) ---------------------------------------------------------------------------------- Contest List: 1. [Hello 2015 Div. 1](https://codeforces.me/gym/100570) 1. [2017 Bangladesh National High School Programming Contest](https://codeforces.me/gym/101353) 1. [2018 KAIST Run Spring Contest](https://codeforces.me/gym/101806) ( [Editorial](https://drive.google.com/file/d/1xzmcmlPLFd4FK5H0waZdg5zjrzRJs8Cf/view) ) 1. [BAPC 2013](https://codeforces.me/gym/100625) ( [E...
/gym/101341) 1. [2014-2015 CT S02E11: Codeforces Trainings Season 2 Episode 11](https, ](https://codeforces.me/gym/101341) 1. [2014-2015 CT S02E11: Codeforces Trainings Season 2 Episode 11

Full text and comments »

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

63.
By Sergiu, history, 11 years ago, In English
MindCoding 2016 ![Header](http://ieval.ro/~sergiu/mindcoding_header.jpg) Hello Codeforces! The third edition of [MindCoding](http://mindcoding.ro) is going to make its debut on [Thursday, the 4th of February, 19:00 EET](http://www.timeanddate.com/worldclock/fixedtime.html?msg=MindCoding+2016+Test+Round&iso=20160204T19&p1=2210&ah=1&am=30), with a [Test Round](https://mindcoding.ro/ct/mc2016testd1). I invite you all to participate and help us test the improvements in our platform on this occasion. There will be a total of 4 online qualification rounds, and one on-site final round. The final will take place in the city of [Cluj-Napoca, Romania](https://en.wikipedia.org/wiki/Cluj-Napoca), the same as last year. The format of the contest is similar to that of Codeforces and TopCoder, so the learning curve should be quite mild. A new feature for this year is the addition of a second division, for beginners. The rounds are organized by fellow Codeforces members: - Petru Trîmbițas ([user:Pet...
+2016+Test+Round&iso=20160204T19&p1=2210&ah=1&am=30), with a [Test Round](https://mindcoding.ro/ct

Full text and comments »

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

64.
By cold.coffee., history, 4 years ago, In English
Help me find bug in this please [Nurikabe puzzle validator] I've been trying to write a validator for Nurikabe puzzle. [Online Judge Link](https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2632) While I'm seeing a lot of my test cases passing, there's seem to be some issue with the code due to which some of the test cases are failing. I've tried playing around with the implementation (without a clue) but nothing seem to be working. Since I do not have access to the failing test cases, I'm hoping to get an input here. Could someone point out the mistake in the code or any corner cases I'm missing? ~~~~~ int r, c, n; int t, a, b, k, shade, unshade, full, x, y, ct, connect; vector<string> board; vector<pair<pair<int, int>, int>> in; int vis[105][105]; void dfs1(int x, int y, char c) { if (x < 0 || x >= r || y < 0 || y >= c || vis[x][y] == 1 || board[x][y] != c) return; vis[x][y] = 1; ct--; dfs1(x, y + 1, c); dfs1(x + 1, y, c); dfs1(...
missing? ~~~~~ int r, c, n; int t, a, b, k, shade, unshade, full, x, y, ct, connect; vector, bool check1(int x, int y) { ct = shade; dfs1(x, y, '#'); return ct == 0; }, bool check2() { for (auto v : in) { ct = v.se; dfs1(v.fi.fi, v.fi.se, vis[x][y] = 1; ct--;, ~~~~~ int r, c, n; int t, a, b, k, shade, unshade, full, x, y, ct, connect; vector board

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

65.
By maximus12793, history, 10 years ago, In English
python 2.7 too slow test 18 http://codeforces.me/contest/515/problem/D http://codeforces.me/contest/515/submission/21582967 Im getting a tle on test 18. Is there anything I can do to improve this vs rewriting in c++? I added the ct/z flags to make sure I save 1 extra loop in the case that I filled all tiles or produced no degree 1 edges. I implemented the same strategy as in their editorial but somehow it is too slow. (http://codeforces.me/blog/entry/16468) ideas? ~~~~~ from Queue import Queue def main(): q = Queue() n, m = map(int,raw_input().split()) grid = [list(raw_input()) for x in xrange(n)] z = True while z: ct=0 z = False for r in xrange(n): for c in xrange(m): if grid[r][c] == '*': ct+=1 if grid[r][c] == '.': deg = 0 up = left = right = down = False if c+1<m and grid[r][c+1] == '.': d...
the ct/z flags to make sure I save 1 extra loop in the case that I filled all tiles or produced no, ()) for x in xrange(n)] z = True while z: ct=0 z = False for r, if(q.qsize()+ct) >= n*m: z = True break

Full text and comments »

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

66.
By aajjbb, 13 years ago, In English
A* Optimization Hello, I'm trying to solve this problem [Link](http://br.spoj.com/problems/RAPREGUI/). The problem statement is available in [LiveArchive](https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=&problem=1653&mosmsg=Submission+received+with+ID+1253271) in English. In the Brazilian SPOJ, the time-limit is quite strict, as the problem resumes to a grid shortest path, I choose the A* algorithm, which generally is faster than Djikstra and it's heuristics fits perfectly in 2-dimensional grids, but my solution isn't fast enough. How can I optimize more the A* ? The current code is: ~~~~~ struct MyLess { bool operator () (int x, int y) { return f[x] > f[y]; } }; int func (void) { int i, j; dist[conv(RF,CF)] = 0; vis[conv(RF,CF)] = 0; priority_queue<int, vector<int>, MyLess> q; q.push(conv(RF, CF)); for ( ; !q.empty(); ) { int now = q.top(); q.pop(); if (vis[n...
[now]) { continue; } vis[now] = 1; if (now == conv(RT, CT, if (next >= 0 && next < R * C) { int next_cost = dist[now] + ct[i, if (now == conv(RT, CT)) return dist[now];, } } } return dist[conv(RT,CT)]; } ~~~~~

Full text and comments »

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

67.
By MikeMirzayanov, history, 10 years ago, translation, In English
2016-2017 CT S03E07: Codeforces Trainings Season 3 Episode 7 <img src="https://rlv.zcache.co.uk/worlds_0_programmer_mug-r155e45cf0b9c4e35ae909aa818013d22_x7jg9_8byvr_324.jpg" style="float:right;margin:0 1em 1em 1em;"/> Welcome to [contest:101138]. The training duration is 5 hours. It is opened for teams as well as for individual participants. After the end you may use the practice mode to complete problem solving. Also it will be available as a virtual contest for whose of you who can't take part today. Please, do not cheat. Only fair play! Many thanks to [user:Errichto,2016-10-25] for the preparation of the training. He has saved me! Visit <a href="http://codeforces.me/gyms">Codeforces::Gym</a> to find the contest and register. We are planning to start on <a href="http://timeanddate.com/worldclock/fixedtime.html?day=26&month=10&year=2016&hour=16&min=10&sec=0&p1=166">October, 26, 2016 13:10 (UTC)</a>. It is possible that the problems will be too easy for some participants, it is possible that we will add some problems. Good ...
2016-2017 CT S03E07: Codeforces Trainings Season 3 Episode 7

Full text and comments »

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

68.
By qwertsboy1234, history, 6 years ago, In English
Help needed in finding error in my code Here is a codechef problem [Friends](https://www.codechef.com/problems/RRFRNDS). Here is my solution ,its giving wrong answer.Can anybody help me find out the error. ~~~~~ #include<bits/stdc++.h> using namespace std; #define dd double #define ll long long int #define pb push_back #define mp make_pair #define fi first #define sc second #define pr pair<ll,ll> #define pri pair<pr,ll> #define pir pair<ll,pr> #define ppr pair<pr,pr> #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); ll INF=1e18; ll mod=1e9+7; int main() { #ifndef ONLINE_JUDGE freopen("inp.txt","r",stdin); freopen("otpt.txt","w",stdout); #endif fastio; ll te=1; while(te--) { ll n,i,j,t; cin>>n; vector<vector<char> > v1(n,vector<char>(n)); for(i=0;i<n;i++) { for(j=0;j<n;j++) { cin>>v1[i][j]; } } ll ans=0; queue<pr> q; for(i=0;i<n;i++) {...
last=q.size(); ll ct=0; while(1) { ct++; pr p=q.front, )); } } } q.push(mp(-1ll,-1ll)); ll last=q.size(); ll ct=0; while(1

Full text and comments »

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

69.
By sarthak11yadav, 6 years ago, In English
DIFFERENT ANSWERS FOR SAME CODE ON DIFFERENT IDES. This is related to todays contest Codeforces Round #679 (Div. 2, based on Technocup 2021 Elimination Round 1). I ran my code for problem B. A New Technique on codechef ide for the example input given in the question and it gave a correct output but when i ran the same code on codeforces it gave WRONG ANSWER on the same test case and I was unable to find where is the problem and as a result it really badly effected my todays standings. So if there is any loophole in the code itself please let me know as , i really wanted to know what's the problem in the code. Or if there is a problem on the setters side please fix it as its really destroyed my contest today. And at last the code ran with just changing my template for loop , i don't know why this happened. If you know the problem please let me know as i'm really frustrated by this thing and my rating will also go down. I'm pasting the code also here. int main() { ll i, j, k, n, m, ct = 0, ans = 0; tc { ...
. I'm pasting the code also here. int main() { ll i, j, k, n, m, ct = 0, ans = 0; tc, ]) { b[0] = j; fu = 1; break; } } ct = 1; if (fu == 1) { fo(i,n,1, int main() { ll i, j, k, n, m, ct = 0, ans = 0;

Full text and comments »

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

70.
By MikeMirzayanov, history, 10 years ago, translation, In English
2016-2017 CT S03E05: Codeforces Trainings Season 3 Episode 5 <img src="http://codeforces.me/predownloaded/68/d1/68d1581aaa827703d59042999baba6df41a6f631.gif" style="float:right;margin:0 1em 1em 1em;"/> Добро пожаловать на [contest:101116]. Продолжительность тренировки — 4 часа 30 минут. Тренировка открыта как для команд, так и для индивидуальных участников. После ее окончания вы можете дорешивать задачи тренировки или поучаствовать в ней виртуально, если не смогли принять участие одновременно со всеми. Пожалуйста, участвуйте в тренировке честно. Перейдите в раздел <a href="http://codeforces.me/gyms">Тренировки</a> для регистрации и участия. Ориентировочный старт: <a href="http://timeanddate.com/worldclock/fixedtime.html?day=5&month=10&year=2016&hour=16&min=10&sec=0&p1=166">5 октября 2016 г., 16:10 (Московское время)</a>. Так как это тренировка, то возможно набор задач будет расширен, если для значительного количества участников он окажется простым. Условия задач будут на английском языке, ведь мы же готовимся к ACM-ICPC! Уда...
2016-2017 CT S03E05: Codeforces Trainings Season 3 Episode 5

Full text and comments »

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

71.
By miniluigi, history, 10 years ago, In English
Time Complexity of floor and log2 When I was coding a solution for 633E, I noticed that using ~~~~~ int log(int x) { int ct = 0; int k = 1; while (k <= x) { k *= 2; ct++; } return ct-1; } ~~~~~ over `floor(log2(x))` allowed my program to run in time. Could someone please explain to me why one is faster than the other? Thanks! See here for my code and use compare to see that nothing else is different: log(x): http://codeforces.me/contest/633/submission/18990265 floor(log2(x)): http://codeforces.me/contest/633/submission/18990181
When I was coding a solution for 633E, I noticed that using ~~~~~ int log(int x) { intct, ~~~~~ int log(int x) { int ct = 0; int k = 1; while (k <= x) { k *= 2; ct

Full text and comments »

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

72.
By MikeMirzayanov, history, 10 years ago, translation, In English
2016-2017 CT S03E09: Codeforces Trainings Season 3 Episode 9 <img src="http://codeforces.me/predownloaded/94/6f/946fee0671fc1a5e38fd124c50de4a604139019b.jpg" style="float:right;margin:0 1em 1em 1em;"/> Добро пожаловать на [contest:101156]. Продолжительность тренировки — 5 часов. Тренировка открыта как для команд, так и для индивидуальных участников. После ее окончания вы можете дорешивать задачи тренировки или поучаствовать в ней виртуально, если не смогли принять участие одновременно со всеми. Пожалуйста, участвуйте в тренировке честно. Перейдите в раздел <a href="http://codeforces.me/gyms">Тренировки</a> для регистрации и участия. Ориентировочный старт: <a href="http://timeanddate.com/worldclock/fixedtime.html?day=9&month=11&year=2016&hour=16&min=10&sec=0&p1=166">9 ноября 2016 г., 16:10 (Московское время)</a>. Так как это тренировка, то возможно набор задач будет расширен, если для значительного количества участников он окажется простым. Условия задач будут на английском языке, ведь мы же готовимся к ACM-ICPC! Удачи!
2016-2017 CT S03E09: Codeforces Trainings Season 3 Episode 9

Full text and comments »

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

73.
By MikeMirzayanov, history, 10 years ago, translation, In English
2016-2017 CT S03E08: Codeforces Trainings Season 3 Episode 8 <img src="http://codeforces.me/predownloaded/36/81/368155e1b9b2b00607e9752c33212fd036375768.jpg" style="float:right;margin:0 1em 1em 1em;"/> Добро пожаловать на [contest:101150]. Продолжительность тренировки — 5 часов. Тренировка открыта как для команд, так и для индивидуальных участников. После ее окончания вы можете дорешивать задачи тренировки или поучаствовать в ней виртуально, если не смогли принять участие одновременно со всеми. Пожалуйста, участвуйте в тренировке честно. Перейдите в раздел <a href="http://codeforces.me/gyms">Тренировки</a> для регистрации и участия. Ориентировочный старт: <a href="http://timeanddate.com/worldclock/fixedtime.html?day=2&month=11&year=2016&hour=16&min=10&sec=0&p1=166">2 ноября 2016 г., 16:10 (Московское время)</a>. Так как это тренировка, то возможно набор задач будет расширен, если для значительного количества участников он окажется простым. Условия задач будут на английском языке, ведь мы же готовимся к ACM-ICPC! Удачи!
2016-2017 CT S03E08: Codeforces Trainings Season 3 Episode 8

Full text and comments »

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

74.
By MikeMirzayanov, history, 10 years ago, translation, In English
2016-2017 CT S03E04: Codeforces Trainings Season 3 Episode 4 <img src="http://codeforces.me/predownloaded/55/22/5522871c97d08493b396d96d8a655a7a608d94e4.jpg" style="float:right;margin:0 1em 1em 1em;"/> Добро пожаловать на [contest:101104]. Продолжительность тренировки — 4 часа 30 минут. Тренировка открыта как для команд, так и для индивидуальных участников. После ее окончания вы можете дорешивать задачи тренировки или поучаствовать в ней виртуально, если не смогли принять участие одновременно со всеми. Пожалуйста, участвуйте в тренировке честно. Перейдите в раздел <a href="http://codeforces.me/gyms">Тренировки</a> для регистрации и участия. Ориентировочный старт: <a href="http://timeanddate.com/worldclock/fixedtime.html?day=28&month=9&year=2016&hour=16&min=10&sec=0&p1=166">28 сентября 2016 г., 16:10 (Московское время)</a>. Так как это тренировка, то возможно набор задач будет расширен, если для значительного количества участников он окажется простым. Условия задач будут на английском языке, ведь мы же готовимся к ACM-ICPC! У...
2016-2017 CT S03E04: Codeforces Trainings Season 3 Episode 4

Full text and comments »

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

75.
By MikeMirzayanov, history, 10 years ago, In English
2016-2017 CT S03E06: Codeforces Trainings Season 3 Episode 6 <img src="http://codeforces.me/predownloaded/4b/f1/4bf15020a10e23e5321f165f5dd0a0f17b7f2617.png" style="float:right;margin:0 1em 1em 1em;"/> Добро пожаловать на [contest:101124]. Продолжительность тренировки — 5 часов. Тренировка открыта как для команд, так и для индивидуальных участников. После ее окончания вы можете дорешивать задачи тренировки или поучаствовать в ней виртуально, если не смогли принять участие одновременно со всеми. Пожалуйста, участвуйте в тренировке честно. Перейдите в раздел <a href="http://codeforces.me/gyms">Тренировки</a> для регистрации и участия. Ориентировочный старт: <a href="http://timeanddate.com/worldclock/fixedtime.html?day=12&month=10&year=2016&hour=16&min=10&sec=0&p1=166">12 октября 2016 г., 16:10 (Московское время)</a>. Так как это тренировка, то возможно набор задач будет расширен, если для значительного количества участников он окажется простым. Условия задач будут на английском языке, ведь мы же готовимся к ACM-ICPC! Удач...
2016-2017 CT S03E06: Codeforces Trainings Season 3 Episode 6

Full text and comments »

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

76.
By karthikeyan_01, history, 6 years ago, In English
CSES Labyrinth Problem Problem State : https://cses.fi/problemset/task/1193 ~~~~~ #include <bits/stdc++.h> #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl #define mp make_pair #define fi first #define se second #define pb push_back #define all(x) (x).begin() , (x).end() #define rall(x) (x).begin() , (x).end() using namespace std; const int maxN = 1e3; char mat[maxN][maxN]; bool vis[maxN][maxN]; pair<int ,int > source; int n, m ; int dx[4] = {-1 , 0 , 1 , 0}; int dy[4] = {0, 1, 0 , -1 }; pair<int ,int > dest; bool isok(int xx , int yy){ if( xx >=0 && yy >=0 && xx <n && yy < m && mat[xx][yy] == '.' && !vis[xx][yy]){ return true; } return false; } vector<char> pos; int ct =0; void bfs(){ queue<pair<int, int>> q; q.push(source); int ans =0; while(!q.empty()){ pair<int , int> dd = q.front(); q.pop(); vis[dd.fi][dd.se] = true; for(int i =0; i<4; ++i)...
+ dx[i] , dd.se + dy[i]}); ct++; } } if(ans){ cout << "YES" << "\n"; cout << ct, [xx][yy]){ return true; } return false; } vector pos; int ct =0; void bfs

Full text and comments »

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

77.
By MikeMirzayanov, history, 10 years ago, In English
2016-2017 CT S03E01: Codeforces Trainings Season 3 Episode 1 <img src="http://assets.codeforces.com/images/evolution-of-programmer.jpg" style="float:right;margin:0 1em 1em 1em;"/> Welcome to [contest:101078]. The training duration is 4.30 hours. It is opened for teams as well as for individual participants. After the end you may use the practice mode to complete problem solving. Also it will be availible as a virtual contest for whose of you who can't take part today. Please, do not cheat. Only fair play! It is possible that the problems will be too easy for some participants, it is possible that we will add some problems. Good luck!
2016-2017 CT S03E01: Codeforces Trainings Season 3 Episode 1

Full text and comments »

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