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 Rhodoks, history, 4 years ago, In English
Codeforces Round #810 Editorial Sorry for the late editorial. May this editorial help you. If you have questions, feel free to ask. [problem:1711A] <spoiler summary="hint1."> The minimal weight is at least $1$ since $1$ divides any integer (so $1$ divides $p_1$). </spoiler> <spoiler summary="solution"> Since $k+1$ does not divide $k$, a permutation with weight equal to $1$ is: $[n,1,2,\cdots,n-1]$. </spoiler> <spoiler summary="code"> ~~~~~ #include <bits/stdc++.h> using namespace std; void work() { int n; cin>>n; cout<<n<<' '; for (int i=1;i<n;i++) cout<<i<<' '; cout<<endl; } int main() { int casenum=1; cin>>casenum; for (int testcase=1;testcase<=casenum;testcase++) work(); return 0; } ~~~~~ </spoiler> [problem:1711B] <spoiler summary="hint1."> See the party as a graph. </spoiler> <spoiler summary="hint2."> Divide the vertices into two categories according to their degrees' parity. </spoiler> <spoiler summary="solution"> Let's consider ...
=0,f1=0,f2=0; for(int j=m,i=0;j>=1;--j){ while(i<=x) ++i; db[j]=i; sm, bool check(int x){ ll sm=0,f1=0,f2=0; for(int j=m,i=0;j>=1;--j){ while(i<=x

Full text and comments »

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

2.
By maomao90, history, 3 years ago, In English
Hello 2024 Hello Codeforces, We are very glad to invite you to participate in [contest:1919], which will start on [contest_time:1919]. You will be given **8 problems** and **2.5 hours** to solve them. One of the problems will be divided into two subtasks. The round will be rated for everyone. There will be at most 2024 interactive problems, so please read the [guide for interactive problems](https://codeforces.me/blog/entry/45307) before the contest. All the problems are written and prepared by me. <spoiler summary="Spoiler"> The first tester tested on 10 October **2022**. </spoiler> We would like to give our sincere thanks to: - [user:errorgorn,2024-01-02] for his wonderful coordination! - [user:Alexdat2000,2024-01-02] for translating problem statements. - [user:dario2994,2024-01-02] for coming up with the solution to one of the problems. - [user:conqueror_of_tourist,2024-01-02], [user:iLoveIOI,2024-01-02], [user:Um_nik,2024-01-02], [user:oolimry,2024-01-02], [user:thenymphs...
: [user:tourist,2024-01-07] - F1: [user:ko_osaga,2024-01-07] - F2: [user:ko_osaga,2024-01-07] - G, ] - D: [user:tourist,2024-01-07] - E: [user:tourist,2024-01-07] - F1: [user:ko_osaga,2024-01-07

Full text and comments »

Announcement of Hello 2024
  • Vote: I like it
  • +2422
  • Vote: I do not like it

3.
By geranazavr555, history, 6 years ago, translation, In English
User activity in the profile! [new, Feb. 2021] For example, [user:tourist,2021-02-16], you can find it on his profile page: ![tourist](/predownloaded/f1/b7/f1b73bae1030397aef853c9907bf436c31af8836.png)
](/predownloaded/f1/b7/f1b73bae1030397aef853c9907bf436c31af8836.png)

Full text and comments »

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

4.
By MikeMirzayanov, 3 years ago, In English
Codeforces Round 923 (Div. 3) Gamarjoba, Codeforces! On [contest_time:1927] will start [contest:1927], the next Codeforces round for the Div.3. Lately, I've been coming up with problem ideas less frequently, but I don't want to lose this skill. Welcome to the round where all problems are my own creation! I hope you'll enjoy them. A huge thank you to [user:Vladosiya,2024-02-05] for preparing the majority of problems in Polygon. Also, thanks to [user:pashka,2024-02-05] and [user:KAN,2024-02-06] for helping with the discussion of problem ideas. Thank you very much [user:74TrAkToR,2024-02-05], [user:CLown1331,2024-02-05], [user:EternalAlexander,2024-02-05], [user:Jostic11,2024-02-05], [user:Killever,2024-02-05], [user:KoT_OsKaR,2024-02-05], [user:LoveWX,2024-02-05], [user:MADE_IN_HEAVEN,2024-02-05], [user:dan_dolmatov,2024-02-05], [user:jnmtz111__,2024-02-05], [user:pedrolino,2024-02-05], [user:theRealChainman,2024-02-05], [user:yorky,2024-02-05] for testing the round. As usual for the Div.3 rounds: ...

Full text and comments »

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

5.
By tourist, 2 years ago, translation, In English
Code Weekend #1 <div align="right" margin="20px"> <img align="right" src="/predownloaded/72/f1/72f1f31badb1452243838a0fc2553c04accff164.jpeg" alt="logo" width="300px" height="300px" margin="20px"/></div> Hello everyone! We, the [RGBTeam](https://clist.by/team/Romka,tourist,%E2%88%A83886090/) ([user:qwerty787788,2024-05-21], [user:Romka,2024-05-21] and [user:tourist,2024-05-21]), are huge fans of heuristic programming competitions and are quite saddened by the fact that they are becoming less and less frequent each year. One day, we decided to organize our own competition :) Despite the fact that such ideas often remain just ideas, this time we have a serious mindset, and now we want to invite you all to participate in the first — and hopefully not last — **[Code Weekend #1!](https://codeweekend.dev)** The competition will be held in a format quite similar to ICFPC/Google Hashcode — there will be one problem and several dozen tests for it. You will need to submit just an output according to t...

Full text and comments »

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

6.
By ATSTNG, history, 7 years ago, In English
[Tutorial] Matroid intersection in simple words **[This article is also available in [Russian](https://codeforces.me/blog/entry/69287?locale=ru)]** Hello, CodeForces. I think that matroids are beautiful and powerful concept, however, not really well known in competitive programming. I’ve discovered matroids at 2019 Petrozavodsk Winter Training Camp. There was a problem that clearly cannot be solved using usual techniques I knew, editorial for this problem was just these three words “just matroid intersection”. Back then it took me more than 2 days of upsolving to find all the information and details I need and implement solution that gets Accepted on this. And it took way longer to actually understand why does it work and exactly how does it work. (I still hesitate in some details.) Of course, it is not hard to google up all the definitions and some related articles, but in my opinion they all are focused more on mathematical part of theory, strict proofs in some not really obvious but short ways, and observing only ke...
![ ](/predownloaded/f1/09/f109c81382f68b1c030d66b2e0e1b37f90f3417f.png)

Full text and comments »

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

7.
By TheOneYouWant, history, 6 years ago, In English
Editorial — Codeforces Round #646 Hello, everyone! It was a delight for us to have you participate in our contest. We hope you enjoyed the problems! Here, we present to you the solutions of the problems. I have also prepared some memes for you to enjoy &mdash; disclaimer: not all of them were created by me. [tutorial:1363A] Author of this problem was [user:Ashishgup,2020-05-31]. <spoiler summary="Relevant Meme"> ![ ](/predownloaded/cd/f1/cdf13618b93c6243dec10ec495181286a2616caa.jpg) </spoiler> <spoiler summary="Code for A"> ~~~~~ #include <bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define int long long const int N = 2e5 + 5; int n, x; int a[N], f[2]; int32_t main() { IOS; int t; cin >> t; while(t--) { f[0] = f[1] = 0; cin >> n >> x; for(int i = 1; i <= n; i++) { cin >> a[i]; f[a[i] % 2]++; } bool flag = 0; for(int i = 1; i <= f[1] && i <= x; i ...
![ ](/predownloaded/cd/f1

Full text and comments »

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

8.
By Tony2_CF, history, 9 months ago, In English
The Time Complexity Lower Bound for Segment Tree Beats is log^2 Original Post: https://jiry-2.blog.uoj.ac/blog/1404 The following content is translated by Gemini 2.5 Pro. ## Part 1: Introduction to the Hacking Method ### How to Map the Hack Sequence to a Segment Tree First, we are given a Hack sequence of length $len$. After $O(1)$ range addition operations and $\Theta(\log len)$ global $\text{chkmax}$ operations, this sequence becomes a cyclic shift (rotation) of the original sequence. Since a cyclic shift does not affect our range addition and global $\text{chkmax}$ operations (we can simply shift the indices for the range addition accordingly), we can consider the sequence as unchanged. If we have such a sequence, let $len=n^{\frac{1}{3}}$, and place such a sequence at intervals of $n^{\frac{2}{3}}$. Each sequence corresponds exactly to a segment tree interval. A subtree of size $n^{\frac{2}{3}}$ contains exactly one such segment tree interval. For the Hack sequence, the range addition operations are performed one by one on eac...
![ ](/predownloaded/73/f1/73f1a7ce629c3ef7475bf36ba241160204b2afcc.png)

Full text and comments »

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

9.
By TheScrasse, 3 years ago, In English
Pinely Round 3 (Div. 1 + Div. 2) <img src="https://assets.codeforces.com/images/pinely_logo.png" align="right" style="height: 200px;" alt="text"/> Ciao, Codeforces! We're glad to invite you to take part in [contest:1909], which will start on [contest_time:1909]. You will be given **9 problems** and **3 hours** to solve them. One of the problems will be divided into two subtasks. The problems were authored and prepared by me. <spoiler summary="Spoiler"> ![ ](https://i.imgur.com/lipiKQE.png) </spoiler> We would like to thank - [user:errorgorn,2023-12-20] for his fun &#129292; &#x1F921; &#x1F913; &#x1F629; coordination; - [user:Alexdat2000,2023-12-20] for Russian translation; - [user:franv,2023-12-20] for writing $173$ lines of checker of problem H correctly at the first try; - [user:franv,2023-12-20] for pictures in the editorial; - [user:dario2994,2023-12-20], [user:Endagorion,2023-12-20], [user:ffao,2023-12-20], [user:Golovanov399,2023-12-20], [user:nor,2023-12-20] for VIP testing; - [user:Kaey,202...
: [user:Petr,2023-12-23] - D: [user:maspy,2023-12-23] - E: [user:QueenOfDiamonds,2023-12-23] -F1, : [user:maspy,2023-12-23] - E: [user:QueenOfDiamonds,2023-12-23] - F1: [user:ksun48,2023-12-23] - F2

Full text and comments »

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

10.
By -is-this-fft-, history, 4 years ago, In English
[Tutorial] FFT If I was a YouTuber, this would be the place where I fill the entire screen with screenshots of people asking me to make this. Anyway, not so long ago I gave a lecture on FFT and now [user:peltorator,2023-01-11] is giving away [free money](https://codeforces.me/blog/entry/110840), so let's bring this meme to completion. In this blog, I am going to cover the basic theory and (competitive programming related) applications of FFT. There is a long list of generalizations and weird applications and implementation details that make it faster. Maybe at some point I'll write about them. For now, let's stick to the basics. **The problem.** Given two arrays $a$ and $b$, both of length $n$. You want to quickly and efficiently calculate another array $c$ (of length $2n - 1$), defined by the following formula. $$c_k = \displaystyle \sum_{i + j = k} a_i \cdot b_j.$$ Solve it in $O(n \log n)$. First of all, why should you care? Because this kind of expression comes up in combinatorics a...
![ ](/predownloaded/f1/78/f17824a30724e99d395432c37aa2a927de071916.png)

Full text and comments »

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

11.
By TheScrasse, history, 2 years ago, In English
Codeforces Round 975 (Div. 1, Div. 2) Ciao, Codeforces! We're glad to invite you to take part in [contest:2018] and [contest:2019], which will start on [contest_time:2018]. You will be given **6 problems** and **2 hours and 30 minutes** to solve them in both divisions. Some problems will be divided into subtasks. **UPD: the time has been changed to [contest_time:2018], which is different from the time announced before. Please note the unusual starting time.** This round is based on [Italian Olympiad in Informatics (OII) 2024](https://codeforces.me/blog/entry/133905). The problems were authored by [user:lorenzoferrari,2024-09-22], [user:wksni,2024-09-22] and me. We would like to thank - [user:KAN,2024-09-22] for his nutella coordination; - [user:Alexdat2000,2024-09-27] for Russian translation; - [user:bortoz,2024-09-22], [user:collodel,2024-09-22], [user:dp_1,2024-09-22], [user:franfill,2024-09-22], [user:franv,2024-09-22], [user:harniver,2024-09-22], [user:jamesbamber,2024-09-22], [user:Kaey,2024-09-22], ...
-09-27] - F1: [user:rainboy,2024-09-27] - F2: [user:rainboy,2024-09-27] - F3: [user:rainboy,2024-09, ] - E2: [user:jiangly,2024-09-27] - F1: [user:rainboy,2024-09-27] - F2: [user:rainboy,2024-09-27

Full text and comments »

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

12.
By Monogon, history, 6 years ago, In English
Efficient 3D Convex Hull Tutorial _Warning: The following contains graphic depictions of geometry, precision errors, and degenerate cases. Viewer discretion is advised._ ### Prerequisites I assume the reader is familiar with: - 2D Convex Hulls - 3D Vector Operations (dot and cross products) ### Introduction Recall that in the 2D convex hull problem, you are given a set of 2D points, and you must compute the smallest convex polygon containing all the given points. By convex, we mean that for any two points $A$ and $B$ inside the polygon, the entire line segment $AB$ is also inside the polygon. The problem in 3D is completely analogous. You are given $n$ 3D points, and you must compute the smallest convex polyhedron containing all the given points. Similarly, a polyhedron is convex if for any two points $A$ and $B$ inside the polyhedron, the line segment $AB$ is also inside the polyhedron. In the 2D case, it is more obvious what the output is. We can simply output a circular list of vertices on the ...
automatically when we insert the 4th point face *F1 = add_face(0, 1, 2); face *F2, together // e1 is a reference to the F1 edge pointer, and e2 is a reference to the F2 edge pointer, // This function will glue two faces together // e1 is a reference to the F1 edge pointer, and e2

Full text and comments »

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

13.
By sum, history, 3 years ago, In English
Codeforces Round #919 (Div. 2) Hello Codeforces! ================= [user:omeganot,2024-01-10] and I are excited to invite you to participate in [contest:1920] which will start on [contest_time:1920]. You will be given 2 hours to solve 6 problems. One of the problems is divided into 2 subtasks. **This round will be rated for participants of Division 2 with a rating lower than 2100.** We would like to thank - [user:artyom123,2024-01-10] for his epic coordination and also for translating the problem statements! - [user:A_G,2024-01-10], [user:PurpleCrayon,2024-01-10], [user:juliany2,2024-01-10], [user:Andreasyan,2024-01-10], [user:oursaco,2024-01-10], [user:hyforces,2024-01-10], [user:Apple_Method,2024-01-10], [user:GusterGoose27,2024-01-13], [user:null_awe,2024-01-10], [user:awesomeguy856,2024-01-10], [user:lunchbox,2024-01-10], [user:jli505,2024-01-10], [user:Lemur95,2024-01-10], [user:ocasu,2024-01-10], [user:EmeraldBlock,2024-01-10], [user:EnDeRBeaT,2024-01-10], [user:cry,2024-01-10], [user:htetgm,2024...
-01-13] E) [user:EasonTAO,2024-01-13] F1) [user:jeroenodb,2024-01-13] F2) [user:jeroenodb, ] F1) [user:jeroenodb,2024-01-13] F2) [user:jeroenodb,2024-01-13]

Full text and comments »

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

14.
By pseudocoder10, 6 years ago, In English
Lockout Bot for codeforces Hello everyone, I'm sure many of you have been watching and enjoying the recent [lockout streams](https://www.youtube.com/watch?v=bBNIIg8REUU&feature=youtu.be) organized by [user:ecnerwala,2020-06-08] and [user:scott_wu,2020-06-08] and would be wanting to compete with your friends in a similar format. I have made a discord bot that does exactly the same. The source code for the bot can be found [here](https://github.com/pseudocoder10/Lockout-Bot). The bot gives a set of 5 problems with ratings from [x, x+400], where x is chosen by you and the point distribution is [100, 500]. The first person to solve a problem gets the points for it. The match ends when someone has >= 800 points or 45 minutes have been elapsed. The bot automatically updates the status when someone solves a problem but you can also do it manually. To invite the bot to your discord server, click [here](https://discord.com/oauth2/authorize?client_id=669978762120790045&permissions=0&scope=bot). If you don't wanna ...
![ ](/predownloaded/f1/29/f12977467fb2997a00f5c438790c07f25750c608.png, , you will be able to compete with others. ![ ](/predownloaded/f1/29

Full text and comments »

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

15.
By antontrygubO_o, 7 years ago, In English
Are subtasks evil? Everything in this blog is only my opinion, motivated by the recent round. If you disagree with it, let's discuss in the comments! It's always hard to prepare a balanced problem set, and when the contest turns out to be unbalanced, an army of angry coders will destroy you in the comments section. But how can setters make Codeforces contests balanced? Before, authors usually had to spend more time coming up with new problems which would close a too large gap between some $2$ problems. But now we have an easier solution! Any time there is a big difficulty gap in a contest, add subtasks to it! [View](https://codeforces.me/blog/entry/67810?#comment-520212) on subtasks by [user:MikeMirzayanov,2019-11-24]: Subtasks became really widely used in Codeforces contests recently. I looked at last $30$ contests rated for Div1 users. In turns out that: Rounds $30 - 21$ had only $1$ subtasks in total, Rounds $20 - 11$ had $3$ subtasks in total, The last $10$ rounds already had $7...
clarify:** I don't think that all problems with subtasks are bad. In particular, I think thatF1 and, that F1 and F2 from [Codeforces Global Round 4](https://codeforces.me/contest/1178) were fitting

Full text and comments »

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

16.
By nifeshe, 20 months ago, In English
Codeforces Round 997 (Div. 2) Hi, Codeforces! I'm delighted to invite you to the best/second best/third best round of 2025 so far! [contest:2056] will be held on [contest_time:2056]. You will be presented with **at least** $6$ and **at most** $6$ problems, one of which might be divided into two subtasks, and $2$ hours to solve them. Many of you may not believe it, but the problems were authored and written by [user:nifeshe,2025-01-14] with a great help from [user:maomao90,2025-01-14]. Moreover, I would like to thank: - [user:maomao90,2025-01-14] for coordinating the round and helping with tasks ideas/preparation. - [user:Alexdat2000,2025-01-14] for translating the problems to Russian. - All of our testers: [user:errorgorn,2025-01-14], [user:A_G,2025-01-14], [user:LipArcanjo,2025-01-14], [user:_istil,2025-01-14], [user:Markadiusz,2025-01-14], [user:Error_Yuan,2025-01-14], [user:Intellegent,2025-01-14], [user:mwen,2025-01-14], [user:LMeyling,2025-01-14], [user:hazzlek,2025-01-14], [user:iLoveIOI,2025-0...
,2025-01-17] E. 00:18:06 by [user:zdc123456,2025-01-17] F1. 00:27:48 by [user:peti1234,2025-01, F1. 00:27:48 by [user:peti1234,2025-01-17]

Full text and comments »

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

17.
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...
https://codeforces.me/contest/1178/problem/F1 (5) //[NICE][MATH][REDUCTION], https://codeforces.me/contest/1203/problem/F1 (5) //[VERY NICE][SORTING][CASES]

Full text and comments »

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

18.
By kuviman, history, 11 years ago, translation, In English
Обновления Codeforces (апрель-май 2015) Привет! Работа на Codeforces никогда не стоит на месте, и вот пришло время рассказать вам о последних изменениях, ранее не упоминавшихся. ### Testlib - testlib переехал на [GitHub](https://github.com/mikemirzayanov/testlib), выпущена новая версия 0.9.9 с поддержкой C++11. Добавлены генераторы двудольных графов, корневых и простых деревьев. ### Polygon - Добавлена базовая поддержка групп тестов. Теперь вы можете для каждого теста указать его группу, запускать invocations по группам, добавлены строки с summary по группам на странице просмотра invocation'а. Если для теста указана группа, она появится в дескрипторе задачи (например `<test cmd="gen 1 2" group="testGroup" method="generated"/>`). Эта функциональность может оказаться полезной при подготовке задач для школьных олимпиад. - Добавлена возможность просмотра условий и валидатора задачи/контеста на одной странице. Это значительно упрощает нахождение ошибок в переводах и валидаторе (раньше для этого нужно было открывать их...
|Стало| |-|-| | ![ ](http://codeforces.me/predownloaded/0c/f1

Full text and comments »

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

19.
By Al.Cash, 10 years ago, In English
Geometry: 2D points and lines [Tutorial] I get an impression that a lot of coders struggle with geometric problems and prefer to avoid them. That's not much of a surprise, considering that I couldn't find a good writing explaining the basics and giving useful advice how to proceed. Moreover, some resources obfuscate this beautiful area to the point it's despised by the readers. I'll try to change that, but first I'll mention some of the better resources: [geomalgorithms.com](http://geomalgorithms.com/points_and_vectors.html) This is where you can start if you don't have a basic notion of a vector. Also there are more detailed explanations for some examples I'll list, but I dislike the implementations. [This post in Russian](http://codeforces.me/blog/entry/6642) has a link to the code that's most similar to mine, with some comments (unfortunately, also is Russian)[cut]. ### Point structure and operations Without further ado, I'll start with my code for the `Point` structure. Explanations are below, so don't rush t...
(point))) FUNC2(dist, Point<F1>& lhs, Point& rhs, norm(lhs - rhs)) FUNC2(dist2, Point<F1>& lhs, ) { return expr; } #define FUNC2(name, arg1, arg2, expr) \ template F1, class F2> \ inline, )) FUNC2(angle, Point<F1>& lhs, Point& rhs, atan2(lhs ^ rhs, lhs * rhs)) FUNC3(angle, Point<F1, , other.y); } template F1> explicit operator Point<F1> () const { return Point< F1, // < 0 if rhs <- lhs counter-clockwise, 0 if collinear, > 0 if clockwise. FUNC2(ccw, Point<F1, F1> explicit operator Line<F1> () const { return Line<F1>(Point<F1>(a), Point<F1 >(ab), false, F1> explicit operator Point<F1> () const { return Point<F1>(static_cast<F1>(x), static_cast<F1, FUNC1(operator -, Point& point, makePoint(-point.x, -point.y)) FUNC2(operator +, Point<F1>& lhs, FUNC2(operator *, Point<F1>& lhs, Point& rhs, lhs.x * rhs.x + lhs.y * rhs.y) FUNC2(operator, FUNC2(operator <, Point<F1>& lhs, Point& rhs, lhs.y < rhs.y || (lhs.y == rhs.y && lhs.x, FUNC2(operator ==, Point<F1>& lhs, Point& rhs, lhs.x == rhs.x && lhs.y == rhs.y) FUNC2, template F1, class F2, class F3> bool intersectClosedSegments(const Line<F1>& lhs, const, template F1, class F2, class F3> bool intersectLines(const, template F1, class F2, class F3> void reflection(const Point<F1>& point, const Line, template F1, class F2> bool operator () (const Point<F1>& lhs, const Point& rhs, template F1, class F2> distF<F1, F2> distLine(const Point<F1>& point, const Line & line, ~~~~~ template F1, class F2, class F3> bool intersectSegments(const Line<F1>& lhs, const, ~~~~~ template F1, class F2, class F3> void closest(const Point<F1>& point, const Line, ~~~~~ template F1, class F2, class F3> void projection(const Point<F1>& point, const Line, ~~~~~ template F1, class F2> bool onLine(const Point<F1>& point, const Line& line, ~~~~~ template F1, class F2> bool onSegment(const Point<F1>& point, const Line& seg, ~~~~~ template F1, class F2> distF<F1, F2> distSegment(const Point<F1>& point, const Line, ~~~~~ template F1, class F2> using distF = decltype(sqrt(F1() + F2()));

Full text and comments »

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

20.
By hxu10, 11 months ago, In English
Codeforces Round 1061 (Div. 2) On the special day of 1024, I am very glad to invite you to participate in [contest:2156], starting at [contest_time:2156] There will be six problems for you to solve in two hours, one of which will have two parts. At least one problem will be interactive, so please make sure to read the [guide for interactive problem](https://codeforces.me/blog/entry/45307) before the contest. This round will be rated for all participants with rating below 2100. All problems were authored by me, and carefully prepared by [user:maomao90,2025-10-20] and me. I would like to thank the following list of very strong individuals for making this round possible: - [user:maomao90,2025-10-20] for his wonderful coordination and careful adjustments to some problems! - [user:MathModel,2025-10-20] for his excellent work on the editorial. - [user:Alexdat2000,2025-10-20] for translating the statements into russian. - [user:Dominater069,2025-10-20] and [user:A_G,2025-10-20] for VIP testing - [user:Agi...
problems. For this contest, problems A to D will have hacks disabled, while E, F1, and F2 will still have, , problems A to D will have hacks disabled, while E, F1, and F2 will still have hacks as usual

Full text and comments »

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

21.
By adamant, 19 months ago, In English
OCPC 2025 Winter — wrap Hi everyone! <center><a href="https://ocpc.camp"><img src="https://ocpc.camp/images/ocpc.svg" height="100px"></a> <a href="https://icpc.foundation/"><img src="/predownloaded/43/08/43086529a28ccb5c9f2f2eec560ffa85e09c6881.svg" height="100px"></a></center> <center> <b>Supported by</b><br> <a href="https://www.quantco.com/"><img src="https://ocpc.camp/images/quantco.svg" height="60px" style="margin: 10px 10px 10px 10px;"></a> <a href="https://ordercapital.com/"> <img src="https://ocpc.camp/images/OrCa.svg" height="60px" style="margin: 10px 10px 10px 10px;"> </a> <a href="https://www.janestreet.com/join-jane-street/open-roles/?type=students-and-new-grads&location=london"> <img src="/predownloaded/ee/f2/eef26616a3661c658d1545f18ed21fabb14d5871.svg" height="60px" style="margin: 10px 10px 10px 10px;"></a> <a href="https://pinely.com/"> <img src="/predownloaded/0a/0f/0a0f3f67435d1f6e467bc7203d4a2090ba8f92cc.svg" height="60px" style="margin: 10px 10px 10px 10px;"></a> </ce...
<>

Full text and comments »

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

22.
By BledDest, 3 weeks ago, translation, In English
Educational Codeforces Round 194 - Editorial [problem:2260A] <spoiler summary="Tutorial"> [tutorial:2260A] </spoiler> <spoiler summary="Solution"> ~~~~~ t = int(input()) for i in range(t): n = int(input()) a = list(map(int, input().split())) cnt0 = a.count(0) if cnt0 >= 2: print(a[0] + a[-1]) else: print(-1) ~~~~~ </spoiler> [problem:2260B] <spoiler summary="Tutorial"> [tutorial:2260B] </spoiler> <spoiler summary="Solution"> ~~~~~ #include<bits/stdc++.h> using namespace std; void solve() { long long x, y, k; cin >> x >> y >> k; long long ans = 0; for(long long i = 0; i < min(y, k); i++) ans += (y + i) % (x + i); long long full = max(0ll, k - y); ans += full * (y - x); cout << ans << endl; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; for(int i = 0; i < t; i++) solve(); } ~~~~~ </spoiler> [problem:2260C] <spoiler...
= 1; i < n; i++) { auto f1 = factorize(i); auto f2 = factorize(i + 1, >, int>> edges; for(int i = 1; i < n; i++) { auto f1 = factorize(i

Full text and comments »

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

23.
By pashka, history, 6 years ago, In English
EDU: Binary Search Hello Codeforces! New [lesson](https://codeforces.me/edu/course/2/lesson/6) in English EDU section. This time I will talk about binary search. <img src="/predownloaded/f1/a3/f1a3c7a64d01066e4668251e45c8b08b6b26a88d.jpg"/> <center style="margin:2.5em;"> <a href="/edu/courses" style="text-decoration:none; font-size:18px; background-color:#01579B; color:white; font-weight:bold; padding:0.5em 1em;">Go to EDU &rarr;</a> </center> More about EDU section you can read in [this](/blog/entry/79530) post. Hope it will be helpful, enjoy!

Full text and comments »

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

24.
By unreal.eugene, 5 years ago, In English
Polygon's New Feature: Resolving Conflicts (finally!) Hello Codeforces! I and [user:DK318,2021-07-09], as students of ITMO University, joined the Codeforces team in June. Last month we mainly dealt with the development of the Polygon platform and were focused on one significant feature lots of people dreamed of. Have you ever made some changes to the problem, and at the same time another person changed the same file? I believe most of you did and disliked this situation. If you wanted to resolve the conflict, you needed to download an archive containing all your changes and repeat them all in the newest revision of the problem. This was very confusing and time-consuming, wasn't it? And now we present probably the most anticipated feature of Polygon since its creation: **a web interface for resolving conflicts**. [cut]<br> When the conflict occurs, the link 'Resolve Conflicts' will appear on the sidebar accessing the page, where you can merge different versions. If it is impossible to load into the problem, the same button will...

Full text and comments »

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

25.
By Dormi, history, 5 years ago, In English
Codeforces LATOKEN Round 1 (Div. 1 + Div. 2) Editorial [problem:1534A] Author: [user:Crackersamdjam,2021-06-13] <spoiler summary="Hint 1"> Let's say you know the colour of the first square, what colours can you figure out next? </spoiler> <spoiler summary="Hint 2"> Colour it like a chessboard, but there's more than one possible chessboard! </spoiler> <spoiler summary="Hint 3"> Brute force the color of the first square! </spoiler> <spoiler summary="Tutorial"> [tutorial:1534A] </spoiler> <spoiler summary="Solution"> [submission:119400830] </spoiler> [problem:1534B] Author: [user:Dormi,2021-06-13] <spoiler summary="Hint 1"> Consider the contribution of each pillar to the answer. </spoiler> <spoiler summary="Hint 2"> How does doing the operation on a pillar change the contribution to the answer? </spoiler> <spoiler summary="Hint 3"> You only want to do an operation on a pillar if the top cell contributes 2 to the answer. </spoiler> <spoiler summary="Tutorial"> [tutorial:1534B] </spoiler> ...
Continued from $F1$, read that first. , ] Author: [user:Dormi,2021-06-13] Continued from $F1$, read that first

Full text and comments »

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

26.
By Proof_by_QED, history, 15 months ago, In English
EPIC Institute of Technology Round Summer 2025 (Codeforces Round 1036, Div. 1 + Div. 2) Editorial Thanks for participation! We hope you loved the contest. #### [problem:2124A] Problem Credits: [user:Lilypad,2025-07-01] <br> <spoiler summary="Hint"> When is there definitely *not* a solution? </spoiler> <spoiler summary="Solution"> First, note that since relative order is preserved no matter which elements are deleted, if $a$ is originally sorted in nondecreasing order, the array cannot be a derangement no matter which elements are deleted. If $a$ is not sorted, we can note that any two elements that form an inversion pair satisfies the requirements. The total runtime is $O(n)$. </spoiler> <spoiler summary="Code"> ``` #include <bits/stdc++.h> using namespace std; void solve(){ int n; cin >> n; vector<int> arr(n); for(auto &x : arr) cin >> x; for(int i = 0; i < n; i++){ for(int j = i + 1; j < n; j++){ if(arr[i] > arr[j]){ cout << "YES\n2\n"; cout << arr[i] << " " << a...
- [likes: 6, option1] Great Problem - [likes: 6

Full text and comments »

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

27.
By Xiaohuba, 11 months ago, In English
Codeforces Global Round 30 Hello, Codeforces! We are pleased to announce the resumption of the Global Rounds. Thanks to XTX Markets for supporting the initiative! In 2025, we will hold 3 such rounds. The series results will take into account the best 2 participations out of 3. On [contest_time:2164] we will host [contest:2164]. **<img src="/predownloaded/2e/e2/2ee2f0f95f05aae6ca6f47812dae2dc2aabf277b.png" style="width: 200.0px;float: right;margin: 0 1.0em 1.0em 1.0em;max-width: 100.0%;max-height: 100.0%;">** Codeforces Global Round 30 marks the second round in the 2025 series of Codeforces Global Rounds. These rounds are open and rated for everyone. The prizes for this round are as follows: - The top 30 participants will receive a t-shirt. - 20 t-shirts will be randomly distributed among participants ranked between 31 and 500, inclusive. The prizes for the 3-round series in 2025: - In each round, the top-100 participants get points according to the [table](https://pastebin.com/NMzrRc...
: [user:Depressed_sad_boy,2025-11-06] D: [user:ksun48,2025-11-06] E: [user:Kevin114514,2025-11-06]F1, : [user:Kevin114514,2025-11-06] F1: [user:Otomachi_Una,2025-11-06] F2: [user:Otomachi_Una,2025-11-06] G

Full text and comments »

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

28.
By sunkuangzheng, 17 months ago, In English
Codeforces Round 1023 (Div. 2) Hello, Codeforces! [user:auiunu,2025-04-30], [user:nahc0el,2025-04-30] and me are glad to invite you to the last round with 10 binary bits &mdash; [contest:2107], which will start on [contest_time:2107]. You will be given 6 problems and 1 subtask with 2 hours 15 minutes to solve them. The round will be rated for participants of Division 2 with a rating lower than 2100. Division 1 participants can participate unofficially. All problems are authored by [user:auiunu,2025-04-30], [user:nahc0el,2025-04-30] and me. We would like to thank: - [user:Dominater069,2025-04-30] and [user:TheScrasse,2025-04-30] for their wonderful coordination and huge help in preparing the round. - [user:Alexdat2000,2025-05-02] for the Russian translations. - [user:hyman00,2025-04-30], [user:le0n,2025-04-30], [user:Flamire,2025-04-30], [user:jeroenodb,2025-04-30] for LGM testing. - [user:Sana,2025-04-30], [user:N_z__,2025-04-30], [user:Wuyanru,2025-04-30], [user:Halzion,2025-04-30], [user:platter,...
E: [user:SSerxhs,2025-05-05] at 00:29. - Problem F1: [user:peti1234,2025-05-05] at 00:14, ] at 00:22. - Problem E: [user:SSerxhs,2025-05-05] at 00:29. - Problem F1: [user:peti1234,2025-05

Full text and comments »

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

29.
By maomao90, 4 years ago, In English
Global Round 20 Editorial Hope that everyone enjoyed the round. Feel free to ask questions in the comments if you do not understand any part of the editorial [problem:1672A] Author: [user:errorgorn,2022-04-23] <spoiler summary="Hints"> <spoiler summary="Hint 1"> No matter what move each player does, the result of the game will **always** be the same. </spoiler> <spoiler summary="Hint 2"> Count the number of moves. </spoiler> </spoiler> <spoiler summary="Tutorial"> Let us consider the ending state of the game. It turns out that at the ending state, we will only have logs of $1$ meter. Otherwise, players can make a move. Now, at the ending state of the game, we will have $\sum\limits_{k=1}^n a_k$ logs. And each move we increase the number of logs by exactly $1$. Since we started with $n$ logs, there has been exactly $(\sum\limits_{k=1}^n a_k) - n$ turns. Alternatively, a log of length $a_k$ will be cut $a_k-1$ times, so there will be $\sum\limits_{k=1}^n (a_k-1)$ turns. If the...

Full text and comments »

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

30.
By awoo, history, 5 years ago, translation, In English
Educational Codeforces Round 108 Editorial [problem:1519A] Idea: [user:adedalic,2021-04-30] <spoiler summary="Tutorial"> [tutorial:1519A] </spoiler> <spoiler summary="Solution (adedalic)"> ~~~~~ fun main() { repeat(readLine()!!.toInt()) { val (r, b, d) = readLine()!!.split(' ').map { it.toInt() } println(if (minOf(r, b) * (d + 1).toLong() >= maxOf(r, b)) "YES" else "NO") } } ~~~~~ </spoiler> [problem:1519B] Idea: [user:adedalic,2021-04-30] <spoiler summary="Tutorial"> [tutorial:1519B] </spoiler> <spoiler summary="Solution (adedalic)"> ~~~~~ fun main() { repeat(readLine()!!.toInt()) { val (n, m, k) = readLine()!!.split(' ').map { it.toInt() } println(if (n * m - 1 == k) "YES" else "NO") } } ~~~~~ </spoiler> [problem:1519C] Idea: [user:BledDest,2021-04-30] <spoiler summary="Tutorial"> [tutorial:1519C] </spoiler> <spoiler summary="Solution (awoo)"> ~~~~~ #include <bits/stdc++.h> #define forn(i, n) for (int i = 0;...
(i, n){ frac f1 = norm((a[i].a + a[i].b) * 1ll * a[i].d, a[i].b * 1ll * a[i].c, ){ frac f1 = norm((a[i].a + a[i].b) * 1ll * a[i].d, a[i].b * 1ll * a[i].c); frac f2 = norm(a, [i].b, &a[i].c, &a[i].d); g.resize(2 * n); forn(i, n){ frac f1 = norm((a[i].a + a

Full text and comments »

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

31.
By cfalas, 6 weeks ago, In English
Some IOI 2026 Statistics Hey everyone, IOI2026 is over! Congratulations to everyone who participated for their hard efforts. While all the contestants were struggling to solve the problems, I had some free time so I looked into some stats. Some notes before we get into things: - It is entirely possible that some of these are wrong/incomplete/misleading. I only made these to satisfy my own curiosity, and they are not an authoritative source - I expect this to be particularly true for medal cutoffs, where I have not accounted for unofficial contestants Thanks to all the organizers for making IOI2026 a great event! [cut] I try to break them down by category so that this blog doesn’t get too long: IOI vs Codeforces ------------------ This has been well researched before, ([here](https://codeforces.me/blog/entry/145502), [here](https://codeforces.me/blog/entry/134654), [here](https://codeforces.me/blog/entry/68981), [here](https://codeforces.me/blog/entry/57700), and [here](https://codefor...
![ ](/predownloaded/02/f1/02f1d482793787b796d81d361edea2b4afa3d119.png)

Full text and comments »

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

32.
By ChthollyNotaSeniorious, history, 4 years ago, In English
Polynomial Round 2022 (Div. 1 + Div. 2) Editorial Thanks for your participation! I am so sorry for my careless review. We were preparing for this round for many months and made some problems which writers and testers are all like. We do want to give everyone a good time to enjoy the contest. But carelessness is deadly. In problem B, some test cases should have been made, but we missed them in not only the pretests but also the final tests. In fact, we had not noticed it until some suspicious hacks appeared. I and all co-authors sincerely regret our mistake and hope you can forgive us. Besides, few people are cyberbullying authors, please do not do so. If you have a bad experience, you can downvote me because of our fault. [problem:1774A] Idea: [user:cirno_9baka,2022-12-17] <spoiler summary="Solution"> The answer is the number of $1$s modulo $2$. We can get that by adding '-' before the $\text{2nd}, \text{4th}, \cdots, 2k\text{-th}$ $1$, and '+' before the $\text{3rd}, \text{5th}, \cdots, 2k+1\text{-th}$ $1$. </spoiler...
For F1, there is another way. Consider every pig. When ``Repeat``, it, (\log x)$ choices. You can just find a subset or use knapsack to solve it. It can also passF1 and the, If you use map to maintain it, the time complexity is $O((n+X)\log ^2X)$. It can passF1. You can

Full text and comments »

33.
By cyand1317, history, 9 years ago, In English
Codeforces Round #431 Editorial Hi, dear contestants! With the end of Codeforces Round #431 ([Div. 1](http://codeforces.me/contest/848) and [Div. 2](http://codeforces.me/contest/849)), some might be complaining behind the screen that problems are too tricky or hard, or have been struggling with some supposedly solvable problem... Yes, this time problems seem hard, but anyways, I hope they provided you with something, say rating, fun, ideas, or experience. I don't want to see anyone losing confidence because of failure (bad luck) in a single contest — please, don't do so. Here are the hints, tutorials and codes for the problems. Feel free to discuss about problems in the comments, and point out if something is incorrect or unclear. Thank you! ### [problem:849A] by [user:cyand1317,2017-09-01] <spoiler summary="Hint"> What will the whole array satisfy? Is that a sufficient condition? </spoiler> <spoiler summary="Tutorial"> [tutorial:849A] </spoiler> <spoiler summary="Model solution"> ~~~ #in...
+ l <= m ? f0[i + l] : 0); for (int i = 0; i < len; ++i) q1[i] = (i + l <= m ? f1[i + l] : 0, - 1)_ * (i - 1)_ * f1[n - i - 2]_ * 2 * i _; if (i >= 3 && i <= n - 3) ans, _ % MODULUS #define __ %= MODULUS int n; int64 g[MAXN]; int64 f0[MAXN], f1 [MAXN], f2[MAXN, ) { (f0[i + l + 1] += t1[i])__; (f1[i + l + 1] += t2[i])__; } if (i + l, ) { ans += g0[i - 1] * f0[n - i - 1]_ * i _; ans += g1[i - 2] * f1[n - i - 2]_ * 2 * i, // Calcukates f0 and f1. void solve_1(int l, int r) { if (l == r) { (f0[l] += g0[l, f0[0] = 0; f1[0] = 1; f2[0] = 4; for (int i = 1; i <= n; ++i) { f0[i] = g[i, int len = 1; while (len < n) len <<= 1; convolve(len, g1, f1, t1); solve_2(0, n);, int n; int64 g[MAXN]; int64 f0[MAXN], f1[MAXN], f2[MAXN];, int n; int64 g[MAXN]; int64 g0[MAXN], g1[MAXN], g2[MAXN]; int64 f0[MAXN], f1 [MAXN], f2[MAXN];

Full text and comments »

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

34.
By awoo, history, 4 years ago, translation, In English
Educational Codeforces Round 128 [Rated for Div. 2] Hello Codeforces! On [contest_time:1680] [contest:1680] 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 Adilbek [user:adedalic,2022-05-12] Dalabaev, Vladimir [user:vovuh,2022-05-12] Petrov, Ivan [user:BledDest,2022-05-12] Androsov, Mak...

Full text and comments »

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

35.
By sum, history, 3 years ago, In English
Editorial for Codeforces Round #919 (Div. 2) ##Information about the round <spoiler summary="Rating predictions (inspired by BucketPotato's editorial)"> | Person | A | B | C | D | E | F1 | F2 | |--------------------------------------------|------|------|------|------|------|------|------| | [user:sum,2024-01-13] | 800 | 1300 | 1500 | 1900 | 2000 | 2200 | 2900 | | [user:oursaco,2024-01-13] | 800 | 1100 | 1300 | 1600 | 1800 | 2100 | 3100 | | [user:omeganot,2024-01-13] | 900 | 1000 | 1400 | 1700 | 1900 | 2200 | 2800 | | [user:sriniv,2024-01-13] | | | | 1900 | 2000 | 1900 | | | [user:apple_method,2024-01-13] | 1000 | 1200 | 1400 | 1900 | 1600 | | | | [user:awesomeguy856,2024-01-13] | 800 | 1100 | 1400 | 1800 | 1900 | 2000 | 2800 | | [user:nonrice,2024-01-13] | 900 | 1000 | 1400 | 1750 | | | | | [user:null_aw...
| A | B | C | D | E | F1 | F2, ] | [user:sum,2024-01-13] | | F1 & F2 | [user:sum,2024-01-13] | [user:sum,2024

Full text and comments »

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

36.
By adamant, history, 8 months ago, In English
OCPC 2026 Winter — wrap _If you are potentially interested in participating in OCPC **in person** in Summer/Autumn 2026, **please** fill **[this form](https://forms.gle/VdMRh6cAJRN4YvQN6)**!_ Hi everyone! <center><a href="https://ocpc.camp"><img src="https://ocpc.camp/images/ocpc_light.svg" height="80px"></a> <a href="https://icpc.foundation/"><img src="/predownloaded/43/08/43086529a28ccb5c9f2f2eec560ffa85e09c6881.svg" height="80px"></a></center> <center> <b>Supported by</b><br> <a href="https://www.janestreet.com/join-jane-street/open-roles/?type=students-and-new-grads&location=london"> <img src="/predownloaded/ee/f2/eef26616a3661c658d1545f18ed21fabb14d5871.svg" height="40px" style="margin: 10px 10px 10px 10px;"></a> <a href="https://www.hudsonrivertrading.com/"> <img src="https://ocpc.camp/images/HRT.svg" height="40px" style="margin: 10px 10px 10px 10px;"></a> <a href="https://www.silares.com/"> <img src="https://ocpc.camp/images/silares-red.svg" height="40px" style="margin: 10px 10px 10px ...
/636c833ff7ba5041d8049dda00bc42360444fa8e.jpg" height=250px>

Full text and comments »

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

37.
By Al.Cash, 10 years ago, In English
Geometry: Polygon algorithms I decided to share my implementations for the basic polygon algorithms. I see almost no problems on this topic and I hope this will change in the future. First, let's remind the definitions we will use: 1. **Polygon** is a plane figure that is bounded by a finite chain of straight line segments closing in a loop to form a closed chain or circuit. These segments are called its edges or sides, and the points where two edges meet are the polygon's vertices or corners ([wiki](https://en.wikipedia.org/wiki/Polygon)). 2. Polygon is **convex** if a line segment connecting any two points on its boundary lies inside the polygon. Equivalently, all its interior angles are less than or equal to 180 degrees. 3. Polygon is **strictly convex** if in addition no three vertices lie on the same line. Equivalently, all its interior angles are less than 180 degrees. 4. Polygon is **simple** if its boundary doesn't cross itself. I will present two algorithms for each problem: one for **ar...
the boundary (two signs are equal and the third one is 0). ~~~ template F1, class F2, ~~~ template F1, class F2, class F = distF<F1, F2>> F stabPolygonLength(const Line<F1, ~~~ template F1, class F2, class F3> bool stabConvexPolygon(const Line<F1>& line, const, ~~~ template F1, class F2> int pointVsConvexPolygon(const Point<F1>& point, const Polygon, ~~~ template F1, class F2> int pointVsPolygon(const Point<F1>& point, const Polygon, ~~~ template F1, class F2> int pointVsTriangle(const Point<F1>& point, const Polygon, ~~~ template F1, class F2> pair tangentsConvex(const Point<F1>& point, const

Full text and comments »

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

38.
By djm03178, history, 7 years ago, In English
Codeforces Round #620 (Div. 2) Editorial [1304A &mdash; Two Rabbits](https://codeforces.me/contest/1304/problem/A) <spoiler summary="Tutorial"> [tutorial:1304A] </spoiler> <spoiler summary="Solution"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int tc; cin >> tc; while (tc--) { int x, y, a, b; cin >> x >> y >> a >> b; cout << ((y - x) % (a + b) == 0 ? (y - x) / (a + b) : -1) << endl; } } ~~~~~ </spoiler> [1304B &mdash; Longest Palindrome](https://codeforces.me/contest/1304/problem/B) <spoiler summary="Tutorial"> [tutorial:1304B] </spoiler> <spoiler summary="Solution"> ~~~~~ #include <bits/stdc++.h> using namespace std; const int MAX_N = 100; string s[MAX_N]; int main() { set<string> dict; int n, m, i; cin >> n >> m; for (i = 0; i < n; i++) { cin >> s[i]; dict.insert(s[i]); } vector<string> left, right; string mid; for (i = 0; i < n; i++) { string t = s[i]; reverse(t.begin(), t.end()); if (t == s[i]) ...
[1304F1 — Animal Observation (easy version)](https://codeforces.me/contest/1304/problem/F1)

Full text and comments »

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

39.
By KluydQ, history, 3 days ago, In English
Codeforces Round 1123 (Div. 2) Hello, Codeforces! ------------------ <img src="/predownloaded/1c/d0/1cd08a5fb515aad56c5a372c5bb64498a1555c9a.jpeg" style="float: right; width: 155px; height: 100px; margin-left: 0px;"> We are glad and excited to invite you to take part in [contest:2267], which will take place on [contest_time:2267]. You will be given **2** hours and **15** minutes to solve **7** problems. Problem F will be divided into subtasks. <style> * { box-sizing: border-box; } html, body { margin: 0; padding: 0; width: 1000px; height: 200px; overflow: hidden; background: white; font-family: Arial, Helvetica, sans-serif; } table { width: 1000px; height: 200px; border-collapse: collapse; table-layout: fixed; } td { border: 2px solid #b8bec5; text-align: center; vertical-align: middle; padding: 0; color: #15191d; ...
> B C D E F1 + F2, > F1 + F2 G Score, D E F1 + F2 G

Full text and comments »

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

40.
By awoo, history, 18 months ago, translation, In English
Educational Codeforces Round 176 Editorial [problem:2075A] Idea: [user:BledDest,2025-03-18] <spoiler summary="Tutorial"> [tutorial:2075A] </spoiler> <spoiler summary="Solution (BledDest)"> ~~~~~ t = int(input()) for i in range(t): n, k = map(int, input().split()) ans = 0 if n % 2 == 1: n -= k ans = 1 k -= 1 ans += (n + k - 1) // k print(ans) ~~~~~ </spoiler> [problem:2075B] Idea: [user:BledDest,2025-03-18] <spoiler summary="Tutorial"> [tutorial:2075B] </spoiler> <spoiler summary="Solution (Neon)"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, k; cin >> n >> k; vector<int> a(n); for (auto &x : a) cin >> x; long long ans = 0; if (k > 1) { sort(a.begin(), a.end(), greater<int>()); ans = accumulate(a.begin(), a.begin() + k + 1, 0LL); } else { int l = *max_element(a.begin(), a.end() - 1); int r = *max_element(a.be...
(int f1 = 0; f1 <= 1; f1++) for(int f2 = 0; f2 <= 1; f2++) for(int fx, ++) for(int f1 = 0; f1 <= 1; f1++) for(int f2 = 0; f2 <= 1; f2

Full text and comments »

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

41.
By rivalq, 4 years ago, In English
Codeforces Round #793 (Div. 2) Editorial I hope you all liked the round. Please share your feedback in the comments section. [1682A &mdash; Palindromic Indices](https://codeforces.me/contest/1682/problem/A) =============================== <spoiler summary = "Hint"> Read the statement carefully!! The given string is a **palindrome**. </spoiler> <spoiler summary = "Tutorial"> Let's remove some index $i$ from the first half of $s$ and check whether the resulting string is a palindrome or not, the other half has the same approach. The prefix of length $i-1$ already matches with the suffix of the same length because the initial string was a palindrome, so we just need to check if $t = s[i + 1 \ldots n - i + 1]$ is a palindrome. For $t$ to be a palindrome, $s_{n - i + 1}$ should be equal to $s_{i + 1}$ which was initially equal to $s_{n - i}$, again which should be equal to $s_{i + 2}$ and this goes on. Here we can see that $s_i = s_{i + 1} \ldots = s_{n - i + 1}$. So the answer is simply equal to the number ...
), x) - psums.begin() + 1; }; fenwick f1(2*n), f2(2*n), f3(2*n); for, ]; } psum = 0; for(int i=0;if1.get, f1.update(1, -Mint(a[i][1]) * a[i][0]); f1.update(get_next(psum), Mint(a[i][1

Full text and comments »

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

42.
By Vladithur, history, 2 years ago, In English
EPIC Institute of Technology Round Summer 2024 (Div. 1 + Div. 2) Editorial Hope you liked the problems! We apologize for the (very?) weak tests in H. Editorials for problems will be added over time (and hints), for now, please take a look at the available hints and model solutions. <spoiler summary="Easter eggs"> <spoiler summary="A"> ForceCodes is a reference CrossCode, you should try it. </spoiler> <spoiler summary="C"> Basil is one of the characters in OMORI, you should also try it. </spoiler> <spoiler summary="D"> "World is Mine" is one of Hatsune Miku's most well known songs, and a fan-made MV has a lot of cakes in it) I originally wanted to make the characters names Miku and Sweetheart(from OMORI), but decided to stick to Alice and Bob to keep the statement clean. </spoiler> <spoiler summary="E"> The epigraph is a reference to KonoSuba. </spoiler> <spoiler summary="H"> The epigraph is a quote from Celeste (you should try it), and the title is a reference to one of it's locations, Mirror Temple, but only now there are fumo...
- Good problem - Average problem - Bad

Full text and comments »

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

43.
By ko_osaga, history, 12 months ago, In English
Squarepoint Challenge (Codeforces Round 1055, Div. 1 + Div. 2) Editorial Thank you for your participation! Problem A, B were authored by [user:djm03178,2025-10-03]. Problem C was authored by [user:As_dfsdf,2025-10-03]. Problem D was authored by [user:qwerasdfzxcl,2025-10-03]. Problem E, F, G, H1, H2 were authored by [user:ko_osaga,2025-10-03]. [problem:2152A] <spoiler summary="Spoiler"> [tutorial:2152A] </spoiler> <spoiler summary="Code"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; set<int> s; for (int i = 0; i < n; i++) { int x; cin >> x; s.insert(x); } cout << s.size() * 2 - 1 << '\n'; } } ~~~~~ </spoiler> [problem:2152B] <spoiler summary="Spoiler"> [tutorial:2152B] </spoiler> <spoiler summary="Code"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; wh...
((sz(pq[idx[i]]) == 0 || U < pq[idx[i]].top()[0] * L)) { lint f1 = U / L - cost[i]; lint, ]].top()[0] * L)) { lint f1 = U / L - cost[i]; lint f2 = (U / L + 1 - pv) * A + B

Full text and comments »

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

44.
By kiwii, 3 years ago, In English
Luvliest Lub Lub Dynamic Diameter and Euler Tour?? ωeecently, I've encountered this pωoblem in a local contest in my coωountωy and I find this pωobωem has a ωeeeaωy cuωul tωick, i aωso found out that this has a s-s-similar idea, and the pωoblem can be fuωuωutheω be ωeduced to &#10024; **Dynamic Diameter** &#10024; [https://oj.uz/problem/view/CEOI19_diameter](https://oj.uz/problem/view/CEOI19_diameter) ## Pωobωem S-S-Statement (,,> &#7447; <,,) Ur given a&#127795; with $N$ n-n-nodes and $N - 1$ e-edges connecting each of the nodes. Each edge is a tu&omega;u&omega;u&omega;uple $(u[i], v[i], c[i])$, connecting node $u[i]$ and $v[i]$ with weight $c[i]$ $(0 \leq i \leq n - 2)$. &#127968;&#127947;&#65039; You're given $Q$ quewees: - `1`, output the RAWWRGESTTT &#129409;&#129409;&#129409;&#129409; diameter of the t&omega;ee, fo&omega;o&omega;ed with T&omega;o&#9996;&#65039; nodes $x$ and $y$ de-de-denoting the endp&omega;oints of the diameterr. &#128726; - `2 x`, output the distance between $x$ and $y$, where $y$ is the node w...
![image-20231004113212648](/predownloaded/f1 /93/f1931222a7240f19ec27593b8dcaa33b52b214a3.png)

Full text and comments »

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

45.
By Xiaohuba, 11 months ago, In English
Codeforces Global Round 30 Editorial ## A Sequence Game Idea from [user:cmk666,2025-11-06], Prepared by [user:cmk666,2025-11-06] <spoiler summary="Hint 1"> Think some straightforward necessary conditions. They are also sufficient. </spoiler> <spoiler summary="Tutorial"> [tutorial:2164A] </spoiler> ## B Even Modulo Pair Idea from [user:244mhq,2025-11-06], Prepared by [user:NetSpeed1,2025-11-06] <spoiler summary="Hint 1"> Consider a brute force solution. What's the actual complexity of it? </spoiler> <spoiler summary="Tutorial"> [tutorial:2164B] </spoiler> ## C Dungeon Idea from [user:Link_Cut_qwq,2025-11-06], Prepared by [user:Xiaohuba,2025-11-06] <spoiler summary="Hint 1"> If you gain a new sword after killing a monster, its damage will be greater or equal than the previous sword. </spoiler> <spoiler summary="Hint 2"> When will we attempt to kill monsters with $c_i = 0$? </spoiler> <spoiler summary="Hint 3"> Consider a greedy approach. </spoiler> <spoiler summ...
## F1/F2 Chain Prefix Rank

Full text and comments »

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

46.
By Acko, history, 6 years ago, In English
Mirror of Bubble Cup 13 Finals on Codeforces Hello, Codeforces! Hope you're all safe and well. [Microsoft Development Center Serbia](https://www.microsoft.com/sr-latn-rs/mdcs) is thrilled to announce the finals of the **13th edition of Bubble Cup competition**! Bubble Cup is an international, **ACM-style team contest** aimed at university and high school students. ![ ](/predownloaded/a2/f1/a2f1a7104558c3ac1e556158b2c033281f915b5c.png) Contest will take place on [Sunday, 4th of October at 11AM CEST](https://www.timeanddate.com/worldclock/fixedtime.html?msg=Bubble+Cup+13+Finals&iso=20201004T11&p1=35&ah=3), virtually. Live results will be available on the official Bubble Cup website (results will be frozen during the last 45 minutes of the competition). Winners will be announced at the closing ceremony. You can find more info on the [BubbleCup website](https://www.bubblecup.org/). Just like the previous editions, this final will be followed by an online mirror competition on Codeforces. Mirror will take place on [Mon...
![ ](/predownloaded/a2/f1/a2f1a7104558c3ac1e556158b2c033281f915b5c.png)

Full text and comments »

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

47.
By Flamire, history, 2 years ago, In English
EPIC Institute of Technology Round August 2024 (Div. 1 + Div. 2) Editorial [2002A &mdash; Distanced Coloring](https://codeforces.me/contest/2002/problem/A) idea & solution: [user:xcyle,2024-08-12] <spoiler summary="Hint 1"> Consider the case with $n=m=k$. </spoiler> <spoiler summary="Hint 2"> Generalize the solution for all $n,m,k$. </spoiler> <spoiler summary="Tutorial"> It can be shown that for any $k\times k$ subgrid, the colors we use must be pairwise distinct. Thus, we have an lower bound of $\min(n,k)\cdot\min(m,k)$. We can show that this lower bound is indeed achievable by coloring the upper-left $\min(n,k)\cdot\min(m,k)$ subgrid with distinct colors, and copy-pasting it to fill the rest of the grid. Time complexity: $O(1)$. </spoiler> <spoiler summary="Solution"> ~~~~~ #include <bits/stdc++.h> using namespace std; int t, n, m, k; int main() { scanf("%d", &t); while (t--) { scanf("%d%d%d", &n, &m, &k); printf("%d\n", min(n, k)*min(m, k)); } return 0; } ~~~~~ </spoiler> [2...
Try generalizing the solution of F1. , We generalize the solution in F1. Let $p$ be the largest prime $\le m, [2002F1 — Court Blue (Easy Version)](https://codeforces.me/contest/2002/problem/F1)

Full text and comments »

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

48.
By Christine-, history, 3 months ago, In English
Codeforces rating deflation <div align="right"> <table> <tr> <td align="left"><em> &mdash; You know what they call an International Grandmaster in 2026?<br> &mdash; They don't call it an International Grandmaster?<br> &mdash; No, man, they got the AI there, they wouldn't know what International Grandmaster is.<br> &mdash; What'd they call it?<br> &mdash; They call it International Master. </em></td> </tr> </table> </div> ### Introduction There was a heated discussion recently, and I decided to quantify the rating deflation over the recent 1.5 years. After accounting for natural improvement, I found roughly 150-190 rating points of deflation. The following is the rating gap between AI period and pre-AI period. ![Codeforces rating deflation](/predownloaded/f1/e2/f1e24c6c9cec1abfe4ba887e365f6ae049260df9.png) ### Background - We need to estimate the recent rating dynamics and compare it with pre-AI dynamics. - Participants have natural improvement when they train, especially lower rated...
![Codeforces rating deflation](/predownloaded/f1 /e2/f1e24c6c9cec1abfe4ba887e365f6ae049260df9.png)

Full text and comments »

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

49.
By AkiLotus, history, 7 years ago, In English
Codeforces Round #554 (Div. 2) Editorial [problem:1152A] ------------------ Author: [user:xuanquang1999,2019-04-24] Development: [user:xuanquang1999,2019-04-24], [user:Akikaze,2019-04-24], [user:GreenGrape,2019-04-24] Theme development: [user:Akikaze,2019-04-24], [user:GreenGrape,2019-04-24] Editorialist: [user:xuanquang1999,2019-04-24] <spoiler summary="Tutorial"> [tutorial:1152A] </spoiler> <spoiler summary="Solution (xuanquang1999)"> Submission link: [submission:53259456] <spoiler summary="Source code in plain text"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main(int argc, char* argv[]) { int n, m; scanf("%d%d", &n, &m); vector<int> a(n), b(m); for(int i = 0; i < n; ++i) scanf("%d", &a[i]); for(int i = 0; i < m; ++i) scanf("%d", &b[i]); int c0 = 0, c1 = 0; for(int i = 0; i < n; ++i) if (a[i]%2 == 0) ++c0; else ++c1; int k0 = 0, k1 = 0; for(int i = 0; i < m; ++i...
Submission link: [submission:53260139], [tutorial:1152F1]

Full text and comments »

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

50.
By AkiLotus, history, 7 years ago, In English
Codeforces Round #554 (Div. 2) Once again, **TREMBLE BEFORE THE MIGHTY OMEGALULRIPGRAPE.** ![ ](https://i.imgur.com/kpS7NEq.png) ![ ](https://i.imgur.com/A2dF7M2.jpg) *(He last walked the Earth in round [538](https://codeforces.me/blog/entry/65033) btw.)* Hello Codeforces! We are here to invite you to Codeforces Round #554 (Div. 2), which will take place at [contest_time:1152]. The round will be rated for all Division 2 participants **(with rating less than 2100)**, yet any Division 1 participants are welcome to join us out of competition. The round will be cat themed. Raise your paws and prepare your catnips! *(Or even cat memes, while you're at it).* You will be given **6+1** problems ( **6** problems, one of them has **2** subtasks ) to solve in **2 hours.** The round's problems were prepared by Xuan-Quang ~xuanquang1999,2019-04-23 D. Nguyen, Duy-Bach ~Akikaze,2019-04-23 Le, Stefan ~stefdasca,2019-04-23 Dascalescu, Quang-Minh ~MofK,2019-04-23 D. Nguyen and our dear Codeforces coordinator ...
participants solved F1+F2, too bad she didn't solve E :<) 10. [user:_wxw_,2019-04-24], ] 9. [user:FluffyT,2019-04-24] (the only official participants solved F1+F2, too bad she didn't solve

Full text and comments »

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

51.
By BucketPotato, history, 2 years ago, In English
California Informatics Competition (CALICO) Spring '24 ![ ](/predownloaded/f1/9a/f19ab0ba793a4707722850061317caa25b635ba4.png) **Edit: Registrations have been extended! They will now close 4/26 at midnight PT! Register while you still can!** Hello Codeforces! We are excited to invite you to compete in CALICO Spring '24! The contest starts [Saturday, April 27, 2024 at 4:00 p.m. PT](https://timeanddate.com/s/43cu) and will be 3 hours long. **Registrations are now open** and will be until April 26, 2024 at 11:59 p.m. PT, so [register here while you can](https://calico.cs.berkeley.edu/register/)! The contest will take place on our [custom judge platform](https://calicojudge.com/) and for the first time, contestants can compete **online or in-person at UC Berkeley**! #### In-Person Contest (New!) The CALICO team is proud to announce our **first in-person contest ever**—that's right, CALICO will be happening **LIVE** at UC Berkeley! We’ll be providing in-person contestants with exclusive merch, dinner, and opening/closing ceremoni...
![ ](/predownloaded/f1/9a/f19ab0ba793a4707722850061317caa25b635ba4.png)

Full text and comments »

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

52.
By Edvard, history, 10 years ago, translation, In English
Editorial of Educational Codeforces Round 11 ### [problem:660A] The problem was suggested by Ali Ibrahim [user:New_Horizons,2016-04-09]. Note that we should insert some number between any adjacent not co-prime elements. On other hand we always can insert the number $1$. <spoiler summary="С++ solution"> ~~~~~ const int N = 1010; int n, a[N]; bool read() { if (!(cin >> n)) return false; forn(i, n) assert(scanf("%d", &a[i]) == 1); return true; } void solve() { function<int(int, int)> gcd = [&](int a, int b) { return !a ? b : gcd(b % a, a); }; vector<int> ans; forn(i, n) { ans.pb(a[i]); if (i + 1 < n && gcd(a[i], a[i + 1]) > 1) ans.pb(1); } cout << sz(ans) - n << endl; forn(i, sz(ans)) { if (i) putchar(' '); printf("%d", ans[i]); } puts(""); } ~~~~~ </spoiler> Complexity: $O(nlogn)$. ### [problem:660B] The problem was suggested by Srikanth Bhat [user:srikkbhat,2016-04-09]. In this problem you should simply do what was written in the problem sta...
is_middle_needed(f1, f2, f3)`. You may check that numbers calculated there do fit in `long long, // where is the intersection of f1 and f2? // f1.a * x + f1.b = f2.a * x + f2.b // x * (f2.a, bool is_middle_needed(const Fun & f1, const Fun & f2, const Fun & f3) { // we ask if for at least

Full text and comments »

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

53.
By awoo, history, 7 years ago, translation, In English
Educational Codeforces Round 83 Editorial [problem:1312A] Idea: [user:BledDest,2020-03-10] <spoiler summary="Tutorial"> [tutorial:1312A] </spoiler> <spoiler summary="Solution (vovuh)"> ~~~~~ for i in range(int(input())): n, m = map(int, input().split()) print('YES' if n % m == 0 else 'NO') ~~~~~ </spoiler> [problem:1312B] Idea: [user:Roms,2020-03-10] <spoiler summary="Tutorial"> [tutorial:1312B] </spoiler> <spoiler summary="Solution (Roms)"> ~~~~~ for t in range(int(input())): n = input() print(*sorted(map(int, input().split()))[::-1]) ~~~~~ </spoiler> [problem:1312C] Idea: [user:adedalic,2020-03-10] <spoiler summary="Tutorial"> [tutorial:1312C] </spoiler> <spoiler summary="Solution 1 (adedalic)"> ~~~~~ fun main() { val T = readLine()!!.toInt() testCases@for (tc in 1..T) { val (_, k) = readLine()!!.split(' ').map { it.toLong() } val a = readLine()!!.split(' ').map { it.toLong() }.toLongArray() var maxPower ...
state go(state s) { int f1 = mex({s[0][K - x], s[1][K - y], s[2][K - z]}); int f2 = mex

Full text and comments »

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

54.
By FelixArg, history, 2 years ago, translation, In English
Codeforces Round 955 (Div. 2, with prizes from NEAR!) Editorial Thank you for participating! I hope you enjoyed the tasks. One of the testers ([user:redpanda,2024-06-25]) did a wonderful [video analysis](https://youtu.be/-btzjr-u4dM) tasks A-C, I highly recommend watching it. [problem:1982A] <spoiler summary="Tutorial"> [tutorial:1982A] </spoiler> <spoiler summary="Solution (74TrAkToR)"> ~~~~~ t = int(input()) for T in range(t): la, lb = map(int, input().split()) ra, rb = map(int, input().split()) if la > lb: la, lb, ra, rb = lb, la, rb, ra if la < lb and rb < ra: print("NO") else: print("YES") ~~~~~ </spoiler> [problem:1982B] <spoiler summary="Tutorial"> [tutorial:1982B] </spoiler> <spoiler summary="Solution (FelixArg)"> ~~~~~ #include <bits/stdc++.h> using namespace std; void solve(){ long long x, y, k; cin >> x >> y >> k; while (k > 0 && x != 1) { long long ost = (x / y + 1) * y - x; ost = max(1ll, ost); ost = min(ost, k); x...
mem[{n, k}]; } } auto [f1, s1, e1] = calc(mid, k); auto [f2, s2, e2] = calc(n - mid, k - 1, ({n, k})){ return mem[{n, k}]; } } auto [f1, s1, e1] = calc(mid, k); auto [f2, s2, e2, [{n, k}]; } } auto [f1, s1, e1] = calc(mid, k); auto [f2, s2, e2] = calc(n - mid, k - 1);, int sub1 = (e1 % MOD) * ((e1 + 1) % MOD) % MOD * 500000004 % MOD; f1 = (f1 * 1ll - sub1 + MOD, long long p = (e1 + s2) % MOD; int f_cur = (f1 * 1ll + f2 + (p * 1ll * ((p + 1) % MOD) % MOD

Full text and comments »

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

55.
By nifeshe, 20 months ago, In English
Codeforces Round #997 (Div. 2) Editorial <spoiler summary = "Rating predictions"> | | A | B | C | D | E | F1 | F2 | |----------------------|------|-----------|---------|------|------|------|---------------| | [user:nifeshe,2025-01-17] | 800 | 1200 | 1400 | 2000 | 2200 | 2700 | 2800 | | [user:Intellegent,2025-01-17] | 800 | 1200 | 1600 | 2000 | 2300 | | | | [user:mwen,2025-01-17] | 800 | 1200 | 1300 | 1800 | 2300 | | | | [user:Markadiusz,2025-01-17] | 800 | 1100 | 1300 | 1800 | 2300 | 2500 | 2800 | | [user:_istil,2025-01-17] | 800 | | [1600, 2000] | 2000 | | 2400 | 2700 | | [user:hazzlek,2025-01-17] | 1000 | 1200 | 1500 | 2000 | 2100 | | | | [user:iLoveIOI,2025-01-17] | 800 | 1100 | 1600 | 2000 | 2400 | | | | [user:A_G,2025-01-17] | 800 | 1100 ...
```cpp #include , | E | F1 | F2

Full text and comments »

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

56.
By Serval, 18 months ago, In English
Codeforces Round #1011 (Div. 2) Editorial <spoiler summary="Fun Fact 0"> [Attention is all you need](https://arxiv.org/abs/1706.03762). </spoiler> <spoiler summary="Fun Fact 1"> The current problems are the original A A B C D E, respectively. </spoiler> <spoiler summary="Fun Fact 2"> The idea for problem D came up after eating at Sushiro, and the idea for problem E came up after eating at McDonald's. However, Sushiro is not a buffet restaurant. :( </spoiler> <spoiler summary="Fun Fact 3"> The intended solutions are short. </spoiler> <spoiler summary="Fun Fact 4"> Some (very) strong testers couldn't solve E when testing, and that's why we gave E so much score. </spoiler> <spoiler summary="Fun Fact suggested by testers"> ![...](/predownloaded/61/a0/61a03f0e26b325e41dd12a2aa483b30b9e9e7c30.png) </spoiler> #### [problem:2085A] <spoiler summary="Hint 1"> When $s$ is lexicographically equal to or greater than the reversal of $s$, is it possible to make $s$ *universal* by performing the operations? ...
Optimizing the solution of F1 using (possibly, heavy) data structures

Full text and comments »

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

57.
By awoo, history, 3 years ago, In English
Educational Codeforces Round 154 Editorial [problem:1861A] Idea: [user:BledDest,2023-09-01] <spoiler summary="Tutorial"> [tutorial:1861A] </spoiler> <spoiler summary="Solution (BledDest)"> ~~~~~ #include<bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for(int i = 0; i < t; i++) { string s; cin >> s; if(s.find("1") < s.find("3")) cout << 13; else cout << 31; cout << endl; } } ~~~~~ </spoiler> [problem:1861B] Idea: [user:Roms,2023-09-01] <spoiler summary="Tutorial"> [tutorial:1861B] </spoiler> <spoiler summary="Solution (Roms)"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int tc = 0; tc < t; ++tc) { string a, b; cin >> a >> b; bool ok = false; for (int i = 0; i + 1 < a.size(); ++i) { if (a[i] == b[i] && a[i] == '0' && a[i + 1] == b[i + 1] && a[i + 1] == '1') { ok = true; } } ...
= max_x[mask][i]; pair f1 = {suits, incoming}; aux[0] = aux[0] + f1; aux, f1 = {suits, incoming}; aux[0] = aux[0] + f1; aux[x + 1] = aux[x + 1

Full text and comments »

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

58.
By asdasdqwer, 2 years ago, In English
[Tutorial] Rotating calipers technique and its applications Hello Codeforces, Before we start: Thanks to [user:bashkort,2024-09-16] for hosting this year's [Codeforces Month of Blog Posts Challenge](https://codeforces.me/blog/entry/133806) and giving me some motivation to actually finish this series. This blog is going to be about the rotating calipers technique. Apparently, it's a basic technique that can be used to solve various problems on convex polygons, however, I couldn't find a codeforces blog about it, so I just decided to write one. ### General idea behind the algorithm For the following, we are going to assume that $P$ is a convex polygon in the 2D plane with a non-negative area. Furthermore, we are going to assume that no three points of the polygon are collinear, meaning that the angle at each vertex of the polygon is smaller than $180^{\circ}$. We call a line $l$ a _line of support_ if it intersects the boundary of the polygon, but not its interior. Suppose that we have two parallel lines of support, $l_1$ and $l_2$...

Full text and comments »

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

59.
By MathModel, history, 11 months ago, In English
Codeforces Round 1061 (Div. 2) Editorial ### Thank you for participating ! Special Thanks to [user:hxu10,2025-10-24] for giving me the chance to write the editorial and for [user:maomao90,2025-10-24] for enhancing the editorial !. Editorial of Problems E and F are written by hxu10, and the rest are written by me. I hope they're insightful and concise, please let me hear your opinion about it or any feedback in general &#128153;. #### [problem:2156A] <spoiler summary="Hints"> <spoiler summary="Hint 1"> Since $m_1 \le m_2$, the total number of slices Alice ate is always at least as much as the total number of slices Bob ate. What's optimal construction ? </spoiler> <spoiler summary="Hint 2"> We want to try to minimize the difference between the total number of slices Alice ate and the total number of slices Bob ate. </spoiler> <spoiler summary="Hint 3"> The optimal construction is to let both $m_1$ and $m_2$ to be equals to one. The sequence of operations, denoted by $(m_1, m...
subtask (F1)., **You should Read Editorial of F1 First**

Full text and comments »

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

60.
By aryanc403, 3 months ago, In English
Very detailed (text+video) editorial for Codeforces Round 1103 The full editorial video for [contest:2236] is [now available here](https://youtu.be/Y91ChDX4apQ) &mdash; over 3 hours of problem discussions and solutions. Enjoy! I'll update this blog later with submission links and video timestamps. For now, I'm exhausted after finishing this video editorial. Problems are discussed in the following order: A → B → C → D → E → F1 → F2 → G. --- [problem:2236A] <spoiler summary="Hint 1"> What is the smallest possible final height that all towers can reach? </spoiler> <spoiler summary="Hint 2"> Remember that every tower must receive a strictly positive increment. </spoiler> <spoiler summary="Hint 3"> If the tallest tower has height mx, can the final height be mx? </spoiler> <spoiler summary="Hint 4"> Try making every tower equal to mx+1. </spoiler> <spoiler summary="Hint 5"> For a tower of height h[i], how much do we need to add? </spoiler> <spoiler summary="Hint 6"> The answer is determined by the tower requiri...
Since K = 1 in F1, the condition becomes:, Problems are discussed in the following order: A → B → C → D → E → F1 → F2 → G.

Full text and comments »

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

61.
By fcspartakm, history, 11 years ago, translation, In English
Testlib and Polygon Updates (June, 2015) Hello, Codeforces! Previously, my contribution to the development of Codeforces was limited only by rounds preparation ([contest:508], [contest:518], [contest:525]). But a month ago, I joined the wonderful Codeforces team led by Mike Mirzayanov ([user:MikeMirzayanov,2015-06-29]). Traditionally, to understand all the niceties of this project, my work begun from Polygon system. I would like to tell you about its changes. [Polygon](https://polygon.codeforces.com/) is a system for the preparation of programming problems. All Codeforces rounds and many other olympiads prepared in Polygon. Everyone at any time can use this system. To edit the files in Polygon now used [Ace Editor](http://ace.c9.io/). It has a nice looking syntax highlighting and autocompletion (you have to press Ctrl + Space). Soon planned to implement this editor in Codeforces. ![ ](http://codeforces.me/predownloaded/33/e9/33e9c5c863282cf8646ed4fa060867f2e5275a89.png) [cut] <br/> Unfortunately, [Ace Edito...
![ ](http://codeforces.me/predownloaded/19/f1 /19f166a722845012e4b90b8294ed230e8973e482.png)

Full text and comments »

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

62.
By GlowCheese, 2 years ago, In English
Editorial of Codeforces Round 963 (Div. 2) [problem:1993A] <spoiler summary="Hint"> What is the pattern of Tim's answer sheet that can give him maximum score? </spoiler> <spoiler summary="Solution"> Let's say there are $n$ problems take $A$ as the answer, therefore he can only get $n$ points with the answer $A$. The same is correct for $B$, $C$ and $D$. Therefore, the maximum score can be achieved is $min(n, A) + min(n, B) + min(n, C) + min(n, D)$. Time complexity: $O(4n)$ </spoiler> <spoiler summary="Code (python)"> ~~~~~ t = int(input()) for _ in range(t): n = int(input()) s = input() print(sum(min(n, s.count(c)) for c in "ABCD")) ~~~~~ </spoiler> [problem:1993B] <spoiler summary="Hint 1"> Find a way to make all the elements even. Then odd. </spoiler> <spoiler summary="Hint 2"> In the worst case, the number of operations required is the number of even elements + 1. Why? </spoiler> <spoiler summary="Solution"> First, if all elements already have the same parity, we don'...
The idea of this version is almost the same as F1: counting the

Full text and comments »

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

63.
By Intellegent, 11 months ago, In English
Codeforces Round 1060 (Div. 2) Editorial Thank you for participating! Special thanks to [user:reirugan,2025-10-16] for writing the analysis for **B, D, E** and to [user:Proof_by_QED,2025-10-16] and [user:LMeyling,2025-10-16] for helping to optimise **F1**, leading to the creation of **F2**. <spoiler summary="Rating Predictions"> | Problem | A | B | C1 | C2 | D | E | F1 | F2 | | :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | ---: | | [user:reirugan,2025-10-19] | 800 | 1100 | 1200 | 1600 | 1700 | 2000 | 2200 | ¯\\_(ツ)_/¯ | | [user:eric899,2025-10-19] | 800 | 1000 | 1300 | ¯\\_(ツ)_/¯ | 1600 | ¯\\_(ツ)_/¯ | ¯\\_(ツ)_/¯ | ¯\\_(ツ)_/¯ | | [user:Proof_by_QED,2025-10-19] | 800 | 1100 | 1500 | 1900 | 1600 | 2100 | 2300 | 2600 | | [user:_istil,2025-10-19] | 800 | 1100 | 1400 | 1800 | 1800 | 2100 | 2000 | 2500 | | [user:anango,2025-10-19] | 800 | 1100 | 1300 | 1900 | 1800 | 2200 | 2400 | 2700 | | [user:FzArK,2025-10-19] | 800 | 1100 | 1400 | 1800 | 1900 | ¯\\_(ツ)_/¯ | 2400 | ¯\\_(ツ)_/¯ | | [user:intel...
[user:Proof_by_QED,2025-10-16] and [user:LMeyling,2025-10-16] for helping to optimise **F1**, leading to, | Problem | A | B | C1 | C2 | D | E | F1 | F2

Full text and comments »

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

64.
By canine, history, 2 years ago, In English
yet another CP extension for VSCode hello all -- if you happen to be in the market for a new competitive programming extension and use VSCode, may i humbly suggest my new [extension](https://purduecpu.com/extension)? i think it is relatively feature complete, but it's still in alpha (especially for languages other than C++) and may have some kinks that need working out. it theoretically supports C++, Java, Python, and Rust (and it's very easy to add more). i created this because i was dissatisfied that most existing solutions can't import a bunch of test cases from a directory then run them in parallel. i also believe it has a cooler UI than other extensions. as usual, i didn't think it would take this long when i started... if you encounter any difficulties, please let me know on [github](https://github.com/canislupaster/cpu-vscode). **thanks for taking a look!** ![hero image](/predownloaded/f1/90/f190d6993497b2e6a93a505706e36189f5fd0200.jpg) ### Realtime Input/Output unlike other test runners for VSCode, w...
![hero image](/predownloaded/f1/90/f190d6993497b2e6a93a505706e36189f5fd0200.jpg), /canislupaster/cpu-vscode). **thanks for taking a look!** ![hero image](/predownloaded/f1/90

Full text and comments »

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

65.
By BucketPotato, 23 months ago, In English
California Informatics Competition (CALICO) Fall '24 ![ ](/predownloaded/f1/9a/f19ab0ba793a4707722850061317caa25b635ba4.png) Hello Codeforces! We're excited to invite you to CALICO Fall '24! The contest will begin [Saturday, November 16, 2024 at 4:00 p.m. PT](https://timeanddate.com/s/44ff) and is 3 hours long. **Registrations are now open** and will be until November 13, 2024 at 11:59 p.m. PT, so please [register here](https://calico.cs.berkeley.edu/register/) as soon as you can! The contest will take place on our [custom judge platform](https://calicojudge.com/) and contestants can compete **online or in-person at UC Berkeley**! #### About The California Informatics Competition (CALICO) is a semiannual team programming contest organized by students at the University of California, Berkeley. We create original problems to help students grow their problem-solving skills and learn algorithms in fun and exciting ways. Check out our [website](https://calico.cs.berkeley.edu/) to learn more about the contest and join our [discord ...
![ ](/predownloaded/f1/9a/f19ab0ba793a4707722850061317caa25b635ba4.png)

Full text and comments »

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

66.
By vovuh, history, 7 years ago, In English
Codeforces Round #575 (Div. 3) Editorial [problem:1196A] Idea: [user:MikeMirzayanov,2019-07-24] <spoiler summary="Tutorial"> [tutorial:1196A] </spoiler> <spoiler summary="Solution"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { #ifdef _DEBUG freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); #endif int q; cin >> q; for (int i = 0; i < q; ++i) { long long a, b, c; cin >> a >> b >> c; cout << (a + b + c) / 2 << endl; } return 0; } ~~~~~ </spoiler> [problem:1196B] Idea: [user:Vovuh,2019-07-24] <spoiler summary="Tutorial"> [tutorial:1196B] </spoiler> <spoiler summary="Solution"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { #ifdef _DEBUG freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); #endif int q; cin >> q; for (int i = 0; i < q; ++i) { int n, k; cin >> n >> k; vector<int> a(n); int cntodd = 0; for (int j = 0; j < n; ++j) { cin >>...
= MAXC; while (n--) { int x, y, f1, f2, f3, f4; cin >> x >> y >> f1, --) { int x, y, f1, f2, f3, f4; cin >> x >> y >> f1 >> f2 >> f3 >> f4; if, ; while (n--) { int x, y, f1, f2, f3, f4; cin >> x >> y >> f1 >> f2 >> f3

Full text and comments »

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

67.
By wuhudsm, history, 14 months ago, In English
Codeforces Round 1040 (Div. 1, Div. 2) Editorial Thank you for participation and we hope you enjoy this round :) <spoiler summary="How did you find the contest?"> - Great: - Good: - Average: - Bad: - Trash: </spoiler> <spoiler summary="Which problem is your most favourite?"> - D2A: - D2B: - D1A: - D1B: - D1C1: - D1C2: - D1C3: - D1D: - D1E: - D1F1: - D1F2: </spoiler> <spoiler summary="Which problem you hate the most?"> - D2A: - D2B: - D1A: - D1B: - D1C1: - D1C2: - D1C3: [likes:favorite,2039E3_...
#### [D1F1 Top-K Tracker (Easy Version)](https://codeforces.me/contest/2129/problem/F1) and [D1F2

Full text and comments »

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

68.
By wuhudsm, history, 3 years ago, In English
TheForces Round #12 (Double-Forces) Editorial [A](https://codeforces.me/gym/104329/problem/A) <spoiler summary="Editorial"> <spoiler summary="code"> ~~~~~ #include <map> #include <set> #include <cmath> #include <ctime> #include <queue> #include <stack> #include <cstdio> #include <cstdlib> #include <vector> #include <cstring> #include <algorithm> #include <iostream> using namespace std; typedef double db; typedef long long ll; typedef unsigned long long ull; const int N=1000010; const int LOGN=28; const ll TMD=0; const ll INF=2147483647; int T,n; int main() { scanf("%d",&T); while(T--) { scanf("%d",&n); if(n%6==1) { for(int i=1;i<n/6;i++) printf("0"); printf("8\n"); continue; } for(int i=1;i<=n/6;i++) printf("0"); if(n%6==2) printf("1\n"); else if(n%6==3) printf("7\n"); else if(n%6==4) printf("4\n"); else if(n%6==5) printf("2\n"); else printf("\n"); } return 0; } ~~~~~ </spoiler> If $n=6k$,print $0...0$; If $n=6k+1$,print $0....
[F1](https://codeforces.me/gym/104329/problem/F1)

Full text and comments »

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

69.
By McDic, 3 years ago, In English
Some common CP code practices which I think would be better changed Hello. After getting prize on ICPC 2020 Seoul Regional and writing Round #633, I almost stopped solving CP problems and entered quant industry. Now I have no job so I am not busy until I get next job, so I often describe my thoughts on online websites. This article is one of those. In this post, I am going to write about some common CP code practices which I think would be better changed. Before enumerating practices, I want to specify that this post is mostly focused to: 1. Who wants to get dev jobs 2. Who wants to create their practices from CP to productions without switching code style too much (i.e. Not having too different mindset for coding styles in CP and real applications) If you just don't care, it's ok. I am not saying writing CP-style codes is bad, unless you believe you can use same practices on productions. Now let's dive in. ### `using namespace std;` What happens if you include big header files like `bits/stdc++.h` and do this? Bunch of functions, class...
#define f1 first #define f2 second, constexpr int N = 100005; const auto f1 = &std::pair::first; const auto f2 = &std, int main(void) { std::pair x; auto x1 = x.*f1; auto x2 = x.*f2

Full text and comments »

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

70.
By adamant, history, 3 years ago, In English
Pythagorean triples and Pell's equations Hi everyone! Recently I started solving projecteuler, and while doing so I encountered two concepts about which I heard before, but I didn't really bother to learn them. I made a few notes to myself about how they work, and thought it could be useful for somebody else too. This blog focuses on Pythagorean triples and Pell's equations, which are recurrent concepts on projecteuler. Great thanks to [user:nor,2023-05-07], [user:Endagorion,2023-05-07], [user:Golovanov399,2023-05-07] and [user:Neodym,2023-05-07] for useful discussions about these topics. [cut]<hr> #### Pythagorean triples **Pythagorean triple** is a triple $a,b,c \in \mathbb Z$ such that $$ a^2 + b^2 = c^2. $$ It is possible to parameterize them in a way that allows to find all triples such that $a,b,c \leq n$ in $O(\sqrt n)$. ##### Rational points on a unit circle To do that, let's divide the equation by $c^2$ to get $$ \left(\frac{a}{c}\right)^2 + \left(\frac{b}{c}\right)^2=1. $$ This re...

Full text and comments »

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

71.
By Wansur, history, 2 years ago, translation, In English
Codeforces Round 973 (Div. 2) Editorial [2013A &mdash; Zhan's Blender](https://codeforces.me/contest/2013/problem/A) First to solve: [user:rob00,2024-09-21] <spoiler summary="Solution"> Let's consider two cases: - If $ x \geq y $. In this case, the blender will mix $ \min(y, c) $ fruits every second (where $ c $ is the number of unmixed fruits). Therefore, the answer will be $ \lceil \frac{n}{y} \rceil $. - If $ x < y $. Here, the blender will mix $ \min(x, c) $ fruits every second. In this case, the answer will be $ \lceil \frac{n}{x} \rceil $, similarly. Thus, the final answer is $ \lceil \frac{n}{\min(x, y)} \rceil $. </spoiler> <spoiler summary="Code"> ``` #include <iostream> using namespace std; int main(){ int t = 1; cin >> t; while(t--){ int n, x, y; cin >> n >> x >> y; x = min(x, y); cout << (n + x - 1) / x << endl; } } ``` </spoiler> [2013B &mdash; Battle For Survive](https://codeforces.me/contest/2013/problem/B) First to ...
[2013F1 — Game in Tree (Easy Version)](https://codeforces.me/contest/2013/problem/F1), [2013F1 — Игра на дереве (простая версия)](https://codeforces.me/contest/2013/problem/F1)

Full text and comments »

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

72.
By BledDest, 2 years ago, In English
Kotlin Heroes 11 — Editorial This round was prepared by [user:Neon,2024-10-01], [user:adedalic,2024-10-01], [user:awoo,2024-10-01], [user:shnirelman,2024-10-01] and me. Huge thanks to all of the testers: [user:ashmelev,2024-10-01], [user:KIRIJIJI,2024-10-01], [user:PavelKunyavskiy,2024-10-01], [user:soup,2024-10-01] and [user:Fanarill,2024-10-01]! Your feedback helped us balance this contest (and find a very stupid overflow bug I'm too ashamed to mention). Thanks for participation, we hope you enjoyed the contest! [problem:2011A] Idea: [user:BledDest,2024-10-01], preparation: [user:BledDest,2024-10-01] <spoiler summary="Tutorial"> [tutorial:2011A] </spoiler> <spoiler summary="Solution (Neon)"> ~~~~~ fun main() = repeat(readln().toInt()) { readln().toInt() val a = readln().split(" ").map { it.toInt() } println(if (a.dropLast(1).contains(a.last() - 1)) a.last() - 1 else "Ambiguous") } ~~~~~ </spoiler> [problem:2011B] Idea: [user:BledDest,2024-10-01], preparation: [user:...
++cnt[f * 2 + s]; } val f1 = (cnt[0] < k && cnt[3] < k) val f2 = (cnt

Full text and comments »

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

73.
By Ecrade_, 18 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...
],F1[M],G0[M],G1[M],SF[M],SG[M]; inline ull Div(const ull&n,const ull&m){ return double(n)/m

Full text and comments »

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

74.
By AksLolCoding, history, 18 months ago, In English
My Editorials for 1011 (Div. 2) For implementations, see my submissions #A &mdash; Serval and String Theory <spoiler summary="Solution"> It is only impossible if the number of k is 0 and r is not universal, or if r consists of only one distinct character. Time complexity: $O(n)$ </spoiler> #B &mdash; Serval and Final MEX <spoiler summary="Solution"> For the MEX to be 0, we must remove all 0s from the array and then apply the operation on the whole array. We can remove all zeroes in one operation (with endpoints on the leftmost and rightmost zeroes) unless both the first and last element are 0, in which case it takes two operations. Once all zeros are removed, we can MEX the whole array resulting in 0. Time complexity: $O(n)$ </spoiler> #C &mdash; Serval and The Formula <spoiler summary="Solution"> It is always possible if x != y. WLOG, assume x>y. Note that a+b=a^b (^ is xor) if and only if the bitwise and of a and b is 0. Let M be the least power of 2 greater than or equal to x. Using k = ...
We optimize the solution for F1 above. Note that a candidate answer, #F1 — Serval and Colorful Array (Easy Version)

Full text and comments »

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

75.
By BledDest, 7 years ago, translation, In English
Codeforces Round #585 Editorial [problem:1215A] <spoiler summary="Editorial"> [tutorial:1215A] </spoiler> <spoiler summary="Solution (fcspartakm)"> ~~~~ #include <bits/stdc++.h> using namespace std; int a1, a2, k1, k2, n; inline void read() { cin >> a1 >> a2 >> k1 >> k2 >> n; } inline void solve() { if (k1 > k2) { swap(k1, k2); swap(a1, a2); } int minCnt = max(0, n &mdash; a1 * (k1 &mdash; 1) &mdash; a2 * (k2 &mdash; 1)); int maxCnt = 0; if (n <= a1 * k1) { maxCnt = n / k1; } else { maxCnt = a1 + (n &mdash; a1 * k1) / k2; } cout << minCnt << ' ' << maxCnt << endl; } int main () { #ifdef fcspartakm freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); #endif srand(time(NULL)); cerr << setprecision(10) << fixed; read(); solve(); //cerr << "TIME: " << clock() << endl; } ~~~~ </spoiler> [problem:1215B] <spoiler summary="Editorial"> [tutorial:1215B] </spoiler> <spoiler summary="...
+ 1, y * 2 + 1); } for(int i = 2; i <= M - 1; i++) { int f1 = i - 2 + p; int f2 =f1, ++) { int f1 = i - 2 + p; int f2 = f1 + 1; add_disjunction(f1 * 2, f2 * 2 + 1); } if

Full text and comments »

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

76.
By __baozii__, history, 6 months ago, In English
Codeforces Round 1087 (Div. 2) Editorial We hope you enjoyed the problems! <spoiler summary="Rate the contest!"> <spoiler summary="Quality"> - Excellent contest - Good contest - Average contest - Bad contest - Horrible contest </spoiler> <spoiler summary="Difficulty"> - Trivial contest - Easy contest - Average contest - Hard contest - Impossible contest </spoiler> </spoiler> [problem:2209A] - Idea: [user:OtterZ,2026-03-21] - Solution: [user:OtterZ,2026-03-21] - Editorial: [user:OtterZ,2026-03-21] <spoiler summary="Solution"> [tutorial:2209A] </spoiler> <spoiler summary="Code (C++)"> ~~~~~ #include<bits/stdc++.h> using namespace std; int n,a[109],k; long long C; int main(){ int t; scanf("%d",&t); while(t--){ scanf("%d %lld %d",&n,&C,&k); for(int i = 1; i <= n; i ++){ ...
> using namespace std; int n,a[5009],bcnt,f1[5009],f2[5009]; int main(){ int t; scanf("%d",&t, ],bcnt,f1[5009],f2[5009]; int main(){ int t; scanf("%d",&t); while(t--){ scanf("%d",&n

Full text and comments »

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

77.
By Chmel_Tolstiy, 5 years ago, In English
Yandex.Cup 2021 Algorithm Qualification Round Editorial Problemset was prepared by Yandex employees. [Problem А. ZeroOne](https://contest.yandex.ru/contest/29878/problems/A/) ------------------ Firstly, let's convert input strings into two binary strings. Because the numbers can be approximately $2^{333}$ we shouldn't convert them into the numeric type and should compare their string representations <spoiler summary="C++ implementation example:"> ~~~~~ #include <iostream> #include <algorithm> int main() { std::string s[2]; std::cin >> s[0] >> s[1]; std::string r[2]; for(int i = 0; i < 2; ++i) { while (!s[i].empty()) { if (s[i].substr(s[i].size() - 3, 3) == "one") { s[i].pop_back(); s[i].pop_back(); s[i].pop_back(); r[i] += "1"; } else { s[i].pop_back(); s[i].pop_back(); s[i].pop_back(); s[i].pop_back(); r[i] += "...
// case 1 auto f1 = [](const int64_t a, const int64_t b) -> int64_t { // a + (a-1) + ... + (a

Full text and comments »

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

78.
By zscoder, history, 7 years ago, In English
Valentine's Day Contest 2020 Editorial I hope you enjoyed the contest! Expected problem difficulty is F < A < (G ~ D) < (C ~ E) < B (though it might be different for different people). I will mainly focus on explaining the full solution to the problems but I will briefly mention how to pass certain subtasks. ### Problem A &mdash; Leakage <spoiler summary="Solution"> This is unfortunately the most standard problem of the set. Obviously, we can model the friends as vertices and friendships as edges in an undirected graph. The problem basically asks us to answer queries of the form: "For a pair of vertices $u, v$, find the number of vertices $w \neq u, v$ such that removing $w$ from the graph disconnects $u$ and $v$". Removing vertices and disconnecting graphs should remind one of articulation points. The data structure to solve this problem is [block-cut tree](https://en.wikipedia.org/wiki/Biconnected_component#Block-cut_tree). Each biconnected component is considered as a block. An articulation point might be...
-1].pb({{l-1,i},-1}); } Fenwick f1(n+10); Fenwick f2(n+10); sort(dsrt.rbegin(),dsrt.rend

Full text and comments »

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

79.
By chromate00, 20 months ago, In English
Codeforces Round 1000 (Div. 2) — Editorial <spoiler summary="Rating Predictions"> | Handles | A | B | C | D | E | F1 | F2 | | ---------------- | --- | ---- | ----------- | ----------- | ----------- | ---- | ----------- | | ~Proof_by_QED,2025-01-20 | 800 | 1000 | 1500 | 2200 | 2400 | 1800 | 2600 | | ~chromate00,2025-01-20 | 800 | 1100 | 1500 | 2100 | 2300 | 1800 | 2700 | | ~redpanda,2025-01-20 | 800 | 900 | 1400 | 2000 | 2400 | | | | ~larush,2025-01-20 | 800 | 1100 | 1600 | 2100 | | | | | ~FairyWinx,2025-01-20 | 800 | 900 | 1500 | 2000 | 2400 | 1800 | 2500 | | [user:priyanshu.p,2025-01-20] | 800 | 1200 | 1500 | 2000 | 2500 | 2000 | | | ~Intellegent,2025-01-20 | 800 | 1000 | 1400 | 2000 | 2200 | 2000 | 260...
to read every problem, almost every tester thought F1 is easy if you read it well..., | E | F1 | F2

Full text and comments »

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

80.
By Joyemang, history, 6 months ago, In English
California Informatics Competition (CALICO) Spring '26 ![ ](/predownloaded/f1/9a/f19ab0ba793a4707722850061317caa25b635ba4.png) Hello Codeforces! We are excited to invite you to compete in CALICO Spring '26! The contest starts [Saturday, April 11, 2026 at 4:00 p.m. PT](https://www.timeanddate.com/worldclock/fixedtime.html?msg=CALICO+Spring+%2726&iso=20260411T16&p1=791&ah=3) and will be 3 hours long. **Registrations are now open** and will be until April 4th, 2026 at 11:59 p.m. PT, so [register here while you can](https://calico.cs.berkeley.edu/register/)! The contest will take place on our [custom judge platform](https://calicojudge.com/) and contestants can choose to compete either **online or in-person at UC Berkeley**! #### In-Person Contest The CALICO team is proud to announce the return of our **in-person contest**! Come compete **LIVE** at the **UC Berkeley campus**, learn from guest speakers, and meet the team behind CALICO! Use [this link](https://forms.gle/G2HbghvgcfV9ATBZ9) to register for the in-person competition, an...
![ ](/predownloaded/f1/9a/f19ab0ba793a4707722850061317caa25b635ba4.png)

Full text and comments »

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

81.
By NBAH, history, 9 years ago, translation, In English
Codeforces Round #448(Div.2) Editorial [problem:895A] -------------- We can notice that if one of the sectors is continuous then all the remaining pieces also form a continuous sector.If angle of the first sector is equal to $x$ then difference between angles of first and second sectors is $|x - (360 - x)| = |2*x - 360| = 2*|x - 180|$. So for each possible continuous sector we can count it's angle and update answer. Time complexity $O(n^2)$ or $O(n)$. [Solution](https://ideone.com/dX19Vz) [problem:895B] -------------- First, we need to understand how to find the number of integers in $[l, r]$ segment which are divisible by $x$. It is $r/x – (l-1)/x$. After that we should sort array in ascending order. For each left boundary of the segment $l = a[i]$ we need to find minimal and maximal index of good right boundaries. All right boundaries $r = a[j]$ should satisfy the following condition $a[j]/x – (a[i]-1)/x = k$. We already know $(a[i]-1)/x$, $a[j]/x$ is increasing while $a[j]$ increases. So we can do binary...
of ways we can take odd and even amount of it from $a$. Let $f1[i]$, $f0[i]$ be that number of ways, интересует только войдет оно четное количество раз в произведение или нечетное. Пусть $f1[i]$, $f0[i]$ это, $dp[i+1][j \oplus mask[i+1]] += dp[i][j]*f1[i+1]$, $dp[i+1][j \oplus mask[i+1]]+=dp[i][j]*f1[i+1]$

Full text and comments »

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

82.
By arham_doshi, history, 6 years ago, In English
cses graph session editorial(incomplete) I got bored with solving and wanted to do something which is related to cp and also very fun so i decided to write this tutorial.bare me for my bad English . ### how to solve grid problems <spoiler summary="trick"> here is my template to solve grid problems ~~~~~ int dx[]={0,0,1,-1}; int dy[]={1,-1,0,0}; string ds="RLDU"; int n,m; bool possible(int x,int y){ //cout<<n<<" "<<m<<" "<<x<<" "<<y<<" possible"<<endl; return (x<n&&x>=0&&y<m&&y>=0); } ~~~~~ here we cand do just x+dx[i],y+dx[i] to move the four <br> directions and ds helps if we want to record path.<br> we can easily extend it to include four diagonals </spoiler> 1) counting rooms ------------------ <spoiler summary="explanation"> For each unvisited '.' cell we have to make dfs(or bfs)<br> and keep on coloring the visited nodes.We keep track number<br> of dfs by count variable .our answer would be count. </spoiler> <spoiler summary="code"> ~~~~~ void dfs(...
fn; fo(i,0,n){ fn.pb(dis[i]); } //cout<<f1<f1[n, ){ q.push({p.x+aa.y,aa.x}); dis[aa.x]=p.x+aa.y; } } } vi f1; fo(i,0,n, if(f1[aa.x]!=-1&&fn[aa.y]!=-1){ ans=min(ans,f1[aa.x]+fn[aa.y]+bb.x/2); }

Full text and comments »

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

83.
By Morphy, history, 11 years ago, In English
Codeforces Round #328 Problem Analysis Problem A. PawnChess -------------------- Player A wins if the distance of his nearest pawn to the top of the board is less than or equal to the distance of the Player’s B nearest pawn to the bottom of the board (Note that you should only consider pawns that are not blocked by another pawns). Problem B. The monster and the squirrel --------------------------------------- After drawing the rays from the first vertex $(n-2)$ triangles are formed. The subsequent rays will generate independently sub-regions in these triangles. Let's analyse the triangle determined by vertices $1, i, i+1$, after drawing the rays from vertex $i$ and $(i+1)$ the triangle will be divided into $(n-i)+(i-2)=n-2$ regions. Therefore the total number of convex regions is $(n-2)^2$ ![ ](http://codeforces.me/predownloaded/6d/e4/6de45565edfd6370e537fc6571fe84832c26446c.png) If the squirrel starts from the region that have $1$ as a vertex, then she can go through each region of triangle $(1, i, i+1)$ ...
![ ](http://codeforces.me/predownloaded/f1 /3f/f13f8b3db06e543ee55d7eb90a459a159535cc4f.png)

Full text and comments »

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

84.
By kostka, 12 years ago, In English
Hack me! (Codeforces Round #282 (Div. 1)) Aren't you tired after [contest:494]? **Did you know...** that when you will be on the list of "best hackers" of the round the row with your handle will be highlighted (if you will be logged in)? <center> <img src="http://test.weaselcrow.com/cfhacks/f1.png"> </center> Other posts can be found [here](http://codeforces.me/search?query=hackme), including [div2](http://codeforces.me/blog/entry/15150). [cut] <h3>Stats</h3> Problem | <small>Successful hacks</small> | <small>Unsuccessful hacks</small> | Other | Sum | <small>Solutions which can be hacked</small> | <small>Accepted solutions</small> | <small> All solutions on final tests</small>| :---:|:---:|:---:|:---:|:---:|:---:| <small> [problem:494A] </small> | 363 (53.23%) | 293 (42.96%)| 26 (3.81%) | 682 | 201 (23.40%) | 658 (76.60%) | 859 | <small> [problem:494B] </small> | 2 (50.00%) | 2 (50.00%)| 0 (0.00%) | 4 | 32 (8.42%) | 348 (91.58%) | 380 | <small> [problem:494C] </small> | 0 | 0 | 0 | 0 | 6 (17.14%) |...

Full text and comments »

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

85.
By flash_7, history, 9 years ago, In English
Digit DP Wrote this article a long ago but during solving a problem recently thought of sharing this article publicly. Hope it will help some contestants to understand the idea clearly. Digit dp is a very easy technique and also useful to solve many dynamic programming problems. Seeing the name “Digit DP” it’s easy to guess that we are going to do something using the digits. Yes we are actually going to play with digits. Let’s explain the concept using a classical problem. #### Problem How many numbers **x** are there in the range **a** to **b**, where the digit **d** occurs exactly **k** times in **x**? There may have several solutions including number theory or combinatorics, but let’s see how we can solve this problem using digit dp. #### Solve for range (zero to a) Using digit dp we always focus on building a number satisfying all the conditions. If we finally manage to build that number then we say, yes we have got one ;-) But how we’ll build that number? For the time being let...
information somehow so that we can use it later? Yes, using an extra parameter **f1**(true/false) in, parameter **f1** which helped us to make sure the sequence is not getting larger than **b**. Can’t we, use it later? Yes, using an extra parameter **f1**(true/false) in our function we can handle that

Full text and comments »

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

86.
By simplelife, 6 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...
FenwickTree f1, f2; vector vv(n); f1.init(n, vv); f2.init(n, vv);, auto deac = [&](int x){ ss.erase(x); f1.modify(x, 0); f2.modify(x, 0); };, for (auto [r, i] : adj[l]){ ans[i] += f2.query(l, r) - l * f1.query(l, r);, for (int i = 1; i <= n; i++){ f1.modify(i, val[i]); f2.modify(i, val[i] * i); }

Full text and comments »

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

87.
By wilcot, history, 4 years ago, In Russian
Solve Judge System Привет всем. Хочу рассказать про свою разработку &mdash; тестирующую систему Solve с открытым исходным кодом. Да, можно сказать Yet Another Online Judge :) Но не стоит сразу расходиться, у нее есть некоторые крутые моменты и может быть вам захочется поднять собственную инсталляцию для проведения какого-нибудь соревнования. Вообще, система разрабатывается уже давно, но вот почему я решил написать только сейчас. Да потому что стабильный релиз вышел совсем недавно и полноценного тестирования до этого момента не проводилось. ### Для кого этот пост 1. Для тех, кто хочет проводить соревнования по СП. 2. Для тех, кто готовит задачи преимущественно в великолепной системе Polygon. 3. Для тех, кто хочет запустить свою систему без разработки с нуля (например огранизации). 4. Для тех, кто просто интересуется. ### Зачем вообще писать еще одну систему Это самый лучший вопрос, который стоит задать. Я не буду здесь сравнивать с другими, уже существующими аналогами, скажу лишь что для...
![Положение участников](/predownloaded/6f/f1

Full text and comments »

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

88.
By __baozii__, 8 months ago, In English
Codeforces Round 1077 (Div. 1, Div. 2) Editorial We hope you enjoyed the problems! <spoiler summary="Rate the contest!"> <spoiler summary="Quality"> - Excellent contest - Good contest - Average contest - Bad contest - Horrible contest </spoiler> <spoiler summary="Difficulty"> - Trivial contest - Easy contest - Average contest - Hard contest - Impossible contest </spoiler> </spoiler> [problem:2188A] - Idea: [user:__baozii__,2026-01-29], [user:Tobo,2026-01-29] - Solution: [user:__baozii__,2026-01-29] - Editorial: [user:__baozii__,2026-01-29] <spoiler summary="Solution"> For $|p_{n-1}-p_n|$ to be divisible by $n-1$, either $p_{n-1}=1$ and $p_n=n$, or $p_{n-1}=n$ and $p_n=1$. Either way, we can construct $p$ backwards. For $i$ from $n-2$ to $1$, there will only by one possible choice for $p_i$, where $...
Construct the optimal tree by following the approach used in F1. Two

Full text and comments »

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

89.
By akcube, 2 years ago, In English
Codeforces Round #940 and CodeCraft-23 (Div. 2) Editorial [problem:1957A] ================== **Idea:** [user:keyurchd_11,2024-04-21] **Problem Setting:** [user:shakr,2024-04-21] [user:lezirtin,2024-04-21] **Editorial**: [user:shakr,2024-04-21] [user:TheRaja,2024-04-21] There were a few solutions which passes pre-tests with the assumption that $a_i \leq n$. We apologize for the pre-tests on A not including this case. <spoiler summary="Hint 1"> To create the most polygons, you should use as few sticks as possible per polygon. What polygon has the least number of sides? </spoiler> <spoiler summary="Solution"> [tutorial:1957A] </spoiler> <spoiler summary="Rate this problem"> - Great Problem - Ok Problem - Bad Problem - Didn't solve </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(101, 0);...
You can also use an idea similar to the hashing technique used in F1 to hash the segment tree nodes

Full text and comments »

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

90.
By CristianoPenaldo, history, 4 years ago, In English
My learning note on AGC061C based on Little09's (Simplified) Chinese Blog I admit that [AGC061C](https://atcoder.jp/contests/agc061/tasks/agc061_c) is too hard for me, and I don't even understand its [official editorial](https://atcoder.jp/contests/agc061/editorial/5695). Today I see a [Luogu blog](https://www.luogu.com.cn/blog/LJA001111/agc061c-first-come-first-serve) with a very genius and clear idea on this problem. I learned a lot from it, and I would like to share it to you now. The writer of this blog is possibly [user:little09,2023-02-15], but I am not quite sure. **Part1: Problem Statement and Constraints** There are $N$ customers named $1$, ..., $N$ visiting a shop. Customer $i$ arrives at time $A_i$ and leaves at time $B_i$ The queue order is first in first out, so $A_i$ and $B_i$ are both increasing. Additionally, all $A_i$ and $B_i$ are pairwise distinct. At the entrance, there's a list of visitors to put their names in. Each customer will write down their name next in the list exactly once, either when they arrive or when they leave. ...
![ ](/predownloaded/2c/f1/2cf16abdf1d82e4f6f87ee556f9e2870462f7ef2.png)

Full text and comments »

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

91.
By SPyofgame, history, 6 years ago, In English
Share exact K candies to all children with a limitation of a child can get ### Original Problem [M-candies-problem](https://atcoder.jp/contests/dp/tasks/dp_m). In this version, we need to calculate the number of ways to share **exact** $K$ candies for all $N$ children that the $ith$-child doesnt have more than $a_i$ candies. And the constraints are - $1 \leq N \leq 100$ - $0 \leq K \leq 10^5$ - $0 \leq a_i \leq K$ <spoiler summary="O(n * k^2) solution - Standard DP"> Lets $DP[i][j] =$ number of ways to share first $[i]$ children with $[j]$ used candies - Base case $(DP[0][0] = 1)$ and $(DP[0][x] = 0\ \forall\ x > 0)$ and ($DP[p][x] = 0\ \forall\ x < 0$) - At state $[i][j]$, you can share to the $[i]$ child $(0 \leq x \leq a_i)$ candies with $(DP[i - 1][j - x])$ ways to share So we have $DP[i][j] = \underset{x = 0..a_i}{Sigma}(DP[i - 1][j - x])$ And the answer is $DP[n][k]$ ```cpp #include <iostream> #include <vector> using namespace std; const int MOD = 1e9 + 7; void quickadd(int &res, int val) { if ((res += val) >...
* f1((n + 0) / 6) * f1((n + 1) / 1) % MOD * f1((n + 2) / 1) % MOD; if (t == 5) return 1LL *f1((n, /// Sigma(i = 1..n) (1) int f1(ll n) { return n % MOD; } /// Sigma(i = 1..n) f1 (i) int f2(ll n, ) { solve2(y, z, x) } /// = Sigma(x = L..R) { f1(max(0, x - y), min(z, x, ); return (f2(l, y - 1) + y * f1(t, r)) % MOD; } /// sigma(i=l..r) i * min(i, y) int g3(ll l, , y) /// = f2(l, y-1) + f1(t, r) * y int g2(ll l, ll r, ll y) { minimize(y, /// Sigma(i = 1..n) f1(i) int f2(ll n) { int t = abs(n) % 2; if (t == 0) return 1LL, /// f1(l, r) = sigma(i=l..r) (1) /// f2(l, r) = sigma(i=l..r) (i) /// f3(l, r) = sigma(i, /// f1(n) = sigma(i=1..n) (1) = n /// f2(n) = sigma(i=1..n) (i) = n * (n + 1) / 2 /// f3, ```cpp /// Sigma(i = 1..n) (1) int f1(ll n) { return n % MOD; }, int f1(ll l, ll r) { return (l < 0 || l > r) ? 0 : fix(f1(r) - f1(l - 1)); } /// sigma(i=l..r, ll X = max(L, x), Y = max(L, y); int res = 0; quickadd(res, fix(0LL + f1(L, R) * (1 - k

Full text and comments »

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

92.
By wilcot, 10 years ago, In Russian
Белорусская областная олимпиада 2017 С 9 по 12 января 2017 года будет проходить областная олимпиада по информатике. Первый тур олимпиады состоится 10 января, второй &mdash; на следующий день. Постараюсь разместить здесь условия и решения задач как можно скорее, естественно не раньше начала самих туров :) В комментариях предлагаю обсудить задачи, поделиться идеями по поводу их решения, мыслями... _Всем участникам желаю удачи!_ **UPD.** Первый тур завершен. Ниже можно почитать, как же получить полные баллы по задачам. **UPD2.** Второй тур тоже завершен. Можно почитать разбор, кроме последней задачи &mdash; я ее не решал, да и решений можно придумать множество. [cut]  ### Первый тур [Условия задач](https://yadi.sk/d/fuyYc0xz38FnHs) #### Задача 1 Отсортируем пары $(a_i, b_i)$ по возрастанию $a_i$. Возьмем первые $K$ подарков. Сложность решения: $O(N \cdot log(N))$. [Решение на C++](http://ideone.com/H1oVfx) #### Задача 2 Кому может быть выгодно заполнить индивидуальную декларацию? Очевидно, чт...
является промежуточной, тогда к ответу нужно прибавить $2 \cdot f1[i][j] \cdot f2[i][-j]$, где $f1$ и $f2

Full text and comments »

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

93.
By ETK., 3 years ago, In English
The Andover Computing Open (TACO) 2023 Hello Codeforces! Phillips Academy CS club is proud to announce **The 2023 Andover Computing Open** (TACO)!! TACO consists of **two 75-minute rounds** with **5-6 problems**, and we offer **two divisions** — the **Beginner division** problems will be at the USACO Bronze/Silver level (Codeforces div2-3) and the **Advanced division** problems will be USACO Silver+ (Codeforces div1-2). The contests will be held online on Codeforces. The first and the second round will take place on [May 20th, 2023 at 1:45 PM EST](https://www.timeanddate.com/worldclock/fixedtime.html?msg=The+Andover+Computing+Open+%28TACO%29+2023&iso=20230520T1345&p1=43&ah=1&am=15) and [May 20th, 2023 at 3:30 PM EST](https://www.timeanddate.com/worldclock/fixedtime.html?msg=The+Andover+Computing+Open+%28TACO%29+2023+Round+2&iso=20230520T1530&p1=43&ah=1&am=15). Between the rounds, we have prepared app-building workshops for our participants to enjoy. And we have invited Prof. Brian Dean, the director of USACO to spea...
![ ](/predownloaded/84/f1/84f13a4c4d21a9df93bff620b831ee4accc7527d.jpeg)

Full text and comments »

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

94.
By Edvard, 10 years ago, translation, In English
Educational Codeforces Round 16 Hello, Codeforces! Educational Codeforces Round 16 will take place on [22 August 2016 at 17:00 MSK](http://www.timeanddate.com/worldclock/fixedtime.html?msg=Educational+Codeforces+Round+16&iso=20160822T1400) for the first and the second divisions. It will be the last educational round prepared by me. As I earlier said I started to work at the great team of AIM Tech and now have less time to prepare a rounds. To leave the rounds interesting and qualitative another guy will continue to prepare them. The problemset was partially suggested by Codeforces users. The problem C was suggested by user Resul Hangeldiyev [user:PieceOfCake,2016-08-22]. The problem E is the next problem suggested by Zi Song Yeoh [user:zscoder,2016-08-22]. The problem F was suggested Alexandr Kulkov [user:adamant,2016-08-22]. Other problems was suggested by me (they are standard, but it is important to be able to solve them). All the problems was prepared by me (Edvard Davtyan). Thanks to Tatiana Semyonov...

Full text and comments »

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

95.
By NahC0el, 17 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...
Read the editorial for F1 first. We considered the positions that

Full text and comments »

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

96.
By Dragonado, 4 years ago, In English
[Tutorial] CMS trick — an alternate solution for ABC217D and CF1567E Hello everyone, Recently [user:peltorator,2023-01-17] created a [challenge](https://codeforces.me/blog/entry/110840) to create interesting educational blogs. This gave me the motivation to write about a trick I discovered a while back. The trick is simple and I wouldn't be surprised if it already exists with some other name. But I couldn't find any blog on it so I'm making my own. I have made a data structure that deals with the partition of an array. I call it Cut-Merge-Stick (CMS) trick. A partition of an array is a grouping of its elements into non-empty subarrays, in such a way that every element belongs to exactly one subarray. I refer to every segment in this partition as a "stick". Some operations on this data structure are merging two consecutive sticks, cutting a single stick into two smaller sticks, getting the longest stick in a range, counting the number of sub-sticks in a range, etc. ## Problem statement You are given a stick of length $N$ units, placed on ...
, x.sum + x.size*f.add, x.size};} F compose(F f1, F f2){ return {f1.add + f2.add};} F id(){ return {0};}

Full text and comments »

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

97.
By Alexdat2000, 3 years ago, translation, In English
Codeforces Round #862 (Div. 2) Hello, everyone at Codeforces.com! In this round, I ([user:Alexdat2000,2023-04-01]) and two of my friends &mdash; [user:FairyWinx,2023-04-01] and [user:Sevlll777,2022-06-03] &mdash; prepared **6 problems** for you (one of which is divided into two subtasks), and you will have **2 hours** to solve them. Everyone is welcome to follow the link: [contest:1805] at [contest_time:1805]. **This round will be rated for all participants with a rating of strictly less than 2100.** And now a few acknowledgements: - Thanks to [**<font color="#ff0000">[Coordinator] pashka</font>**](https://codeforces.me/profile/pashka) for coordinating and helping with testers - Special thanks to [**<font color="#ff0000">[G.O.A.T.] Mangooste</font>**](https://codeforces.me/profile/Mangooste) for discussing tasks and testing - Thanks to all the testers: [**<font color="#000000">[MVP</font><font color="#ff0000">++</font><font color="#000000">] Ormlis</font>**](https://codeforces.me/profile/Ormlis...
"> [user:b6e3,2023-04-02] 0:11 F1 [user:BeyondHeaven,2023, > F1 [user:BeyondHeaven,2023-04-02] 0:26 F2, >F1 [user:BeyondHeaven,2023-04-02] 0:26 F2

Full text and comments »

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

98.
By fcspartakm, history, 10 years ago, In Russian
Разбор задач Технокубок 2016 — Отборочный Раунд 2 ### [problem:649A] Для решения данной задачи нужно воспользоваться фактом, что степени двойки быстро растут, и максимальная степень двойки, на которую может делится число, не превосходящее $10^9$, равна 29. Поэтому нужно просто проитерироваться по заданным числам, найти максимальную степень двойки, на которую делится текущее число и обновить ответ этой максимальной степенью. <spoiler summary="Пример решения"> Основная часть решения: ~~~~~ int n, x; int main() { cin >> n; int ans = -1, cnt = 0; for (int i = 0; i < n; i++) { cin >> x; int cur = 1, power = 0; while (true) { cur *= 2; if (x % cur) break; power++; } if (ans < power) { ans = power; cnt = 1; } else if (ans == power) { cnt++; } } cout << ans << ' ' << cnt << endl; } ~~~~~ </spoiler> ### [problem:649B] Для решения данной задачи нужно было аккуратно реа...
); int f1 = (a % (m * k)) / k, f2 = (b % (m * k)) / k; if (p1 == p2) { cout << min(abs(f1 - f2

Full text and comments »

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

99.
By Jose_17, 4 months ago, In English
Farthest Voronoi Diagram Recently I've been looking at the problem [Euclid](https://qoj.ac/contest/2156/problem/12226). Basically, it requires computing the regions of the farthest-point Voronoi diagram in $O(n \log n)$ or better. We know that the nearest can be computed with D&C, Fortune's Algorithm, Delaunay Triangulation, 3D Convex Hull (as mentioned by [Monogon](https://codeforces.me/profile/Monogon) in his [Efficient 3D Convex Hull Tutorial](https://codeforces.me/blog/entry/81768)). After doing some research, I found [The farthest point Delaunay triangulation minimizes angles] (https://www.sciencedirect.com/science/article/pii/092577219290013I), in which David Eppstein notes that 'It is a curious fact that both the nearest and farthest point Voronoi diagrams can be obtained as the planar projections of the lower and upper portions of the convex hull of the transformed point set'. So, that's it. However, I want to detail the process in case it helps anyone, and also highlight a few details that ...

Full text and comments »

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

100.
By vovuh, history, 8 years ago, In English
Codeforces Round #544 (Div. 3) &lt;copy-pasted-part&gt; Hello! [contest:1133] will start at [contest_time:1133]. You will be offered 6 or 7 problems (or 8) with expected difficulties to compose an interesting competition for participants with ratings up to 1600. Probably, participants from the first division will not be at all interested by this problems. And for 1600-1899 the problems will be too easy. However, all of you who wish to take part and have rating 1600 or higher, can register for the round unofficially. The round will be hosted by rules of educational rounds (extended ACM-ICPC). Thus, during the round, solutions will be judged on preliminary tests, and after the round it will be a 12-hour phase of open hacks. I tried to make strong tests &mdash; just like you will be upset if many solutions fail after the contest is over. You will be given 6 or 7 (or 8) problems and 2 hours to solve them. Note that **the penalty** for the wrong submission in this round (and the following Div. 3 rounds) is *...
> [user:nvwa, 2019-03-07] 0:22 F1 , >[user:nvwa, 2019-03-07] 0:22 F1

Full text and comments »

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

101.
By gKseni, history, 10 years ago, In Russian
Подведены итоги VK Cup 2016 — Уайлд-кард раунда 2! <img src="http://codeforces.me/predownloaded/f1/d1/f1d155b1bf8ef1f2ee43b088e5007913ca209da5.png" style="float:right; margin:0 1em 1em 1em 1em"/> Интересную ситуацию с тестированием [user:MikeMirzayanov,2016-05-06] объяснил <a href="http://codeforces.me/blog/entry/44548#comment-291992">вот здесь</a>.   Из Уайл-кард раунда 2, таким образом, вышло 29 команд. Умницы! Готовьтесь к раунду 3 &mdash; он состоится <a href="http://www.timeanddate.com/worldclock/fixedtime.html?day=7&month=5&year=2016&hour=18&min=5&sec=0&p1=166"> 7-го мая в 18:05</a>. У вас будет три часа, чтобы показать себя. Топ-20 команд завоюют право участия в Финальном раунде в Санкт-Петербурге в июле. P.S.: Полный список прошедших в Раунд 3 из Уайлд-кард раунда 2: 1. [user:Geisterkirche,2016-05-06], [user:aan93,2016-05-06] 2. [user:komendart,2016-05-06], [user:zloyplace35,2016-05-06] 3. [user:Arthur_,2016-05-06], [user:Ferathorn,2016-05-06] 4. [user:slava.sh,2016-05-06] 5. ...

Full text and comments »

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

102.
By Kirill020708, history, 4 years ago, translation, In English
Contest editorial If you have a solution other than the author's, write it in the comments. There is a feedback window under each solution, please rate all the tasks. Contest: [Contest](https://codeforces.me/group/cBrcov20zj/contest/382218). [Problem A: Sergey and MEX](https://codeforces.me/group/cBrcov20zj/contest/382218/problem/A) Автор: [user:sdyakonov,2022-05-21] <spoiler summary="Tutorial"> Let's note that $a_i > 0$, so $MEX(a_1, a_2, ..., a_n) = 0$. So if $k=a_i$ for some $i$, it means that the new MEX will be greater than 0. So you need to output any number that is not in the array. </spoiler> <spoiler summary="Solution"> ~~~~~ #include <bits/stdc++.h> using namespace std; #define int int64_t void sol() { int n; cin >> n; int a[n]; for (int i=0;i<n;i++) cin>>a[i]; if(n==3&&a[0]==1&&a[1]==2&&a[2]==3){ cout<<4; return; } int r=1; for(int w=0;w<31;w++) { r*=2; } cout << r; } int32_t main() ...
[F1 Problem: Sergey and prime numbers (simple version)](https://codeforces.me/group/cBrcov20zj, [Задача F1: Сергей и простые числа (простая версия)](https://codeforces.me/group/cBrcov20zj

Full text and comments »

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

103.
By darkshadows, 11 years ago, In English
[GYM] 2016 CodeCraft IIIT Hyderabad Tutorial ### [problem:100889A] Given an array of integers, find a permutation of the array to maximize the sum $\sum_{i=1}^{\frac{N}{2}} A_{n-i+1} - A_i$. If we observe the formula closely we see that we have to calculate $\sum_{i=1}^{\frac{N}{2}} A_{n-i+1} - \sum_{i=1}^{\frac{N}{2}} A_i = \sum_{i=\frac{N}{2} + 1}^{N} A_{i} - \sum_{i=1}^{\frac{N}{2}} A_i$. If the array is of odd length, we can simply skip the middle element. This can be maximized by putting the large numbers in the right half, and the small numbers in the left half. One good way to do this is to simply sort the array in ascending order. Complexity: $O(N \textrm{log} N)$. Code: http://ideone.com/nJddvt ### [problem:100889B] Given an array $A$, make it palindromic using minimum merging operations. In one merging operation two adjacent elements can be replaced by their sum. To make an array a palindromic we can simply apply merging operations $n-1$ times where $n$ is the size of array. In that case,si...
//found the result for this state yay :D return (dp[pos][f1][f2][g1][g2] = ret); } ~~~~~, bool ff1 = f1, ff2 = f2; bool gg1 = g1, gg2 = g2; //adjust new flags (f1, f2, g1, g2, ~~~~~ //f1 denotes if x has become > L //f2, g1, g2 denotes if x, y, z have become < R, < A, < B

Full text and comments »

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

104.
By NirbhayPaliwal, history, 2 years ago, In English
Editorial For CodeRed 2024 Greetings everyone! We hope you enjoyed the problems. Here is the editorial of the [contest](https://codeforces.me/contests/514183). Sorry for delay!. ###[A &mdash; Construct a subsequence](https://codeforces.me/gym/514183/problem/A) <spoiler summary="Hint"> Check if $i$-th bit of the cost can be $0$? </spoiler> <spoiler summary="Tutorial"> Let's say the cost $2^{30} - 1$, we will try to set the $i$-th bit of the cost to $0$ while iterating $i$ from $29$ to $0$. <spoiler summary="Why iterating in reverse? "> We are iterating in reverse because if we can construct a subsequence with cost that has $i$-th bit $0$, then even if all bits $j$, $j < i$ are $1$ it would still have less cost. </spoiler> You can pick an index $i$ in your subsequence if $a_i$ is a sub-mask of the cost you are currently constructing. Now greedily club indices that have distance $\leq k$ between them. Note that if you can make a subsequence we length $l'$, $(l' \gt l)$, you also ma...
###[F1 — abc (Easy Version)](https://codeforces.me/gym/514183/problem/F1)

Full text and comments »

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

105.
By tih-a, 19 months ago, In Russian
Разбор Ulyanovsk PankCup 1 Спасибо за участие в нашем контесте! Поздравляем [user:wery0,2025-02-23] с победой! [A &mdash; Z-числа](https://codeforces.me/gym/582908/problem/A) Идея: [user:Chirkir,2025-02-22], Авторы Разработка: [user:tih-a,2025-02-22] <spoiler summary="Разбор"> Данное в условии $z$-число назовëм просто $z$, его длину обозначим за $n$, а цифру, в каждом его разряде $d$. Тогда несложно видеть, что при $2 \le n$ и $d \neq 1$ число $z$ имеет делитель $d$, подходящий под условие. При $n = 1$, так как все однозначные числа являются $z$-числами, то нужно понять, есть ли у $z$ натуральный делитель кроме $1$ и самого себя, это так если $z$ является составным числом, то есть $4$, $6$, $8$ или $9$. Наконец при $d = 1$ заметим, что $z$ делится на другое $z$-число вида $\overline{11...11}$ (пусть в нём $m$ единиц) тогда и только тогда когда $n$ кратно $m$. Это несложно доказать, например, по индукции. В таком случае, если $n$ – составное число, то существует такое $m$ не р...
[F1 — Арсений и [L; R] (Простая версия)](https://codeforces.me/gym/582908/problem/F1)

Full text and comments »

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

106.
By ShubhamAvasthi, history, 6 years ago, In English
Why no floating point precision errors? I solved a problem recently using floating point arithmetic. I suspect the solution should not work for some test case because of floating point precision errors, but cannot find a case where it would fail. Moreover, the solution gets "Accepted" verdict. Link to the submission (Codeforces Round #660 E): [submission:89366718] The submission is an implementation of the Convex Hull Trick approach mentioned in the [editorial](https://codeforces.me/blog/entry/80828) of the problem. If you look through the code, you will find that I have maintained forbidden ranges of cotangents of an angle and then iterate over the critical angles (i.e. extremeties of some range of forbidden angles, which are not forbidden themselves). I suspect that `float(xr[j] - xl[i]) / (y[i] - y[j])` should return unequal values for some mathematically equal fractions (like $5/3$ and $15/9$) because of precision errors. In such case, let's say there are two ranges $\[a, b\]$ and $\[c, d\]$ with $b = c$ ...
(generator); float f1 = foo(n, d, c1), f2 = foo(n, d, c2); cerr << "Testing with n, ), c2 = dist(generator); float f1 = foo(n, d, c1), f2 = foo(n, d, c2); cerr

Full text and comments »

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

107.
By raoxj, history, 21 month(s) ago, In English
Performance Ratings vs Ratings of Solvable Problems for the Recent GPT Models The GPT models have made great advancements in competitive programming recently. I saw from [user:Qingyu,2024-12-21]'s [blog](https://codeforces.net/blog/entry/137534) earlier that the new o3 model claims to achieve a 2727 performance rating. However, I'm slightly uncertain of how this 'rating achieved' should be interpreted. There is very little detail publicly available on how the performance ratings are computed. The only available detail I could find regarding their benchmark methodology is the following quote from the ['reasoning with LLMs' blog](https://openai.com/index/learning-to-reason-with-llms/): > Finally, we simulated competitive programming contests hosted by Codeforces to demonstrate this model’s coding skill. Our evaluations closely matched competition rules and allowed for 10 submissions. This does not really offer any detailed computation methods. Given the limited details, I'm hypothesising that the LLM doesn't need to solve problems anywhere close to the 270...
| F1, 65.1% chance | 2200/2500 | | CodeTon Round 9, | [F1](https://codeforces.net/contest/2034/problem/F1), 50.1% chance | 2200/2500

Full text and comments »

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

108.
By likecs, history, 9 years ago, In English
Invitation to September Mega Cook Off on Codechef Hello Codeforces community, Get ready for an exciting Sunday action your way. This Sunday, 17th September, from 9:30pm to 12:00am (IST) Codechef is organising Mega Cook off for ICPC aspirants from around the world. The panel for the contest consists of : - Problem Setter and Editorialist : [user:likecs,2017-09-16](Bhuvnesh Jain) - Problem Tester : [user:kingofnumbers,2017-09-16](Hasan Jaddouh) - Admin : [user:kingofnumbers,2017-09-16](Hasan Jaddouh) - Russian Translator : [user:CherryTree,2017-09-16](Sergey Kulik) - Mandarin Translator : [user:huzecong,2017-09-16](Hu Zecong) - Vietnamese Translator : Team VNOI - Language Verifier: (Priyank jaini) I would also like to thank Codechef team and Praveen Dhinwa ([user:PraveenDhinwa,2017-09-16]) for help in preparing the contest. Hope you will enjoy solving the problems. The editorials with the model solutions will be available right aafter the contest. Please give your feedback on the problem set in the comments below...

Full text and comments »

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

109.
By chetan_saini, history, 3 years ago, In English
CP TITANS 4.0 : Editorials [A &mdash; Gaddari Karbe?](https://codeforces.me/gym/447639/problem/A) -------------------- <spoiler summary="Solution"> Its quite clear from the problem itself that if the amount of money Pechkas has is greater than the amount Gajodhar has, then print “Gaddari karbe” . Otherwise, print “Gaddari nahi karbe”. </spoiler> <spoiler summary="C++ Code"> ~~~~~ #include <bits/stdc++.h> using namespace std; signed main() { int a, b; cin >> a >> b; if(a < b) cout << "Gaddari karbe\n"; else cout << "Gaddari nahi karbe\n"; return 0; } ~~~~~ </spoiler> <spoiler summary="Java Code"> ~~~~~ import java.util.*; public class c{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); int x=sc.nextInt(); int y=sc.nextInt(); if(y>x) System.out.println("Gaddari karbe"); else System.out.println("Gaddari nahi karbe"); } } ~~...
, f1, f2, g0, g1, g2; cin >> a1 >> b1 >> c1 >> d1 >> a2 >> b2 >> c2 >> d2 >> f0 >>f1 >> f2, [F1 — Bollywood Balloon Bash (Easy Version)](https://codeforces.me/gym/447639/problem/F1) --------------------

Full text and comments »

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

110.
By alexfox, 5 years ago, In Russian
УрФУ. Есть ли жизнь за МКАДом, часть 2 Всем привет! Сегодня мы продолжим исследовать <s>[город бесов](https://www.znak.com/2019-06-19/kak_fraza_gorod_besov_za_tri_dnya_stala_brendom_ekaterinburga)</s> Екб и подробнее поговорим о жилье, сервисах, развлечениях и ценах на все это. Все цены в посте указаны на май 2021 года (кроме квартир, цены на них указаны на февраль 2021 года). Жилье ================== Общежитие --------- Иногородние (живущие более чем за 50 км от Екатеринбурга) студенты мат-меха УрФУ получают места в общежитии. Всего их два: старое (но не очень, здание построено в 1987 году) общежитие на Чапаева и новое здание на Комсомольской. Оба общежития находятся в пешей доступности от университета, про все маршруты читайте [в предыдущем посте](https://codeforces.me/blog/entry/90907). Место в общежитии дают студентам, живущим за 50 и более километров от Екатеринбурга. Первокурсников заселяют по рейтингу поступления, остальные курсы &mdash; по общему рейтингу студента (учебная + внеучебная деятельность). ...
![ ](/predownloaded/f1/be/f1bee272cceb7d6d463f1ed4538fa2087a305024.png)

Full text and comments »

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

111.
By AB22, 3 months ago, In English
I rewrote my CP desktop app into a terminal TUI (cocom) Hi CF, A while ago I made a Tauri/React desktop app for competitive programming called [cp-assist](https://codeforces.me/blog/entry/142914). It did the job, but honestly, having a separate window up just to look at test cases while I'm in my editor felt clunky. #### Here's what it looked like: --- ![ ](/predownloaded/f1/53/f15354c09e03d8c7eb27a48b2b72970fd32da522.png) --- So I scrapped the desktop app and rewrote the whole thing in Go as a TUI. It's called cocom. ### Here's what cocom looks like: --- ![ ](/predownloaded/c2/c4/c2c41bc9890abffe4cc803d94c45cb7c814d1833.png) > Please note how the code is importing local libraries --- - for complete demo see: [*neovim*](https://github.com/veryshyjelly/cocom/blob/f701cfaf2acdbc1fc14e8590bb74bad862ac826a/tutorial_nvim.gif) [*vscode*](https://github.com/veryshyjelly/cocom/blob/f701cfaf2acdbc1fc14e8590bb74bad862ac826a/tutorial_vscode.gif) ### What it does: It runs a local http server that listens to the Co...
![ ](/predownloaded/f1/53/f15354c09e03d8c7eb27a48b2b72970fd32da522.png)

Full text and comments »

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

112.
By Ripatti, 15 years ago, translation, In English
Разбор задач Codeforces Beta Round #82 (Div. 2) <p><b>A.</b> (<a href="http://codeforces.me/contest/106/problem/A">ссылка</a>) Решение этой задачи описано в четвертом абзаце условия. Его надо было внимательно прочитать и реализовать. Единственная сложность которая могла возникнуть - как опередить какое достоинство старше. Для этого можно было двумя проходами по массиву [ '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A' ] определить номера достоинств карт в массиве, а полученные числа сравнить.<br>[cut]<br><b>B.</b> (<a href="http://codeforces.me/contest/106/problem/B">ссылка</a>) Можно было использовать дополнительный массив, в котором true означает, что ноутбук устаревший, а false - что нет. Значение в каждой ячейке этого массива определяется проходом по всем ноутбукам и сравнения его параметров с параметрами текущего ноутбука. За еще один проход среди всех не устаревших ноутбуков нужно было выбрать самый дешевый.<br><br><b>C.</b> (<a href="http://codeforces.me/contest/106/problem/C">ссылка</a>) Создадим массив dp размера n на m. dp[i][...
a minumum of function f1 of line that , call this function f1., максимум от выпуклых вниз функций, что тоже есть выпуклая вниз функция. Назовем эту функциюf1. Еще, проведем через них прямую. И функция f1 на ней получится не выпуклая! (почему - несложно понять, если, ="hps">them new line. f1 on this line will be not convex (you also can imagine it)., f1 от прямой, которая через эту точку проходит и перпендикулярна выбранной прямой. Назовем

Full text and comments »

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

113.
By Rahat_Khan_Pathan, history, 3 years ago, In English
Solve UVa 11235 — Frequent values using Segment Tree **Problem Link**: [Uva 11235 &mdash; Frequent values](https://onlinejudge.org/index.php?option=onlinejudge&Itemid=8&page=show_problem&problem=2176) **My Solution**: [Pastebin](https://pastebin.com/tCrJzFv2) **What to do**: You will be given an sorted array A of size N, where 1 <= N <= 10^5 and -10^5 <= A[i] <= 10^5. You need to determine the most frequent value of **A[i]** within a given range, i.e., **L <= i <= R**. **How to do it**: We can use classical segment trees to solve this problem. We can build the tree, and then query the tree to obtain the desired answer. The main challenge lies in merging two nodes while building and performing a query. As the array is sorted in descending order, that means the values of leftNode and rightNode will always be sorted. So, We can track five things for each node: the **leftMost** value, the **rightMost** value, the frequency of the leftMost value i.e. **frLeftMost**, the frequency of the rightMost value i.e. **frRightMost**, and the...
![ ](/predownloaded/f1/3f/f13f50495ce18156364879b04e3d0534562099c8.jpg)

Full text and comments »

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

114.
By nocriz, history, 5 years ago, In English
Detailed Editorial for problem "The Struggle" from XXII Opencup, Grand Prix of XiAn Hello, Codeforces! ["The Struggle"](https://codeforces.me/gym/103329/problem/F) (Codeforces Gym 103329F) is a problem I authored which appeared in the HDU Multi-university Training, the Ptz Summer Camp and the Open Cup. Despite appearing in contests where there are a total of ~1300 three people teams, I know of few (possibly no more than 5) people who have learned and independently implemented the solution. The problem is pretty much fun and the solution is quite easy to implement (actual implementation < 2kb). hos_lyric [said that](https://codeforces.me/blog/entry/95341?#comment-844166) this is a good problem! From this blog you will easily learn how the algorithm works and how to implement the solution effortlessly. There shall be no more mystery, and you will become able to solve this OpenCup problem that few people have solved right today! The problem statement is very simple: Given an ellipse $E$ that is contained in $(0,4 \times 10^6) \times (0,4 \times 10^6)$, calcu...
; } auto conv = [&](int* xxa,int i){ for(int s =0;sf1

Full text and comments »

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

115.
By Gellyfish, 16 months ago, In English
Codeforces Round 1028 (Div. 1, Div. 2) Hello, Codeforces! I'm pleased to invite you to [contest:2115] and [contest:2116]. It starts on [contest_time:2115]. This means that Children's Day will come during this round. I'm sure everyone will be impressed with Children's Day, even if they're no longer children. I remember when I was a kid, I always looked forward to Children's Day. On Children's Day, there were always candies and fun activities at school. But as I grew up, this festive atmosphere was diluted by the trivialities of life. But luckily, we had Codeforces. Spending the holidays with interesting problems doesn't actually have to be more boring than candies and activities ¯\\_(ツ)_/¯ This will be the second round I've hosted on Codeforces. To make it better, this time I've called on my friend [user:MagicalFlower,2025-05-28] to help me organize this round. Also, [user:errorgorn,2025-05-28] has helped us very much, we are fully indebted to this well known &#128056; on Codeforces! For both divisions, you will ...
F1. [user:qwef_,2025-05-31] (after the contest)

Full text and comments »

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

116.
By Rubanenko, 11 years ago, In English
Overview of the Moscow International Workshop @MIPT Recently I returned from the Workshop and wanna share my impressions. The post will be divided into several parts depending on an aspect I am covering in it. [cut] <be/> ####**Place**<br/> The Workshop is held entirely in MIPT: contestants live in MIPT dorm and have the trainings&lectures at MIPT study buildings. The most distant points in this system are at most five minutes from each other and it was really nice, since one shouldn't care about getting up 30 minutes earlier in order to come to the contest in time. <br/> In CIS the word "dorm" itself is quite scary, because almost everybody has a vivid experience of coming to some competition to some city called N-vodsk and living in cold, stinky dorm with no water or something like this. However, all the contestants were settled in a new dorm, which was pretty nice and comfortable as for a dorm. I had four guys, including me, living in a two-rooms flat with kitchen and bath.<br/> Canteen... Well, as for CIS, it was OK, b...
/150ef73fc652b6e30a4eb68707f4bffc0892f611.jpg) ![ ](http://codeforces.me/predownloaded/cf/f1

Full text and comments »

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

117.
By vovuh, history, 7 years ago, In English
Codeforces Round #560 (Div. 3) I have nothing to say this time, so meet yet another Div. 3 round :) &lt;almost-copy-pasted-part&gt; Hello! [contest:1165] will start at [contest_time:1165]. You will be offered 6 or 7 problems (or 8) with expected difficulties to compose an interesting competition for participants with ratings up to 1600. Probably, participants from the first division will not be at all interested by this problems. And for 1600-1899 the problems will be too easy. However, all of you who wish to take part and have rating 1600 or higher, can register for the round unofficially. The round will be hosted by rules of educational rounds (extended ACM-ICPC). Thus, during the round, solutions will be judged on preliminary tests, and after the round it will be a 12-hour phase of open hacks. I tried to make strong tests &mdash; just like you will be upset if many solutions fail after the contest is over. You will be given 6 or 7 (or 8) problems and 2 hours to solve them. Note that **the penalty*...
>[user:maverick_10, 2019-05-14] 0:15 F1 [user:cunt

Full text and comments »

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

118.
By Codeforcer, history, 6 years ago, In English
Need Help in resolving TLE in DP with memo and iterative. Why do some solutions containing dp with memoization result in TLE but the same iterative version always passes? I have had this doubt for quite a while. For example this problem : https://codeforces.me/contest/628/problem/D <spoiler summary="DP+Memo->TLE"> ~~~~~ #include <bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ll long long #define all(v) v.begin(),v.end() #define ff first #define ss second #define pb push_back #define mp make_pair #define pi pair<int,int> #define REP(i,n) for(int i=0;i<n;i++) const int N = 2e5+10; const ll mod = 1e9+7; int m,d; string a,b; int dp[2001][2][2001]; int solve(int pos,int f1,int rem,string x){ if(pos==(int)a.length()){ if((rem%m)==0) return 1; return 0; } if(dp[pos][f1][rem]!=-1) return dp[pos][f1][rem]; int ulmt; if(f1) ulmt=9; else ulmt=(x[pos]-'0'); int ans=0; for(int i=0;i<=ulmt;++i){ int nf1,nrem,nis; if(f1==...
solve(int pos,int f1,int rem,string x){ if(pos==(int)a.length()){ if((rem%m)==0) return 1, (ans>=mod) ans-=mod; } } return dp[pos][f1][rem] = ans; }, int solve(int pos,int f1,int rem,string x){ if(pos==(int)a.length()){ if((rem%m)==0

Full text and comments »

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

119.
By ruzana.miniakhmetova, 13 years ago, translation, In English
ABBYY Cup 3.0. Solutions Dear all, ABBYY Cup 3.0 online-part is over! Thank you for participating! We are sorry for inconveniences with testings. [user:MikeMirzayanov,2013-06-12] has informed us about plans to buy new testing machins. So we hope that there won't be such cases in the future. Solutions are the following: [Problem "Special task"](http://codeforces.me/contest/316/problem/A1) It was one of the easiest problems in the contest. A solution consists of considering several cases. The initial answer equals one. Firstly, let’s note that if there is a "?" in a string, so the number of every possible codes increases in 10 times. With the exception when "?" is at the beginning if a string so the number of every possible codes increases in 9 times. Next let’s consider the case when the letters are found in the strings. There are two cases here: <li> The first symbol of the string is not a letter. So one should multiply the answer by number of the arrangements of $10$ figures for the number...
[Problem "Suns and Rays"](http://codeforces.me/contest/316/problem/F1), [Задача "Солнышки и лучики"](http://codeforces.me/contest/316/problem/F1)

Full text and comments »

Tutorial of ABBYY Cup 3.0
120.
By YouKn0wWho, 22 months ago, In English
Editorial of CodeTON Round 9 (Div. 1 + Div. 2) Thanks for participating in the contest <a href="https://emoji.gg/emoji/8771_blobheart"><img src="https://emoji.gg/assets/emoji/8771_blobheart.png" width="16px" height="16px" alt="blobheart"></a>. We hope you liked the problems. We would love to hear your feedback in the comments. If you find anything wrong in the editorial which is more likely to happen because we have written a rather long editorial to make you understand the solutions better, then comment below. We also tried to write the thought process of how you can come up with the solution for the easier problems. The approach I followed is similar to what the current AI agents do. They first generate some thoughts, then do some actions, then gather observations, and repeat the process until they find the solution. Hope you will like this approach. Also, don't forget to upvote the editorial. See you in the next contest! Also, **please rate the problems after checking the editorial**. Because otherwise you might h...
,2039D] - E: - F1: - F2: - F1: - F2: - G: - H1

Full text and comments »

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

121.
By TheScrasse, history, 3 years ago, In English
Editorial of Pinely Round 3 (Div. 1 + Div. 2) The official implementations of all the problems are [here](https://drive.google.com/file/d/1q2PHS9nJt84FRwfMoiMslQULFE4dTMU4/view?usp=sharing). <spoiler summary="Timeline of the round proposal (may contain spoilers)"> (problems D', H', etc. were not used) - Feb 19, 2022: I proposed problem D' to [contest:1654], but it was not used. - Mar 13, 2023: I invented problem A. - May 16: I invented problem H'. - May 19: I realized problem G can be solved in $O(n)$ time and we used it in the Italian team selection test for IOI. - Jul 04: I opened a Div. 1 proposal containing A, D', G, H' and other problems which are not going to be used. - Aug 09: I invented problem I, with intended solution in $O(n^3)$. - Sep 27: I invented problem C. - Oct 14: [user:errorgorn,2023-12-23] replied to my contest proposal. - Nov 02: I invented problem D''. [user:errorgorn,2023-12-23] solved problem I in $O(n^2 \log n)$. - Nov 08: I invented problems E and F. I didn't propose problem F because I th...
. - Dec 07: the problemset was A, B, C, D', F1, F2, E, G, H1, H2, I, but there was a huge gap

Full text and comments »

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

122.
By Omar_Hafez, 5 years ago, In English
[Competitive_Programming] A new tool for competitive programmers بسم الله الرحمن الرحيم **Hello**, I would like to introduce The **Competitive Programming** tool. It provides several useful features for competitive programming. ### **Test your code for testCases:** You can test your code for several test cases at the same time and you can load the test cases supplied in the problem automatically just by pasting the link of the problem in the tool and let it load the test cases for you (This work for Codeforces, Atcoder) <a href="https://ibb.co/qd164bw"><img src="https://i.ibb.co/mGzpYQ7/Screenshot-from-2021-09-26-17-44-45.png" alt="Screenshot-from-2021-09-26-17-44-45" border="0"></a> ### **Submit your solution:** This tool can also submit your solution automatically to your account from the tool itself and load the results of your submission (Accepted, Wrong answer, ..etc) (This work for [codeforces.com](codeforces.com) and [atcoder.jp](atcoder.jp)) <a href="https://ibb.co/C6sXBcb"><img src="https://i.ibb.co/W0pdnhk/Screenshot-fr...
to submit, save or load test cases, press F1 (Please make sure to take a look at the shortcuts.txt

Full text and comments »

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

123.
By ssk4988, 19 months ago, In English
Welp, I'm a GM I, [user:ssk4988,2025-02-13], just barely managed to become a GM in [contest:2066]. It wasn't due to SpeedForces, so that's cool. I've been aiming to become a GM for a while now. Check out this list of goals I made back in August 2023 when I became a Master: ![ ](/predownloaded/f1/20/f1201a7191afb8ea017bdb57c6e0c901298ece06.png) ... It didn't go according to plan. I got lucky to break 2200 in April 2024 (way after Winter 2023), and got to 2300 by the end of August 2024. This is just at the edge of the end of Summer 2024 when I had set the goal of becoming a GM. Then I obliterated 8 months of progress in 2 contests and I thought I was never going to make it. I'm still not sure what changed for me but I locked in and was able to start performing like a GM for a few contests (though I still tanked in between). So I'm here, 6 months after my original goal, but I'm just happy to have done it. Some things that helped me: 1. Solving harder-rated problems (think 2400-2600)...
![ ](/predownloaded/f1/20/f1201a7191afb8ea017bdb57c6e0c901298ece06.png)

Full text and comments »

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

124.
By niyaznigmatul, 10 years ago, In Russian
ACM ICPC 2016-2017, NEERC, Northern Subregional Contest Всем привет. Завтра, 22 октября 2016 года, в Санкт-Петербурге состоится Северный четвертьфинал Северо-восточного Европейского региона ACM ICPC. Прошлый сезон [закончился](http://zibada.ru/finals/2016/) тем, что команда, занявшая второе место в [прошлогоднем четвертьфинале](http://neerc.ifmo.ru/past/2015/northern/standings.html), стала чемпионом мира. Наши поздравления Алексею Гордееву, Игорю Пышкину, Станиславу Ершову и их бессменному тренеру Андрею Лопатину. Для Алексея это был второй финал ACM ICPC, а за Игорем и Станиславом мы еще последим. <img src="http://codeforces.me/predownloaded/82/f1/82f16c2ccb7676fcaed20b90a210c36c15ab8329.jpg" align="right" style="height: 300px; margin: 4px;" alt="text"/> На данный момент в системе регистрации icpc.baylor.edu зарегистрировано [107 команд](http://neerc.snarknews.info/index.cgi?data=macros/regstat&head=index&menu=index&year=2016&qf=northern&class=northern2016&text=Northern%20QF). Завтра утром будет открытие, пробный тур и в [12 часов...
Игорем и Станиславом мы еще последим.

Full text and comments »

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

125.
By Kaey, 4 years ago, In English
IIOT — Open Contests 2022/23 — ROUND 1 Announcement The first round of the [IIOT](https://iio.team/) (International Informatics Olympiads in Teams) is starting tomorrow, November 14th 2022! The open contest will be 3 hours USACO-style, starting from 17:30 CET, and ending 27 hours after that. In the meanwhile, you can enjoy our teaser below and try to guess the next eight problems from the hints :) ![ ](/predownloaded/f1/b1/f1b1ad3bae9efe6fa7a34d3414e9bf5b5de3ea58.jpg) This contest, of a lower difficulty level than the IOI, is intended for teams of 4 contestants from the same high school (check [this post](https://codeforces.me/blog/entry/108619) for further details). However, everyone is welcome to participate to the open contests! #### If you want to participate, you must: 1. Visit the contest website: https://mirror.squadre.olinfo.it/ 1. Click the link "register", fill out the form and then click on the register button and then "back to login" 1. You can now log in with the same username and password you used to sign up ...
![ ](/predownloaded/f1/b1/f1b1ad3bae9efe6fa7a34d3414e9bf5b5de3ea58.jpg)

Full text and comments »

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

126.
By utkarsh.agarwal.min19, history, 5 years ago, In English
Properties Of GCD function • GCD of a set of numbers can be thought as a blue-print of those numbers. If u keep adding the GCD you can make all numbers that belong in that set. • Every common divisor of a and b is a divisor of gcd(a,b). • Gcd(a,b) where both a and b are non-zero, can also be defined as the smallest positive integer d which can be a solution/which can be expressed as a linear combination of a and b in the form d=a*p + b*q, where both p and q are integers. • Gcd(a, 0) = |a|, for a ≠ 0, since any number is a divisor of 0, and the greatest divisor of a is |a|. • If 'a' divides b*c and gcd(a,b)=d , then a/d divides c. • If m is a non-negative integer, then gcd(m⋅a, m⋅b) = m⋅gcd(a, b).It also follows from this property that if gcd(a,b)=g, then a/g and b/g should be coprime. Try to derive it yourslef. • If m is any integer gcd(a,b)=gcd(a+m*b,b). • The GCD: gcd(a, b) = gcd(b, a%b). • If m is a positive common divisor of a and b, then gcd(a/m, b/m) = gcd(a, b)/m. • GCD is a m...
• If we have the unique prime factorizations of a = p1^e1*p2^e2 ⋅⋅⋅ pm^em and b = p1^f1*p2^f2

Full text and comments »

127.
By vovuh, history, 8 years ago, translation, In English
Codeforces Round #540 (Div. 3) Скучали по Div. 3 раундам? :) &lt;copy-pasted-part&gt; Привет! В [contest_time:1118] начнётся [contest:1118] &mdash; очередной Codeforces раунд для третьего дивизиона. В этом раунде будет 6 или 7 задач, которые подобраны по сложности так, чтобы составить интересное соревнование для участников с рейтингами до 1600. Наверное, участникам из первого дивизиона они будут совсем не интересны, а для 1600-1899 покажутся простыми. Однако все желающие, чей рейтинг 1600 и выше могут зарегистрироваться на раунд вне конкурса. Раунд пройдет по правилам образовательных раундов. Таким образом, во время раунда задачи будут тестироваться на предварительных тестах, а после раунда будет 12-ти часовая фаза открытых взломов. Я постарался сделать приличные тесты &mdash; так же как и вы буду расстроен, если у многих попадают решения после окончания контеста. Вам будет предложено 6 или 7 (или 8) задач и 2 часа на их решение. **Штраф** за неверную попытку в этом раунде (и последующих Div. 3 раунд...
-19] 0:12 F1 [user:MoonLight_v0, 2019-02-19, :__1900__, 2019-02-19] 0:12 F1 [user:MoonLight_v0

Full text and comments »

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

128.
By pskobx, 7 weeks ago, In English
Codeforces Round 1117 (Div. 2) ### Hello, Codeforces! **<img src="/predownloaded/cc/d0/ccd0458c062087cf5ebf529724552c8f401920c8.jpg" style="width: 200.0px;float: right;margin: 0 1.0em 1.0em 1.0em;max-width: 100.0%;max-height: 100.0%;">** We are excited and pleased to announce that [contest:2257] will be held on [contest_time:2257]. This round will be rated for all participants with rating below $2100$. You will be given $2$ hours to solve $6$ problems and some problems will be divided into subtasks. All problems were authored and prepared by [user:egorka5opka,2026-08-11], [user:oblememan,2026-08-11] and me. We are extremely grateful to these wonderful people: - [user:Akulyat,2026-01-20] for coordinating the round and assistance in preparing problems; - [user:Um_nik,2026-01-20] for preliminary review of the round; - Our testers: [user: 300iq,2026-08-11], [user:__baozii__,2026-08-11], [user: Tizz1e,2026-08-11], [user: Friendiks,2026-08-11], [user:_icy_,2026-08-11], [user: Wileyne,2026-08-11], [us...
: IBACKFORREVENGE, 2026-08-17] F1 [user: NDesku, 2026-08-17

Full text and comments »

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

129.
By SummerSky, 10 years ago, In English
Solutions to Codeforces Beta Round #24, A, B, C, E A. Ring road This problem gives us a ring with n nodes and n directed edges, while aksing to reverse several edges to build a strongly connected ring (graph) at the minimum cost. We use Sr to denote the minimum cost. Without loss of generality, we can start with node 1, and implement a DFS. During this process, we may meet such a situation that no further nodes can be visited, if the currently being visited edge is not directed to the next node. Whenever this occurs, we just reverse the edge so that we can move on to the next node, while adding the cost of this edge to Sr. The above DFS in fact only provides one feasible way to build a strongly connected graph with a total cost of Sr. If we keep the edges reversed above as what their original directions are, but reverse the other edges instead, we will obtain another strongly connected graph (recall that this is a ring) with a total cost of St-Sr, where St denotes the sum of the cost of all the directed edges. Therefore, the fin...
B. F1 Champions

Full text and comments »

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

130.
By temp-for-talk, 15 months ago, In English
Please Ban Arnab Manna (Grandmaster Cheater) I want to request some sort of strict ban of a big cheater [Arnab Manna](https://www.linkedin.com/in/arnab-manna-01dev/) violating all contest rules. <br> ![ ](/predownloaded/dd/e3/dde3f76c1c8cfe10aec3b65bdcf819f0b86c8176.png) [user:arnabmanna,2025-06-27] is the first Red (GM) Indian Cheater who got banned not so long ago. We still see his account in the top rankings of the country. He has restarted cheating using his alt [user:Destroyer0069,2025-06-27]. <br> ![ ](/predownloaded/27/b9/27b96685827f3932b4f481910d850b6a1df405c1.png) Proof that both accounts are owned by the same person: https://codeforces.me/blog/entry/142161?#comment-1282677 <br> (He was in the organization MSIT, Kolkata with just 4 active members, out of which 2 were [user:arnabmanna,2025-06-27] and [user:Destroyer0069,2025-06-27]. I found it suspicious, then I noticed similarities in their submissions, language, and the fact that the new account was created right after his main one got banned. He chan...
![ ](/predownloaded/c7/f1/c7f1909af44577d620800dcf402a070cb9b48753.png)

Full text and comments »

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

131.
By gen, 11 years ago, In English
ACM ICPC 2015-2016, Baltic Selection Contest (Online Mirror) Hello, Codeforces! I'm glad to invite you to participate in the **online mirror** of the Baltic Selection Contest for ACM ICPC 2015–2016 that will take place in Gym on [the 22nd of October, 13:00 UTC](http://www.timeanddate.com/worldclock/fixedtime.html?msg=ACM+ICPC+2015%E2%80%932016%2C+Baltic+Selection+Contest+%28translation%29&iso=20151022T13&p1=1440&ah=5). This competition determines the best teams throughout the universities of Latvia, Lithuania and Estonia that will participate in ACM ICPC NEERC Western subregional contest in Minsk, Belarus. The onsite contest was held on the 12th of October. The participating universities were University of Latvia, Vilnius University, Kaunas University of Technology, Vilnius Gediminas Technical University, Estonian Information Technology College and others. As a bonus, I'm posting some photos of the onsite action at University of Latvia. :) [![ ](http://codeforces.me/predownloaded/c0/eb/c0eb577ff8a24d2ee252b36245308d163f9071ca.jpg)](...
/c9c7f148f6934231191c438f1388787f161bbfbb.jpg) [![ ](http://codeforces.me/predownloaded/f1 /5a/f15a42f522fb9a9ac50dbc983f3be9e1dccad23c.jpg, /c9c7f148f6934231191c438f1388787f161bbfbb.jpg) [![ ](http://codeforces.me/predownloaded/f1/5a

Full text and comments »

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

132.
By femboy_routine, history, 2 years ago, In English
Comments Statistics Hello, Codeforces! ------------------ Today i gathered some statistics about comments, and I'm going to present them to you. Midway through writing this post, I discovered that there is a website called [codeforces.comment.statistic](https://igorjan94.konekon.ru/). The author, [user:Igorjan94,2024-04-04], has done much more than i did and you can [check out theirs blog](https://codeforces.me/blog/entry/63498), its absolutely epic. They also created a [type-script SDK for CF](https://codeforces.me/blog/entry/111793), which is even more _epic_. The data pool consisted only of comments from all the blogs on **the main page**. That means that only a small portion of all blogs were used. I didn't find a good method to get all blogs from all users. #### Data pool - Blogs amount: $2059$ - Comments amount: $297853$ - *Root comments: $117293$ *Root comments are comments that are not a reply to another comment #### The most up-voted comments <spoiler summary=""> $1....
of the comment](/predownloaded/f1 /e6/f1e6e834af349607f47a7ce45bffe6bcb347f39d.png)

Full text and comments »

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

133.
By kpw29, 7 years ago, In English
Meet IT Winter Workshops 2020 are for you! ![ ](/predownloaded/77/f1/77f168719a11e118802f4bc2d9519a8c3d38865b.png) Remember **Camp IT**? Well, it’s ok if not, because we’re organizing a new one and the summer one won’t be worth mentioning compared to this one anyways. There won’t only be programming tasks on **IOI** level, but also **ML workshops**! You might think they won’t be challenging enough for you... The advanced level of the workshops will be hosted by profesionalists with years of experience (for example, Marek Bardoński from AI Revolution). They are prepared to grasp interest not only needs of students with little or no experience in Machine Learning, but also of those who have already worked in ML projects or interned at companies such as Boston Consulting Group or Facebook. If you don’t already know, apart from the tasks and ML workshops there will be fun Evening Activities &mdash; as if the like-minded people, with whom you can talk for hours, was not enough. **Everyone 16-21 years** old can apply (if...
![ ](/predownloaded/77/f1/77f168719a11e118802f4bc2d9519a8c3d38865b.png)

Full text and comments »

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

134.
By Karan2116, history, 11 years ago, In English
Everything About Dynamic Programming **I decided to gather some good material on the web related to DP and found some good explanation by svg on topcoder forums..Hence wrote this blog.Will format it when i get time.** ![ ](http://codeforces.me/predownloaded/2c/af/2caf058ab9cf6db0f875c573fb0d6e73de572122.png) **Problem:** About 25% of all SRM problems have the "Dynamic Programming" category tag. The DP problems are popular among problemsetters because each DP problem is original in some sense and you have to think hard to invent the solution for it. Since dynamic programming is so popular, it is perhaps the most important method to master in algorithm competitions. The easiest way to learn the DP principle is by examples. The current recipe contains a few DP examples, but unexperienced reader is advised to refer to other DP tutorials to make the understanding easier. You can find a lot of DP examples and explanations in an excellent tutorial Dynamic Programming: From novice to advanced by Dumitru. The purpose ...
either f1(A) or f2(A) or f3(A) or ... or fk(A) then we can change state domain from (A,B) to (A,i) where, number is required. The recurrent equation looks like R[s] = F1(R[i], R[j], ..., R[k]) + F2(R[u], R[v, recurrent equation is something like: R[s] = min(F1(R[u], u), F2(R[v], v), ..., Fk(R[w], w)). In, . Both coins and LCS examples are optimization-type. The recurrent equation looks like R[s] = min(F1(R[i

Full text and comments »

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

135.
By SPyofgame, history, 6 years ago, In English
Divisor Sum Implementations ### I found these implementations ^^ > Sorry, I am not sure if there are some corner cases or I calculated wrong complexity. If there are, please correct me. I am wondering if there are some other implementations ^^ (you can comment below and I will add to the post) <spoiler summary="Implementation 0: Trivial"> ~~~ /// Implementation: Trivial /// Time Complexity: O(n) /// Space Complexity: O(1) int main() { int n; cin >> n; ll sum = 0; /// n = sigma(x | n % x == 0) for (int i = 1; i <= n; ++i) /// O(n) if (n % i == 0) /// If (i) is a divisor sum += i; cout << sum; return 0; } ~~~ </spoiler> <spoiler summary="Implementation 1: Optimized Trivial"> ~~~ /// Implementation: Optimized Trivial /// Time Complexity: O(√n) /// Space Complexity: O(1) typedef long long ll; int main() { ll n; cin >> n; int sqrtn = sqrt(n); ll sum = 0; ...
int main() /// O(n * log5(n)) { ll n; cin >> n; ll sum = 1; /// n = p1 ^ f1, ll sum = 1; /// n = p1 ^ f1 * p2 ^ 2 * ... * pk ^ fk /// sum = ∏(divisor prime p){ p ^ (f

Full text and comments »

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

136.
By kien_coi_1997, 12 years ago, In English
Segment tree with insertion and deletion operators. I have created this structure successfully some weeks ago, and I want to share it with you. This structure is **fast, efficient**, and it is only the improvement from segment tree. I have used this code to submit to two problems, one is in SPOJ, one is in CF. For simpliest example, consider the problem QMAX3VN on SPOJ. (http://www.spoj.com/problems/QMAX3VN/) There are two operators: _Insert_ X before Y-th element, and _find Max_ between X-th element and Y-th element (inclusively). Firstly, I use a variant of segment tree, allow us to insert element and access elements by indexes. Each node will have two childs: Left[Node] and Right[Node], by default, they are 0 (NULL). To be indexable, we must maintain array Size[]. ~~~~~ #include <stdio.h> #include <iostream> #include <algorithm> using namespace std; #define long long long #define f1(i,n) for (int i=1; i<=n; i++) #define f0(i,n) for (int i=0; i<n; i++) #define N 400005 #define oo 0x3c3c3c3c int Max[N], Size[N], ...
#define long long long #define f1(i,n) for (int i=1; i<=n; i++) #define f0(i,n) for (int i=0; i

Full text and comments »

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

137.
By Sarvesh0955, history, 11 months ago, In English
CodePlus Long 2025 Editorial Welcome to the Editorial of CodelPlus Long 2025. CodePlus Long Contest is a 2-day coding competition featuring a mix of educational and challenging problems. It allows participants to learn, practice, and compete to enhance their problem-solving skills. You can attempt the contest [here](https://codeforces.me/contestInvitation/940e1bd9749a95d26fbca52cd74512d1b505f65e). (Many Original and Challenging problems, you can give it a try :) ) The problems were authored and prepared by [user:pranavsingh0111,2025-10-14],[user:Sarvesh0955,2025-10-16],[user:Ragnar21,2025-10-16],[user:rndascode,2025-10-16],[user:ankitgarg2105,2025-5-14],[user:utk_09,2025-8-14]. We would also like to thank, [user:Rishabh_king,2025-10-16] for testing. Author : [user:Sarvesh0955,2025-10-14] <spoiler summary="Problem A"> This problem can be solved in several ways; one approach is as follows: --- ### Graph Construction Construct a new graph ( **nodes n+1 to 2n** ) where all edge weights ar...
### 1) Dynamic Programming (DP)

Full text and comments »

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

138.
By vovuh, history, 8 years ago, translation, In English
Codeforces Round #521 (Div. 3) I am so sorry about very long gaps between the contests but I really don't have enough time to prepare the problems. So... &lt;copy-pasted-part&gt; Hello! [contest:1077] will start at [contest_time:1077]. You will be offered 6 or 7 problems with expected difficulties to compose an interesting competition for participants with ratings up to 1600. Probably, participants from the first division will not be at all interested by this problems. And for 1600-1899 the problems will be too easy. However, all of you who wish to take part and have rating 1600 or higher, can register for the round unofficially. The round will be hosted by rules of educational rounds (extended ACM-ICPC). Thus, during the round, solutions will be judged on preliminary tests, and after the round it will be a 12-hour phase of open hacks. I tried to make strong tests &mdash; just like you will be upset if many solutions fail after the contest is over. You will be given 6 or 7 problems and 2 hours to solv...
>[user:Programmist_111, 2018-11-17] 0:12 F1 [user:happ1, 2018

Full text and comments »

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

139.
By shestimerk, 9 years ago, In Russian
Анонс Tinkoff Challenge Про Tinkoff.ru ============== Мы самый технологичный IT-банк России, работаем онлайн, без отделений. Больше всего похожи на IT-компанию: молодые сотрудники, молодой менеджмент, отсутствие дресс-кода на большинстве позиций, минимум бюрократии, классный офис, высокая зарплата за ум и талант. Мы делаем финансовые продукты, которые упрощают жизнь миллионам людей. Мы заботимся о клиентах и сотрудниках. Недавно переехали в новый офис с огромным спортзалом. В офисе есть несколько переговорных зон для проведения встреч, кухни. В офисе работает сервис по доставке здоровой еды, основанный одним из сотрудников. Работники могут заказать себе обед с вечера, а утром он окажется в холодильнике в офисе. В планах руководства — в ближайшие несколько месяцев открыть в офисе столовую. ![ ](http://codeforces.me/predownloaded/cd/1c/cd1c331abaac6234aac1443a40a7d5ea20809bcd.jpg) Мы знаем ценность аналитического ума и помогаем талантливым ребятам развиваться дальше. У нас есть своя бесплатная шко...
![ ](http://codeforces.me/predownloaded/f1 /d1/f1d139ee5fa4333aa82b2c5f3b139183683cc77c.jpg)

Full text and comments »

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

140.
By L_Wave, 7 months ago, In English
Cheaters Reported (This time, from div.1 top 100!) During Codeforces Round 1082 (Div. 1), we have noticed that a large number of accounts ranked top 100 have a suspicion of cheating. <spoiler summary="Examples"> - [user:LiFar,2026-02-28]'s submission of F1: [link](https://codeforces.me/contest/2201/submission/364100028) which has a complexity of $O(n)$. But he didn't submit F2! - [user:tickcross.y,2026-02-28] submitted exactly same code for F1 and F2 (which is very normal), but he submitted F2 15 minutes after F1! What is he checking about? [link &mdash; F1](https://codeforces.me/contest/2201/submission/364080736) and [link &mdash; F2](https://codeforces.me/contest/2201/submission/364086552) - [user:p_a_r_k_j_u_n_e,2026-02-28], submitted F2 with a same code of F1, but after 35min. - And so on... </spoiler> Though there is not enough clue to determine whether they used AI for assistance or not, it is clear that they literally didn't understand what the code was doing. Maybe they used AI, maybe they got the code from others...
- [user:LiFar,2026-02-28]'s submission of F1: [link](https, submission of F1: [link](https://codeforces.me/contest/2201/submission/364100028) which has a complexity

Full text and comments »

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

141.
By oweMeEternity, 9 months ago, In English
A Guide to Debugging Runtime Errors with Compiler Sanitizers We have all been there. You submit your solution, wait anxiously, and then see the dreaded Runtime Error on test 2. Is it an array out-of-bounds index? A signed integer overflow? A null pointer dereference? Usually, you have to stare at your code or add a dozen printf statements to find out. But there is a better way. ![ ](https://i.ibb.co.com/8g1j2NT9/Screenshot-2025-12-25-172753.jpg) ![ ](https://i.ibb.co.com/s9yBm35K/Screenshot-2025-12-25-16503f5.jpg) ![ ](https://i.ibb.co.com/ynHZFnPG/Screenshot-2025-12-25-165035.jpg) By using compiler sanitizers and debug flags, you can make your compiler tell you exactly which line caused the error and why. Here is how to set up a powerful debugging environment on both Linux and Windows. ### For Linux Users Linux makes this incredibly easy with GCC. Instead of your standard compilation command, use the following flags to catch errors at runtime. `g++ -g -O2 -fsanitize=undefined -fsanitize=address -fno-omit-frame-pointer -D_GLIB...
version. write `echo $(clang -dumpversion | cut -d. -f1)` to get it)**

Full text and comments »

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

142.
By pilliamw, history, 11 months ago, In English
Invitation to PHS Computing Olympiad (Fall 2025) ![ ](/predownloaded/6e/f1/6ef137ab66c0450ed55bb2d4248d363fff150969.png) Hi Codeforces! I'm excited to invite you to the Fall 2025 PHS Computing Olympiad, a programming contest run by the Poolesville High School computer team! The contest will take place on [October 25th, 2025 at 5:00PM (UTC)](https://www.timeanddate.com/worldclock/fixedtime.html?msg=PHS+Computing+Olympiad+Fall+2025&iso=20251025T17&p1=1440&ah=4) and last for four hours. ### Format & Difficulty The contest will be hosted on Codeforces and last for 4 hours. There will be a Standard Division and an Advanced Division, roughly corresponding to Div4 and Div2 difficulty, respectively. Each division will contain $12$ to $15$ problems, and all problems are equally weighted with a time penalty of 20 minutes for wrong submission. You can choose to register either as a solo participant or as a team of two. This contest is aimed towards participants with $< 2100$ rating, but anyone is welcome to participate! ### Pr...
![ ](/predownloaded/6e/f1/6ef137ab66c0450ed55bb2d4248d363fff150969.png)

Full text and comments »

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

143.
By Jamshed11, history, 3 years ago, In English
Invitation to Codelicious Hello Codeforces! ![ ](/predownloaded/f1/df/f1dfc33380205bf5075da54ea61cebedadf4d5a0.jpg) Craving for a coding challenge? Get ready because Pulzion Tech or Treat is throwing a feast full of Codelicious treats for you to dig your fangs into. I invite all of you to join and take part in Codelicious, the worldwide coding challenge featured in Pulzion Tech or Treat, the annual flagship event of PICT ACM Student Chapter. You will be served 6-8 problems in a time frame of 2 hours to solve and savor them. Special thanks to [user:yashss1,2023-10-25], [user:admiralpunk111,2023-10-25], [user:harshpatil2104,2023-10-25], [user:vijaymunde_02,2023-10-25], [user:Nachiket,2023-10-25], [user:adsulswapnil27,2023-10-25], [user:shreekargade2004,2023-10-25] for their valuable contribution. **Registrations:** **Only registrations via the website will be considered valid and will be eligible for the prizes.** To register, please refer to our website: [https://pulzion.co.in/](https://p...
![ ](/predownloaded/f1/df/f1dfc33380205bf5075da54ea61cebedadf4d5a0.jpg)

Full text and comments »

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

144.
By NextBB, history, 7 years ago, translation, In English
How rating of Codeforces users have been stolen By randomly looking at the submissions from the last rounds, I discovered the fact of the cheating by the user [user:Dedalius,2020-02-24]. The automatic anti-cheat system did not detect this. However, if you carefully look at the submissions of this user, you will find a lot of useless code. Interested in this fact, I found the original author of these codes. It was user [user:Tematop,2020-02-24]. ![ ](/predownloaded/f1/f0/f1f0273cc3cbc3d67b7d04b6c274b3c98476a671.png) ![ ](/predownloaded/6e/94/6e9438332bc9a073c25ca8dbf4bc2fa6687e82e8.png) You can see the coinciding time of the submissions, and also below there are the submissions of users. For example task 1315С: [submission:71714491] [submission:71713703] To hide the fact of cheating, [user:Dedalius,2020-02-24] used useless code. ![ ](/predownloaded/36/5a/365a568d0059a9d23c8847b9fd398fea33116d2a.png) By comparing the submissions, you can notice the obvious fact of cheating. If you look at more packages, it bec...
![ ](/predownloaded/f1/f0/f1f0273cc3cbc3d67b7d04b6c274b3c98476a671.png) ![ ](/predownloaded/6e/94

Full text and comments »

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

145.
By pskobx, 6 weeks ago, In English
Codeforces Round 1117 (Div. 2) Editorial Thank you for participating in our round! We hope you enjoyed the problems. <!-- <spoiler summary="Fun facts"> 1. A total of 30 problems were proposed for this round 2. E was proposed as C, and C as B </spoiler> --> [problem:2257A] Idea: [user:egorka5opka,2026-08-17] <spoiler summary="Solution"> Note that adding abbreviations to the set $S$ does not create any new possibilities for creating new abbreviations, because a word starting with that letter already exists. Therefore, for each of the 26 letters, we can remember that there is a word that begins with it, and then go through all the abbreviations and check each letter. </spoiler> <spoiler summary="Code"> [submission:387467084] </spoiler> <spoiler summary="Rate the problem"> Amazing Good Ok Bad Terrible </spoiler> [problem: 2257B] Idea: [user:egorka5opka,2026-08-17] <spoiler summary="...
Surprisingly, the main problem with the solution from F1 is memory, each block, calculate the matrix of the entire block using the same merging formula as inF1. Then

Full text and comments »

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

146.
By CodemastersIntl, 3 years ago, In Russian
Турнир по программированию среди студентов Codemasters Code Cup 2023 Привет, Codeforces! Приглашаем принять участие в [Codemasters Code Cup 2023](https://www.codecup.online/) &mdash; Турнире по программированию среди студентов. Соревнования включают в себя отборочный раунд, который будет проходить онлайн, а также финал и награждение, которые состоятся в Туле. ![ ](/predownloaded/f1/0b/f10b7a37cf77c81552a6c3afe51641683ffa79eb.png) [Codemasters Code Cup](https://www.codecup.online/) &mdash; турнир, который проводит компания Codemasters International уже четвертый год подряд. Первые три соревнования проводились исключительно в Саранске и Туле, в этом году мы приглашаем к участию студентов со всей России. Соревнование будет организовано в партнерстве с Тульским государственным университетом и Центром олимпиадной подготовки по программированию МГУ им. Н.П. Огарёва. В турнире Сodemasters Code Cup могут принять [участие](https://www.codecup.online/#registration) **студенты и аспиранты очной формы обучения российских учебных заведений в возрасте от 17...
![ ](/predownloaded/f1/0b/f10b7a37cf77c81552a6c3afe51641683ffa79eb.png)

Full text and comments »

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

147.
By george_stelian, history, 3 months ago, In English
"Adolescent Grigore Moisil" (AGM) International Programming Contest 2026 Dear Codeforces, We are excited to announce the XII-th Edition of the AGM International Programming Contest! AGM is a team programming contest for high school students (teams of up to 3 members, ICPC-style). Starting with this edition, the contest will consist of a single onsite round in Bucharest, Romania. <img src="/predownloaded/f1/b9/f1b9381688c78aaeeca80b818864961dbd741dae.jpeg" style="float:right;width:40%;height:40%;margin:5px"> Key dates: - Registration opens: June 26, 2026, 17:00 (GMT+3) - Participation confirmation deadline: July 10, 2026, 17:00 (GMT+3) - Participants list announced: August 5, 2026, 17:00 (GMT+3) - Contest dates: September 5–6, 2026 Important changes: - No Qualification Round - Registration is on a first come, first served basis - Participation is onsite only in Bucharest, Romania The top teams will receive diplomas and cash prizes. [Link to the Registration Form.](https://docs.google.com/forms/d/e/1FAIpQLSda2BUk_NS1t8IXU_0pc33...

Full text and comments »

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

148.
By MikaMisono, history, 4 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...
){ return x.pf1; int e,v,l,r; string mv, f1; int e,v,l,r; string mv; }; struct res

Full text and comments »

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

149.
By PaciukZvichainyi, 2 years ago, In English
Busy but Master #1 Alternative name: "Road to Master when you don't have time". Episode 1: August 2024 ### Preface I used to be a competitive programmer since ~8th grade. When covid started and we all had more time to solve problems, I actually began to see some progress in cp. I have two bronzes in the UOI (1 place to silver x2, sad). That's not too bad, and I probably don't regret it (though if I could go back, I'd definitely change my attitude). I always had one milestone: to become a Master (yellow) on Codeforces. As you can see, my max rating is 3 points below Master. Pretty sad. I need to fix that. But a few things happened compared to 2020: 1. 4 years have passed. 2. I'm in my last year of university. 3. I have a swe job. So, I definitely have much less free time than I did in 2020. This is probably the last period in my life when I have at least some time to improve in cp, and I need to use it mindfully and close all my competitive programming goals (that are still achievable)...
grind period, I try not to watch YouTube or surf social media (watch f1 is allowed), I stopped going

Full text and comments »

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

150.
By MiptLited, 7 years ago, In English
Registration is open for the competitive programming workshop Discover Riga 2019 Competitive programming workshop **Discover Riga 2019 by Moscow Workshops ICPC** and University of Latvia will be held from 21 to 28 September ![ ](/predownloaded/3e/38/3e386538963f11cdc1e33e6e35474aba77601a55.jpg) Students will stay in a four-star hotel 5 minutes walk from the University of Latvia where educational process will be organized. ![ ](/predownloaded/7c/f1/7cf13fc6574e25598740a5fff17a32ac704e0cc0.jpg) ![ ](/predownloaded/33/39/33398efa6afe77ef16b28b5b46c475a9b428ba6b.jpg) ![ ](/predownloaded/8f/d8/8fd892dd0962731a0dd845169d401c6ccfcec2fc.jpg) ![ ](/predownloaded/b7/e3/b7e3349501684c9304e898bb04d59a10259a1f0a.jpg) At the weekend participants will be able to visit the Old Town, the oldest district of Riga (it is included in the UNESCO world heritage list). ![ ](/predownloaded/ac/56/ac562707f3907c703f60e7d01584bdb97893b0b7.jpg) Students have the opportunity to decide where to live and how to eat, because participation in the training camp involves **two fo...
![ ](/predownloaded/7c/f1/7cf13fc6574e25598740a5fff17a32ac704e0cc0.jpg) ![ ](/predownloaded/33/39

Full text and comments »

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

151.
By maanassehgal, history, 7 months ago, In English
Request for banning Codeforces Master (longago_06) Hi [user:chromate00,2026-02-23], [user:MikeMirzayanov,2026-02-23], Please get this ID banned: https://codeforces.me/profile/longago_06 He's Ayush Ranjan from KIIT and has been CHEATING openly from a long time without getting flagged. He has given today's Div1 contest and ranked 70, reaching Master with a delta of +238. Here are some proofs and suspicous behaviors: - He submitted today's F1 in Div1, if you submit that same solution to F2, it will get an AC, but he didn't submit it to avoid getting an even higher rank. Here's the solution link for your reference: https://codeforces.me/contest/2201/submission/364101785 - His problem solving graphs don't match with what rating problems he's solving in contests. - He is from India and recently changed his location to Japan, and added himself to Jiangly Fan Club. - There was this linkedin blog posted by someone where all other proofs are mentioned: https://www.linkedin.com/posts/saurabh-kumar-84857538b_stopcheating-cod...
- He submitted today's F1 in Div1, if you submit that same solution to F2, it will get an AC, but

Full text and comments »

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

152.
By sslotin, history, 9 years ago, In English
CF and IOI performance So, I scraped stats.ioinformatics.org for some data to estimate the correlation between CF rating and place you get at IOI. I guess many will find these plots interesting. ![ ](/predownloaded/f4/ec/f4ecc2d20be6b62717d25e54a23b2b846279ed8f.png) ![ ](/predownloaded/8a/6e/8a6e1c65f50b122adde7812526823b5e3f79600d.png) ![ ](/predownloaded/24/21/2421711828a68ceccfe2dbcd61832ac85b1148d1.png) ![ ](/predownloaded/06/a9/06a931fcac4aeee59155a263bafd27cb454f6c6f.png) ![ ](/predownloaded/c2/56/c2567ac9b00dba400d1818b058cf1320381caaa9.png) ![ ](/predownloaded/f1/59/f15988ce0b21528321300f3624cb924a32a6c46f.png) I only considered contestants who had $\geq 5$ rated contests during last 2 years before 1st of August of the relevant year. Years 2013-2017 had more than 120 such contestants, but IOI '12 had only 55 and earlier IOIs had even less, so I didn't go any further. By "normalized # of inversions" I mean this: $\frac{|\{(i, j) \; \mid \; rank_i < rank_j, \; rating_i > rating_j \}|}{\fr...
) ![ ](/predownloaded/c2/56/c2567ac9b00dba400d1818b058cf1320381caaa9.png) ![ ](/predownloaded/f1/59

Full text and comments »

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

153.
By SummerSky, 9 years ago, In English
Solutions to Codeforces Beta Round #35, A, B, C, D A. Shell Game The solution is straightforward by swapping the integers as required by the problem. B. Warehouse The warehouse can be viewed as a two-dimensional array. If '+1' is met, we just enumerate the positions from the given one to the final one in the order required by the problem, and put the drink into the first empty box if there exist any. If '-1' is met, we can enumerate from the first position to the final one, and if any one that has the same ID is found, we just output the corresponding position; otherwise output "-1 -1". C. Fire Again Suppose that the position at which the fire begins is denoted as (f1,f2). Then, for any position (r,c), the fire gets to it after time |r-f1|+|c-f2|, which is referred to as Manhattan Distance as far as I consider. Therefore, we can first enumerate the positions where fire starts, and for each such position, we enumerate every feasible position and calculate the time when the fire arrives at it. As all the fires start at the...
Later, I noticed that some people used another simpler method. The formula |r-f1 |+|c-f2| in fact, Suppose that the position at which the fire begins is denoted as (f1,f2). Then, for any position (r

Full text and comments »

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

154.
By shivansh1102, 3 years ago, In English
CodeNite Sept 2023, organized by CodeClub, IIT Kharagpur [CodeClub, IIT Kharagpur](https://www.facebook.com/CodeClub.IITKGP) brings to you **CodeNite Sept 2023** sponsored by **Coding Ninjas**, a competitive programming contest with individual participation to be held on **CodeChef**. This contest is **OPEN TO ALL** irrespective of college, year of study, department. Details are as follows: **Date**: Friday, 8th Sept 2023 **Time**: 9PM to 11:30PM [GMT+5:30] **Platform**: CodeChef **Prizes**: 1st &mdash; Rs. 4000 2nd &mdash; Rs. 2500 3rd &mdash; Rs. 1500 4th &mdash; Rs. 1000 5th &mdash; Rs. 1000 **Setters & Testers** : [user:anubhavdhar,2023-09-04], [user:shuklaji1102,2023-09-04], [user:anitm,2023-09-04], [user:harshith_04,2023-09-04], [user:picramide,2023-09-04], [user:aryansanghi,2023-09-04], [user:gayathri_anant,2023-09-04], [user:harshit_jain52,2023-09-04] **Contest Page**: [https://www.codechef.com/CONT2023](https://www.codechef.com/CONT2023) Register here if you want to take part and be eligible fo...
![ ](/predownloaded/18/f1/18f15f79be96e56f5fbc6192d51f627a9ea73453.jpg)

Full text and comments »

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

155.
By saanTH, history, 2 months ago, In English
Beyond the Contest: How Competitive Programming Powers Real Life and Sports If you've ever done competitive programming (CP), you know the drill — segment trees at 2 AM, dynamic programming (DP) transitions that make your head spin, graphs that refuse to be traversed efficiently. It's easy to dismiss this as "just contest stuff." But the truth is, almost every algorithm you grind on Codeforces or LeetCode has a real job somewhere in the world — and one of the most fun places to see this is sports. This post covers two things: Everyday, real-life uses of classic CP concepts. A deep dive into how algorithms — especially DP — quietly run the show in cricket, tennis, basketball, football, chess, and more. **Part 1: CP Concepts You Already Know, Working in the Real World** **** **Sorting & Searching** **** Every time you sort products by price on Amazon or search for a contact on your phone, you're using variants of merge sort, quicksort, or binary search. Databases use B-trees (a generalization of binary search trees) to fetch records in logari...
an F1 team win a race by seconds., system, NFL's fourth-down calculator, and F1 pit strategy as answers. CP isn't just an academic, — deciding cricket targets, football fourth-down calls, and F1 pit stops.

Full text and comments »

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

156.
By magnified, history, 4 years ago, In English
Editorial of Dytechlab Cup 2022 > It has been a wild ride the final 24 hours in the preparation of this contest! And we really hope you liked the problemset we gave today! ## [problem:1737A] Author: [user:low_,2022-10-07] <spoiler summary="Tutorial"> [tutorial:1737A] </spoiler> <spoiler summary="Solution snippet ( low_ C++)"> ~~~~~ ... void execute(int test_number) { cin>>n>>k>>str; vector <int> count_char(26, 0); for (char c: str) count_char[c - 'a']++; string ans = ""; for (int i = 0; i < min(25, n/k); i++) { while (k - ans.size() > count_char[i]) { ans.push_back(i + 'a'); } } char c = 'a' + min(n / k, 25); while (k > ans.size()) { ans += c; } reverse(ans.begin(), ans.end()); cout << ans << "\n"; } ... ~~~~~ </spoiler> ## [problem:1737B] Author: [user:low_,2022-10-07] <spoiler summary="Tutorial"> [tutorial:1737B] </spoiler> <spoiler summary="Solution snippet (low_, C++)"> ~~~~~ ... ll l, r; ll bs_sqrt(ll x) { l...
[i])f1(i - 1); } }, void f1(int x) { int n = a.size(); for(int i = 0; i < n; i++)a.push_back(a[i]); for(int i

Full text and comments »

Tutorial of Dytechlab Cup 2022
  • Vote: I like it
  • +38
  • Vote: I do not like it

157.
By slycelote, 16 years ago, translation, In English
Codeforces Beta Round #23 tutorial <h3>A. <a href="../../../contest/23/problem/A">You're given a string...</a></h3><br />Iterate over all substrings, starting with the longest ones, and for each one count the number of appearances. The complexity is $O(L^4)$ with a small multiplicative constant.<br />[cut]<br /><h3>B. <a href="../../../contest/23/problem/B">Party</a></h3><br />It's clear that at least one person (the one with the least number of friends) will have to leave. We claim that at least two persons will leave. Indeed, suppose that only one person left, and he had $d$ friends. Then all other people had more than $d$ friends before he left, and after that they had less than $d+1$ friends, i.e. not more than $d$. So, his leaving influenced the number of friends for every other person, which means that he was friends with everyone: $d=N-1$. But he has fewer friends than everyone — a contradiction.<br /><br />So, the answer is not more than $N-2$. We'll prove that it's possible for $N-2$ people to stay (of course, ...
src="/predownloaded/f1/a7/f1a7995e4a3d367abadaa8f9fae8a41615065dcc.png" style="max-width: 100.0

Full text and comments »

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

158.
By MisterGir, 3 years ago, In Russian
Разбор DIV 5 Этот контест [тык](https://codeforces.me/contestInvitation/f26ab82615ba78ed42d354682adc09c971834848) Спасибо пользователям codeforces за тестирования раунда . Авторские решения + маленький разбор A [тык](https://codeforces.me/contest/4/submission/218133417) B [тык](https://codeforces.me/contest/4/submission/218133483) C [тык](https://codeforces.me/contest/4/submission/218133654) D [тык](https://codeforces.me/contest/4/submission/218133852) E [тык](https://codeforces.me/contest/4/submission/218134076) F1 [тык](https://codeforces.me/contest/4/submission/218134399) F2 [тык](https://codeforces.me/contest/4/submission/218136309) G [тык](https://codeforces.me/contest/4/submission/218135721) I [тык](https://codeforces.me/contest/4/submission/218135857) Спасибо за коментарии [user:__Secret,2023-08-10] [user:Kalrddddd,2023-08-10] [user:Abracadaber,2023-08-10] [user:ibrosh,2023-08-10] [user:ivna,2023-08-10]
F1 [тык](https://codeforces.me/contest/4/submission/218134399)

Full text and comments »

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

159.
By vedant_vaidya_77, history, 2 years ago, In English
Invitation to The Game Of Codes 2.0 (DCC, NIT Agartala) ![ ](/predownloaded/ef/f1/eff10fbf34a27b0c7ea4795a4c407cada280215a.png) What's up competitive programmers :> Welcome, to another installment of The Game Of Codes. Get ready to unleash your coding skills as we present to you The Game Of Codes 2.0 : Space Exploration! Organized by the Developers & Coders Club and would like to invite you all for following events : - The Game Of Codes 2.0 Prelims, online on [Wednesday April 3, 2024 at 20:30 IST](https://www.timeanddate.com/worldclock/fixedtime.html?iso=20240403T2030&p1=176) - The Game Of Codes 2.0 Finals, onsite on 5th April. Prelims Contest Details Date & time : [Wednesday April 3, 2024 at 20:30 IST](https://www.timeanddate.com/worldclock/fixedtime.html?iso=20240403T2030&p1=176) Platform : Codeforces Penalty: 20 minutes for each wrong submission You will be offered 5 problems and 1.5 hours to solve them. We tried to make interesting, beautiful, problems with strong pretests. Top 15 teams will qualify for finals. ...
![ ](/predownloaded/ef/f1/eff10fbf34a27b0c7ea4795a4c407cada280215a.png)

Full text and comments »

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

160.
By DmitriyH, 13 years ago, In Russian
(?) Обновление на интервале + запрос на интервале Возможно ли реализовать универсальное дерево отрезков (или другую структуру данных), которое поддерживает модификацию на интервале и запрос на интервале?<br/> Под универсальным, подразумевается реализация в виде шаблона, у которого функция «комбинирования значений» (F1) и функция «комбинирования модификаций» (F2) являются параметрами шаблона.<br/> Например:<br/> 1) (запрос минимума/присвоение на отрезке): F1 = min, F2 = assign<br/> 2) (запрос XOR-a/прибавление на отрезка): F1 = XOR, F2 = add<br/> С более частными случаями ((обновление значения/запрос отрезка), (обновление отрезка/запрос значения)) обобщенная реализация, вроде, получается, но (обновление отрезка/запрос отрезка) &mdash; ни в какую. И что-то мне подсказывает, что либо это невозможно, либо F1 и F2 должны обладать какими-то дополнительными свойствами, либо нужная еще какая-нибудь функция F3..<br/> Другими словами: если это возможно, то как? и если нет, то какими дополнительными свойствами должны обладать F1 и ...
значений» (F1) и функция «комбинирования модификаций» (F2) являются параметрами шаблона., обладать F1 и F2, чтобы это было возможно? , реализация в виде шаблона, у которого функция «комбинирования значений» (F1) и функция «комбинирования, 1) (запрос минимума/присвоение на отрезке): F1 = min, F2 = assign 2) (запрос XOR-a

Full text and comments »

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

161.
By vrintle, 5 years ago, In English
I am getting TLE in "Problem F1 - Guess the K-th Zero (Easy version)" of Codeforces Round #719 (Div. 3) Hello everyone! The following is my submission to [Problem F1 &mdash; Guess the K-th Zero (Easy version)](https://codeforces.me/contest/1520/problem/F1) [submission:118290089] It is showing me TLE, whereas when I run it locally, it passes the test case. I have also cross-checked my loops, but found nothing suspicious. I guess my logic is a bit different from others, but I will later work on that, firstly I want to know the reason for TLE.
I am getting TLE in "Problem F1 - Guess the K-th Zero (Easy version)" of Codeforces Round #719 (Div, Hello everyone! The following is my submission to [Problem F1 — Guess the K-th Zero (Easy, The following is my submission to [Problem F1 — Guess the K-th Zero (Easy version)](https

Full text and comments »

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

162.
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! Удач...

Full text and comments »

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

163.
By watchdogs132, history, 7 years ago, In English
Sum of proper divisors of numbers between the range (1 to 1e16)[Time limit exceeded] Link to question :https://www.spoj.com/problems/DIVSUM2/ My approach : -> Find all prime factors of the number below 1 million . Store the frequency of prime factors in a vector while repeatedly dividing the number by the factor , then use the formula to calculate the sum of factors . ->Now if there is a number left ,then that will be either prime or product of two primes. I try to check primality using Miller–Rabin. If number is not prime , then using rho-pollard , I try to generate one of the prime factors , divide to get another and then proceed accordingly. However, I am getting TLE. I would like to know where I am going wrong . Is it the implementation or the approach ? Thank you. ~~~~~ #include<bits/stdc++.h> using namespace std; #define MOD 10000000007 using ll = unsigned long long ; const ll million=1000000; vector<ll>v(50000); ll pow_expo(ll a,ll b) { ll res=1; while(b>0) { if(b&1) res=res*a; a=...
) { int f1=rho_pollard(n); int f2=n/f1; sum*=(f1+f2+2

Full text and comments »

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

164.
By shadow_47, history, 4 years ago, In English
Alternating Strings CodeChef Starters 44 Out of all the problems that were present in CodeChef Starters 44. I found this problem to be intriguing, the problem in itself is not difficult but the constraints require the solver to find a formula in O(1) time. So let's start with the problem [link](https://www.codechef.com/problems-old/ALT7STR) To start with the problem it will be really easy if we think of the string like this 12233344445555... N is the length of the string, and before starting let's define some functions - $ f1(N) = \dfrac{N.(N+1)}{2} $ - $ f2(N) = \dfrac{N.(N+1).(2N+1)}{6} $ - $ c(N) = $ No. of times N is present in the string So the first step would be to find the smallest N' such that $ \dfrac{N'.(N'+1)}{2} > N $ We can use binary search to do this step. For now, let's ignore the last number N' in the string because it will either be partially present or not present in the string, Something like this 12233344, N' = 4(partially present) and 122333, N' = 4(not present) ### Step 1 &mdash; ...
$ B(S) = \sum\limits_{i = 1}^{N'-1}i^2.f1(i) - \sum\limits_{i = 1}^{N'-1}i.f2(i) $, $ L(S) = c(N'). \left( N'.f1(i) - f2(i) \right) $, ').\left( N'.f1(i) - f2(i) \right) $, - $ f1(N) = \dfrac{N.(N+1)}{2} $ - $ f2(N) = \dfrac{N.(N+1).(2N+1)}{6} $ - $ c(N) = $ No. of, .f1(i) - \sum\limits_{i = 1}^{N'-1}i.f2(i) + c(N').\left( N'.f1(i) - f2(i) \right) $, Now, $ B(S) = - \sum\limits_{i = 1}^{N'-1}i.f2(i) - \left( - \sum\limits_{i = 1}^{N'-1}i^2.f1(i

Full text and comments »

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

165.
By highonjuice, history, 5 years ago, In English
Back to green I guess Kinda sad, but I'm probably going to going back to pupil. I messed up pretty badly on the second problem and was overthinking during the process. ![ ](/predownloaded/ec/67/ec67fee4912b229681ce4b6b5acd9ddbb33e03a0.jpg) On the third problem, there was an interesting solution that involved a greedy approach that was pretty cool, but on the fourth problem, I got too greedy. I had 30 min on the clock, definitely not enough time for a C problem, but I thought of an O(N) solution that could pass both D1 and D2. Maybe, just maybe I could do it... ![ ](/predownloaded/70/f1/70f1529965758789a529feffb5616e052e50ee40.jpg) Pretests Failed When it was the last moment, I hurried and tried the brute force approach involving doing all possible edges (using information from Union Find), but couldn't make it in time. I was really close. I knew that the optimal solution had to involve a tree, and required all vertices to be in their own set. Sadly, this info was not enough. Oh well, I wi...
![ ](/predownloaded/70/f1/70f1529965758789a529feffb5616e052e50ee40.jpg)

Full text and comments »

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

166.
By sufiyankhan27764, history, 12 months ago, In English
LLM(large language model) Large Multimodal Models (LMMs) – Detailed Overview 1. Introduction to LMMs Large Multimodal Models (LMMs) are an evolution of Large Language Models (LLMs). Unlike LLMs, which process only text, LMMs handle multiple modalities such as text, images, audio, video, and sometimes even structured data. Their core idea is to unify representation learning across modalities, allowing cross-modal reasoning and understanding. They are foundational models powering systems like GPT-4V (vision), Gemini, LLaVA, Kosmos, Flamingo, CLIP, and ImageBind. The ability to reason over multimodal data makes them crucial for AI applications in robotics, autonomous driving, healthcare imaging, multimodal search, and interactive AI systems. 2. Why Multimodality? Human intelligence is inherently multimodal. We process language, vision, sound, and spatial reasoning together seamlessly. LMMs aim to replicate this ability in artificial systems. A single modality (e.g., text-only) limits...
F1/Exact Match for multimodal QA.

Full text and comments »

Tags llm
  • Vote: I like it
  • -37
  • Vote: I do not like it

167.
By RussianCodeCup, 11 years ago, In Russian
Russian Code Cup 2015 — Qual 1 — Разбор задач <p> Всем привет! <p> Мы рады представить вашему вниманию разбор задач первого квалификационного раунда Russian Code Cup и заодно напомнить, что тем, кто не смог пройти квалификацию с первого раза, стоит принять участие во втором квалификационном раунде, который состоится [25 апреля в 12-00 по московскому времени](http://www.timeanddate.com/worldclock/fixedtime.html?msg=Russian+Code+Cup+2015+-+Qual+2&iso=20150425T12&p1=166&ah=2). <h2>Задача A. Магические карточки.</h2> <b>Идея:</b> Виталий Аксёнов.<br> <b>Реализация:</b> Григорий Шовкопляс.<br> <b>Разбор:</b> Григорий Шовкопляс.<br> <p> В задаче требуется проверить, верно ли, что Гриша в любом случае выиграет раунд, независимо от выбранных карточек. </p> <p> Рассмотрим случай, когда у Гриши будут выбраны <i>l</i> минимальных карточек, а у Димы <i>l</i> максимальных. Очевидно, что если в этом случае Гриша выиграет, то он выиграет в любом другом, так как если заменить среди выбранных любую к...
точек, например описанной на

Full text and comments »

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

168.
By sru_31, history, 5 years ago, In English
DESHAW Online Coding Test Today we had Deshaw online coding test, 1st question had 25 mins time limit, 2nd and 3rd have 35 mins time limit. Q1: You are given a vector of strings v and a string s. Length of s= 26. 1<=v.size()<=2*(1e4); max_length of string<=100 All strings in v may or may not have the same length. string s contains only lowercase English alphabets. All the characters in the string s are in the increasing order of value of the character.Let's say s="abfde" , it means value of 'a'< value of 'b'<value of 'f' <value of 'd' and so on. Now there's a competition going on, let's say v={"ab","abdf","abe"} in the first round every string uses the character "a" and as all the strings provide same value they proceed to the next round, in the second round every string uses char "b" and proceed to third round, Now in third round string "ab" gets eliminated because it doesn't have any character left, now if we compare the third character of strings {"abdf","abe"}, value of 'e'>value of ...
vegetable. Let's say customer buys fruits {f1,f3,f4} and vegetables {v1,v2,v5} profit is calculated as

Full text and comments »

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

169.
By nicotina04, 6 months ago, In English
Personalized Codeforces Training Service — Introducing CFRD! ![ ](/predownloaded/d7/9c/d79c752c4c908145f69d7c73dfbf0dd6d324877a.png) Hello Codeforces! I previously shared a problem recommendation app, and now I've rebuilt it into a much more powerful service. 1. Precise and Fast Per-Tag Skill Analysis ------------------------------------------ ![ ](/predownloaded/1e/63/1e63e0774d6dc786bc06542b1c21a29f07eac910.png) While the previous app only used an ML model to recommend problems, CFRD computes per-tag ratings using Bayesian estimation. You can instantly see which tags — greedy, DP, math, graphs — are your strengths and weaknesses. 2. Weekly Marathon — Your Weekly Training Plan ---------------------------------------------- ![ ](/predownloaded/00/8d/008daa053c7d5cb8a358eb7ae1e96d5c00921851.png) No more wondering what to practice! CFRD automatically prepares 8 problems for you every week. Just run the Weekly Marathon! 3. Round Drills — Round-Level Recommendations for Real Improvement -----------------------------...
----------------------------------------- ![ ](/predownloaded/20/f1 /20f18392babaea810aa247ed4ee6c6f9f019aad6.png) Prefer solving individual problems

Full text and comments »

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