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 -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...
/contest/53/problem/D (3) //Bubble sort http://codeforces.me/contest/58/problem/D (4) //[BUCKET, http://codeforces.me/contest/53/problem/D (3) //Bubble sort

Full text and comments »

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

2.
By ouuan, history, 7 years ago, In English
One thing you should know about comparators — Strict Weak Ordering Is "In C++, comparator should return false if its arguments are equal." [all you should know about comparators in C++](https://codeforces.me/blog/entry/70237)? **Definitely NOT.** ### What's the requirement of the custom comparator in STL? It should be a *Strict Weak Ordering*. In other words, let the comparator be $f$, and $f(x, y)=true$ means $x< y$, then: 1. $f(x, x)$ must be false (Irreflexivity) 2. If $f(x, y)$ is true, then $f(y, x)$ must be false. (Antisymmetry) 3. If $f(x, y)=true$ and $f(y, z)=true$, then $f(x, z)$ must be true. (Transitivity) 4. If $f(x, y)=false$, $f(y, x)=false$, $f(y, z)=false$ and $f(z, y)=false$, then $f(x, z)=false$ and $f(z, x)=false$. (Transitivity of equivalence) In fact, *Antisymmetry* can be deduced by *Irreflexivity* and *Transitivity*, so we can ignore it. Here are some examples that these rules aren't satisfied: | Comparator | Irreflexivity | Transitivity | Transitivity of equivalence | Example | | :----------: | ...
where *Transitivity of equivalence* is used in bubble sort and quicksort for example., : Otherwise, apply bubble sort to the optimal permutation to get a sorted array, $c_n$ won't be larger., In bubble sort, it is required that "if there are any inversions, at least one of them is two, sort and quicksort for example. In bubble sort, it is required that "if there are any inversions

Full text and comments »

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

3.
By flamestorm, 3 years ago, In English
April Fools Day Contest 2024 Editorial Thank you for participating in our contest! We hope you enjoyed it. Please let us know what you thought of the problems by voting! [problem:1952A] Idea: [user:flamestorm,2024-03-31] <spoiler summary="Hint"> Have you seen the "are you a robot" boxes on websites? </spoiler> <spoiler summary="Solution"> [problem:1952A] ------------------ If you select all the squares with traffic lights and read the corresponding letters from left-to-right, top-to-bottom, you get the text "$\texttt{print safety}$". So all you need to do is print the word $\texttt{safety}$. </spoiler> <spoiler summary="Feedback"> - Based problem - Based problem - Based problem </spoiler> [problem:1952B] Idea: [user:willy108,2024-03-31] <spoiler summary="Hint"> Can you interpret the question in the title another way? </spoiler> <spoiler summary="Solution"> [problem:1952B] ------------------ You just need to check if there ...
- Sort the array and output $a[k-1]$. We may use bubble sort for easier implementation., ]$. We may use bubble sort for easier implementation. ~~~~ yoink n yoink a bruh i is lowkey

Full text and comments »

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

4.
By LMydd0225, 14 months ago, In English
Codeforces Round 1052 (Div. 2) Editorial [problem:2146A] <spoiler summary="Hint 1"> Let's focus on the number of occurrences of each element: let $c_i$ be the number of time that element $i$ occurs in the array. To keep a subsequence is to decrease each $c_i$ by a non-negative integer. We need to make all the non-zero elements in $c$ the same while maximizing the sum of $c$. </spoiler> <spoiler summary="Hint 2"> For each integer $x$: suppose the value of all non-zero elements in $c$ is $x$, what is the length of the longest subsequence? <spoiler summary="Answer"> For those $c_i<x$, we decrease it to $0$; for those $c_i\ge x$, we decrease it to $x$. </spoiler> </spoiler> <spoiler summary="Tutorial"> [tutorial:2146A] </spoiler> <spoiler summary="Implementation"> By [user:Caylex,2025-09-21]. ```py def solve(): n = int(input()) ls = list(map(int, input().split())) a = [0] * n for x in ls: a[x - 1] += 1 a = sorted(a) s = sum(a) ans = s for i in ra...
Count the number of integers $i$ such that $ip_x$. In one round of bubble sort, Let's focus on bubble sort first. For an element $p_x$, how many rounds does it take to make all, ] Let's focus on bubble sort first. For an element $p_x$, how many rounds does

Full text and comments »

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

5.
By cry, 15 months ago, In English
CSES Additional Problems I (new problems only) Tutorial Hello Codeforces. I was stuck on a 3 hour flight with nothing to do, so what better way to spend my time than catching up on the new CSES problems. But it turns out I finished those too quick so I guess I'm writing the solutions for some of them here. No one probably asked. This will only cover the new problems from the 2025 update and in the **Additional Problems I** section. For old problem solutions you can probably find them somewhere on the internet. For new problems not in this section, some of their solutions are in [this blog](https://codeforces.me/blog/entry/142894). ### [Distinct Values Sum](https://cses.fi/problemset/task/3150/) <spoiler summary="Smash Me"> Consider each distinct value separately. Say we are focused on $x$ and denote the indices where $x$ occurs in $a$ as $b_1, b_2, \ldots, b_k$. We want to count the number of subarrays that covers at least one element in $b$. Let's break $[1, n]$ into intervals separated by each $b_i$, so we have intervals $[...
$a_i$ and its corresponding position in $b$. Since bubble sort is stable, we also must match the same, In bubble sort, if a smaller element is to the right of a larger, Read the solution to the previous problem for the bubble sort, ### [Bubble Sort Rounds II](https://cses.fi/problemset/task/3152), ### [Bubble Sort Rounds I](https://cses.fi/problemset/task/3151/), / $\mathcal{O}(n \log n)$ ### [Bubble Sort Rounds I](https://cses.fi/problemset/task

Full text and comments »

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

6.
By atodo, 5 years ago, In English
Codeforces Round #771 Editorial I hope you enjoyed the problems! You can give feedback on each problem and also choose your favourite below. This could help me and other problemsetters understand what type of problems you want to see on Codeforces. [problem:1638A]<br> <spoiler summary="Hint 1"> When is it best for the permutation to remain unchanged? </spoiler> <spoiler summary="Hint 2"> What elements are obviously optimal and should remain as they are? </spoiler> <spoiler summary="Hint 3"> Find the first non-optimal element. What's the best way to fix it? </spoiler> <spoiler summary="Tutorial"> Let $p_i$ be the first element such that $p_i \neq i$. For the prefix of elements $p_1=1,p_2=2, \dots ,p_{i-1}=i-1$ we do not need to change anything because it is already the minimum lexicographic, but we would like to have $i$ instead of $p_i$ on that position. The solution is to reverse segment $[i,j]$, where $p_j=i$. Notice that $i<j$ since $p_k=k$ for every $k<i$, so $p_k<p_j=i$ for every $...
"YES" in this case. What does the Bubble Sort algorithm, What does the Bubble Sort algorithm do here? Does it ever do an illegal, always possible to sort the sequence. We can for example perform Bubble Sort algorithm. Note that this

Full text and comments »

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

7.
By null_awe, 2 years ago, In English
Codeforces Global Round 26 Editorial Thank you for participating! We put a lot of effort into this contest. Special thanks to [user:TheScrasse,2024-06-08] for contributing to these problems. <spoiler summary="Rating Predictions"> | Person | A | B | C1 | C2 | D | E | F | G | H | |--------------------------------------------|------|------|------|------|------|------|------|------|------| | [user:null_awe,2024-06-08] | 800 | 1000 | 1200 | 1700 | 2200 | 2400 | 2500 | 2900 | 3400 | | [user:buffering,2024-06-08] | 800 | 1000 | 1300 | 1800 | 2300 | 2400 | 2600 | 3100 | 3500 | | [user:redpanda,2024-06-08] | 800 | 1100 | 1200 | 1800 | | | | | | | [user:thescrasse,2024-06-08] | 800 | 1000 | 1200 | 1600 | 2200 | 2500 | 2500 | 3100 | 3400 | | [user:bronze_coder,2024-06-08] | 800 | 1000 | 1600 | 1800 | 2400 | | | 2700 | 3500 | | [user:awesomeguy856,20...
are able to do this, we can bubble sort. For each number, position the divider in $O(n)$ moves, Because we are able to do this, we can bubble sort. For each number, position the divider in $O(n

Full text and comments »

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

8.
By tokitsukaze, 5 years ago, In English
Codeforces Round #789 Editorial [problem:1678A] Idea: [user:tokitsukaze,2022-05-08] <br /> Prepare: [user:tokitsukaze,2022-05-08] <spoiler summary="Tutorial"> We observe that when there is $0$ in the sequence, it is optimal to choose $0$ and any number other than $0$ for each operation. Therefore, when there is $0$ in the sequence, let $cnt$ be the number of $0$s, the answer is $n - cnt$. Otherwise, when $0$ does not exist in the sequence, there are two situations: 1. When there exist two equal numbers in the sequence, we can perform the operation $1$ time to convert it into the situation of having $0$ in the sequence. So the answer must be $n$. 2. When all numbers in the sequence are distinct, we can perform the operation $2$ times to convert it into the situation of having $0$ in the sequence. So the answer must be $n + 1$. </spoiler> <spoiler summary="Solution"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main(){ int t; scanf("%i",&t); while(t--){ int n; scan...
the current $v=[0,0,2,1,1]$, after once bubble sort, $v=[0,1,0,0,0]$. To avoid confusion, the, Consider counting $v$, we observe that each bubble sort will first make $v_i=\max(v_{i}-1,0)$, then, For example, if the current $v=[0,0,2,1,1]$, after once bubble sort, $v=[0,1,0,0,0]$., For the position $i(i\le k)$, it can be observed that after $k$ times of bubble sort , it is

Full text and comments »

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

9.
By fchirica, 13 years ago, In English
Codeforces Round #198 — Editorial [problem:340A] ------------------ You are given a range $[A, B]$. You're asked to compute fast how many numbers in the range are divisible by both $x$ and $y$. I'll present here an $O(log(max(x, y))$ solution. We made tests low so other not optimal solutions to pass as well. The solution refers to the original problem, where $x, y \le 10^9$. Firstly, we can simplify the problem. Suppose we can calculate how many numbers are divisible in range $[1, X]$ by both $x$ and $y$. Can this solve our task? The answer is yes. All numbers in range $[1, B]$ divisible by both numbers should be counted, except the numbers lower than $A$ (1, 2, ..., A &mdash; 1). But, as you can see, numbers lower than A divisible by both numbers are actually numbers from range [1, A &mdash; 1]. So the answer of our task is f(B) &mdash; f(A &mdash; 1), where f(X) is how many numbers from 1, 2, ..., X are divisible by both x and y. For calculate in $O(log(max(x, y))$ the f(X) we need some math. If you don't ...
the proof that bubble sort does sort correctly an array. To proof lemma 1, we need to show two things, **Div2 D / Div1 B** Suppose the reverse problem. You are given a bubble sort graph having $N, **Proof** We assume we know the proof that bubble sort does sort correctly an array. To proof lemma, 1. Every inversion will be swapped by bubble sort. 2. For each i < j when $a_i$ < $a_j$,bubble, To proof 1, if bubble sort wouldn't swap an inversion, the sequence wouldn't be sorted. But we know

Full text and comments »

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

10.
By .o., 12 years ago, In English
Good Bye 2014 Editorial First of all, sorry for the late editorial. I was too exhausted and immediately went to bed after the round finished, and didn't write the editorial. There are many pictures in this editorial, to cover up my poor English skills! If you have detected any errors or have questions, feel free to ask questions by comments. Unfortunately, the authors only know English, so we can't answer you if you write comments in Russian. ## [problem:500A] Let's assume that I am in the cell $i$ ($1 \le i \le n$). If $i \le n-1$, I have two choices: to stay at cell $i$, or to go to cell $(i + a_{i})$. If $i = t$, we are at the target cell, so I should print "YES" and terminate. If $i > t$, I cannot go to cell $t$ because I can't use the portal backwards, so one should print "NO" and terminate. Otherwise, I must go to cell $(i + a_{i})$. Using this method, I visit each cell at most once, and there are $n$ cells, so the problem can be solved in linear time. #### What is test 13? There are 9...
[bubble sort](http://en.wikipedia.org/wiki/Bubble_sort). Look at the picture below for easy, ), the values of $p_{i}$ and $p_{j}$ can be swapped, using a method similar to [ bubble sort](http

Full text and comments »

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

11.
By UnexpectedValue, history, 4 years ago, In English
A Time Complexity Guide **Introduction** Often in Competitive Programming, we have to choose between multiple algorithms/ approaches for a problem. How do we decide which algorithm is better and which algorithm to go for? Runnning an algorithm comes at the cost in the form of time taken or memory consumed. In this blog, we will try to compare algorithms or approaches based on their Time Complexity, which simply put is the time taken by them to run. So how do we compare the algorithms? Do we calculate the exact time taken by them to run? Or do we try to predict the time taken based on our input? These approaches to calculate Time Complexity can be called as _Experimental Analysis_ and _Theoretical Analysis_ respectively. [cut] **=========================================================================================================** **Big O Notation** The Big O Notation ($O()$) provides a mathematical notation to understand the complexity of an algorithm or to represent the complexity of an a...
7. $O(n^2)$ : 2-nested loops; Bubble/ Selection/ Insertion Sort 8. $O(n \cdot, STL sort has an average time complexity of $O(N \cdot log(N))$ while the Bubble Sort has an average, builtin C++ STL sort with the Bubble Sort. Bubble Sort is the simplest sorting algorithm that works by, can perform $10^7$ operations in one second, and we are told to sort an array of size $10^4$. We, with the Bubble Sort. Bubble Sort is the simplest sorting algorithm that works by repeatedly, ~~~~~ For n = 1000 Inbuilt Sort : 0 Bubble Sort : 2, ~~~~~ For n = 10000 Inbuilt Sort : 2 Bubble Sort : 202, ~~~~~ For n = 100000 Inbuilt Sort : 32 Bubble Sort : 19778, cout << "Bubble Sort : " << end1 - start1 << "\n"; return 0; } ~~~~~

Full text and comments »

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

12.
By Sul_A., history, 18 months ago, In English
New CSES Tasks Editorials Editorial for some of the new CSES tasks. Tasks that are trivial or too similar to already existing tasks are not included. Every time I solve a new nontrivial task, I will add it here. **NOTE: ONLY READ THE SOLUTIONS IF YOU ARE COMPLETELY STUCK AND OUT OF IDEAS. CSES tasks are the kinds of tasks you can solve at a random time by random chance. You might read a task today and solve it next week. Or next month. Or next 3 months. So read at your own risk.** ## Sorting & Searching <spoiler summary="Distinct Values Subsequences"> For each value $x$, we can include $0$ or $1$. If $f(x)$ is the number of times $x$ appears in the array, Then there are $f(x) + 1$ ways to pick $0$ or $1$ occurrences of $x$. Since every value is independent of every other values, we will take the product of $f(x) + 1$ over all $x$. This can be done with `std::map` or sorting. </spoiler> ## Dynamic Programming <spoiler summary="Mountain Range"> Let $L_i$ be the nearest greater element o...

Full text and comments »

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

13.
By Wind_Eagle, history, 5 years ago, translation, In English
How to train: why it's not enough to just do a lot of tasks Hello, Codeforces! I, like many of you, read blogs periodically. Lately, blogs from low-rated users who ask me how to raise their ratings have been catching my attention. I want to tell you a little bit about my opinion on these blogs. So what do these blogs look like? Usually this is a blog with a title something like <b>"I need help right now!"</b> or <b>"How to improve my rating, help me!"</b> When you open this blog, you see the most detailed description of the problem, such as: "I have solved 500 problems, but no improvement" or "I have solved 100 problems with rating >= 1500, but my rating is not increasing". And in the comments they usually write "you haven't solved enough, solve more" or "solve more difficult problems". <b>In my opinion, this is incorrect and misleads such users. So, imagine that you do not know anything at all about sports programming, or even about the basics of Olympic math. You at best (because many people don't even do that) have learned a programmin...
easy. Actually, understanding that an unsorted array can be sorted by a bubble sort in n * (n-1) / 2, , understanding that an unsorted array can be sorted by a bubble sort in n * (n-1) / 2 operations is not

Full text and comments »

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

14.
By AboAbdoMC, 3 years ago, In English
[EDITORIAL] Syrian Private Universities Collegiate Programming Contest 2023 [A &mdash; G Game](https://codeforces.me/gym/104426/problem/A) Author: [user:Blade-Master,2023-07-10] <spoiler summary="Tutorial"> </spoiler> <spoiler summary="Solution"> </spoiler> [B &mdash; Permutation Tree](https://codeforces.me/gym/104426/problem/B) Author: [user:Space-Time-,2023-07-10] <spoiler summary="Tutorial"> This problem is solved greedily. Let $v$ be the minimum unassigned node in the tree. We have to assign it the minimum possible value. This can be done by assigning each unassigned value on the simple path from the root $x$ to $v$ the minimum possible value. This can be done in $O(n)$. </spoiler> <spoiler summary="Solution"> ~~~~~ #include<bits/stdc++.h> using namespace std; int n , x , p [200005] , k , pr [200005]; vector < int > gr [200005]; void dfs ( int x , int pt ) { pr [x] = pt; for ( auto u : gr [x] ) { if ( u == pt ) continue; dfs ( u , x ); } } int up ( int x ) { if ( p...
"> [D — Bubble Sort !!?](https, [D — Bubble Sort !!?](https://codeforces.me/gym/104426/problem/D)

Full text and comments »

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

15.
By ch_egor, 10 years ago, translation, In English
Codeforces Round #359 Editorial If you notice typos or errors, please send a private message. <br> <br> [Div2A Free Ice Cream](http://codeforces.me/contest/686/problem/A) <br> Author: [user:cdkrot,2016-06-24] <br> Developer: [user:ch_egor,2016-06-23] <br> You just needed to implement the actions described in statement. <br> If you solution failed, then you probably forgot to use 64-bit integers or made some small mistake. <br> Correct solution: <br> <br> <spoiler summary="C++ code"> ~~~~~ #include <iostream> #include <cstdio> #include <cstdlib> #include <string> #include <cstring> #include <vector> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <cassert> #include <algorithm> #include <iomanip> #include <ctime> #include <cmath> #include <bitset> #pragma comment(linker, "/STACK:256000000") using namespace std; typedef long long int int64; typedef long double double80; const int INF = (1 << 29) + 5; const int64 LLINF = (1ll <<...
each iteration (bubble sort for example). Complexity $O(n^2)$ , , which changes the neighboring elements in each iteration (bubble sort for example). Complexity

Full text and comments »

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

16.
By DrunkMaster, 5 years ago, translation, In English
Editorial of the personal Olympiad for grades 6-9 Editorial of [contest:368205]. [problem:375720A] <spoiler summary="Editorial"> For tests up to 10 you can solve manually. For second group you can solve by brute force: check all possible $i$, $j$ and check condition. $O(n^2)$ For third group you can see, that for fixed $i$ $j = n - i$. $O(n)$ For full solution you can see, that for every number from $0$ to $n$ we can find pair. The answer is $n + 1$. $O(1)$. </spoiler> <spoiler summary="Code"> ~~~~~ #include <bits/extc++.h> #define int int64_t using namespace std; int32_t main() { int n; scanf("%lld", &n); n++; printf("%lld", n); } ~~~~~ </spoiler> [problem:375720B] <spoiler summary="Editorial"> For the first group it was enough to note that the answer is always $k$. For the second group it was necessary to find the number of ones and twos and solve similarly to the first case. For the third group it was necessary to be able to find the minimum in the a...
array. For the fourth group, you could sort the array for $O(n^2)$ (for example, bybubble, For the fourth group, you could sort the array for $O(n^2)$ (for example, by bubble sorting) and

Full text and comments »

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

17.
By TryOmar, history, 3 years ago, In English
Code Collection Covering Bubble Sort, Binary Search, Lower Bound, Frequency, and Prefix Sum Recently, I was explaining fundamental algorithms like Bubble Sort, Binary Search, Lower Bound, Frequency, and Prefix Sum to my friends. It occurred to me that sharing these algorithms on Codeforces could be beneficial to others as well. So, I decided to share the code, as it might serve as a useful resource for anyone interested in learning these concepts. Bubble Sort: compares adjacent elements and swaps them if in the wrong order until the list is sorted. ~~~~~ #include <iostream> using namespace std; int main() { int arr[] = {64, 34, 25, 12, 22, 11, 90}; int n = sizeof(arr) / sizeof(arr[0]); // Bubble Sort for (int i = 0; i < n; i++) { // --> O(N^2) for (int j = 0; j < n - 1; j++) { if (arr[j] > arr[j + 1]) { swap(arr[j], arr[j + 1]); } } } cout << "Sorted array using Bubble Sort: "; for (int i = 0; i < n; i++) { cout << arr[i] << " "; } return 0; }...
Code Collection Covering Bubble Sort, Binary Search, Lower Bound, Frequency, and Prefix Sum, // Bubble Sort for (int i = 0; i < n; i++) { // --> O(N^2) for (int j = 0; j < n - 1, // Sort the array (Note: Ensure that the array is sorted before using upper_bound)sort(arr, Bubble Sort: compares adjacent elements and swaps them if in the wrong order until the list is, Recently, I was explaining fundamental algorithms like Bubble Sort, Binary Search, Lower Bound, Sort with Built-in Function: Sorting the array using the built-in `std::sort` function from the, cout << "Sorted array using Bubble Sort: "; for (int i = 0; i < n; i++) { cout << arr, sort(arr, arr + n);

Full text and comments »

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

18.
By parth_1818, history, 3 years ago, In English
Know Some Sorting Techniques Introduction: ------------- Sorting is a fundamental operation in computer science, playing a crucial role in various applications and algorithms. Sorting involves arranging elements in a specific order, making it easier to search, retrieve, and analyze data. There are numerous sorting algorithms, each with its own unique approach and time complexity. In this blog, we'll explore some commonly used sorting techniques and see their code. ### 1) Selection Sort Introduction: Selection Sort is a simple sorting algorithm that repeatedly selects the minimum element from an unsorted portion of the array and places it at the beginning. This process continues until the entire array is sorted. Time Complexity: - Best: O(N^2) - Average: O(N^2) - Worst: O(N^2) Code: ~~~~~ int main() { int n = 5; int arr[] = { 9, 1, 5, 6, 3 }; for (int i = 0; i < 5; i++) { int position = 0, minimum = 1e5; for (int j = i; j < n; j++) { if (a...
### 2) Bubble Sort, Bubble Sort: Easy to implement but tends to be inefficient for large datasets, also with quadratic, Introduction: Bubble Sort is a comparison-based sorting algorithm that repeatedly steps through

Full text and comments »

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

19.
By CalisthenicsMan, 5 years ago, In English
Very fun game "Codenames with CP words" Dear Community, I want to introduce you to very fun game we in Germany often play at national finals and IOI selection program (online). It is Codenames https://codenames.game/ You have to create room and select "create your own custom word pack!" and deselect the other pre-selected options which words to use. Invite your friens who are chilling in the Discord Server and paste the link. ![ ](/predownloaded/d8/7f/d87fbe5ec656cc9b47082773c7f80912d65c6cdb.png) There are two teams, blue and red who play againist each other. First team to tap all own-color cards wins, team which accidentally taps black card loses. In the beginning all cards are turned around so no-one can see colors, only words noted on them. Spymasters (one person per team) can see color, operatives not. Every turn goes the following: Spymaster of current team looks at the cards, gives hint describing one or multiple cards of his team, which are not yet turned around, and selects a number of taps his team i...
hint "slowsort — 2" and operatives could agree on blue cards "insertion sort" and "bubble sort, operatives could agree on blue cards "insertion sort" and "bubble sort".

Full text and comments »

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

20.
By halyavin, 11 years ago, In English
Educational Codeforces Round 9 Challenge Overview. 632A &mdash; Grandma Laura and Apples ------------------------------- There were no successful challenges for this problem. Thumbs up to everyone! I did find a couple of C/C++ solutions with uninitialized local variables though. Fortunately for them, the top of the stack is filled with zeros in the current testing system and compiler didn't decide to place uninitialized local variables in the register. 632B &mdash; Alice, Bob, Two Teams ---------------------------- There was quite a variety of off-by-one errors in this problem. My most successful test was ~~~~~ 2 1 1 BB ~~~~~ Some solutions just have to flip something. The were also 2 challenges where solution got TL due to slow input. The most crazy uninitialized variable prize for this problem goes to [submission:16447719]: ~~~~~ ll n; v b(n); cin >> n; forn(i, n) { cin >> b[i]; } ~~~~~ What is the size of vector `b`? Definitely not `n`. Fortunately for the author, it can't be challenged. Und...
lexicographical order followed by bubble sort using the correct order. Turned out this is not fast, sorting with lexicographical order followed by bubble sort using the correct order. Turned out this

Full text and comments »

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

21.
By DuX, 11 years ago, In English
Bubble Cup 8 — Finals ![ ](http://codeforces.me/predownloaded/85/ac/85ac500c1ca1cb56cfbafb3b8a1eccd2de4e4b1f.png) Hello Codeforces, In less than a two weeks, finals of 8th edition of Bubble Cup will be held in Belgrade, organized by [Microsoft Development Center Serbia](http://www.microsoft.com/serbia/mdcs/). Unfortunately, there wont be Bubble Run contest this year (which was held last two years for university students in the same tame as BCup, and it was a 24h marathon style contest), but only ACM-style 5 hour long contest for both university and high school teams in the same category. You can read more about contest on the [official website](http://www.bubblecup.org), and read tasks and solutions from past years in the [booklets](http://www.bubblecup.org/Archive). (There are some very interesting tasks, especially from Run contests, so I encourge you all to take a look at them). Usually, the contest was interesting only to teams from Serbia and it's region, but every year we can see more an...
Bubble Cup 8 — Finals, ) Hello Codeforces, In less than a two weeks, finals of 8th edition of Bubble Cup will be held in

Full text and comments »

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

22.
By eanacra, 11 years ago, In English
How to determine the solution of a problem by looking at its constraints? By looking at the constraints of a problem, we can often "guess" the solution. **Common time complexities** Let *n* be the main variable in the problem. * If *n* &le; 12, the time complexity can be O(n!). * If *n* &le; 25, the time complexity can be O(2<sup>n</sup>). * If *n* &le; 100, the time complexity can be O(n<sup>4</sup>). * If *n* &le; 500, the time complexity can be O(n<sup>3</sup>). * If *n* &le; 10<sup>4</sup>, the time complexity can be O(n<sup>2</sup>). * If *n* &le; 10<sup>6</sup>, the time complexity can be O(n log n). * If *n* &le; 10<sup>8</sup>, the time complexity can be O(n). * If *n* > 10<sup>8</sup>, the time complexity can be O(log n) or O(1). **Examples of each common time complexity** * O(n!) [Factorial time]: Permutations of 1 ... *n* * O(2<sup>n</sup>) [Exponential time]: Exhaust all subsets of an array of size *n* * O(n<sup>3</sup>) [Cubic time]: Exhaust all triangles with side length less than *n* * O(n<sup...
-based sorting (eg. Bubble Sort, Insertion Sort, Selection Sort) * O(n log n) [Linearithmic time, 2) [Quadratic time]: Slow comparison-based sorting (eg. Bubble Sort, Insertion Sort

Full text and comments »

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

23.
By fchirica, 13 years ago, In English
Codeforces Round #245 — Editorial [problem:430A] ------------------ The problem asks you to output “-1” if there is no solution. A natural question is now: “when there is no solution”? Try to come up with a test like this! After some analysis, you’ll see anyhow we draw the points and the lines, there will always be a solution. By manually solving small cases, you might already have found the pattern. But for now, let’s assume anyhow we draw points and lines, there will always be a solution. Let’s have a fixed set of points. Then, anyhow we draw a line, there should still be a solution. So, we need to find a coloring of points, such as for every line, |number of red points which belong to it – number of blue points which belong to it| <= 1. Suppose anytime you color a point with red you assign it +1 value. Also, anytime you color it with blue you assign it -1 value. Then, for a segment, the drawing is good if S = sum of values assigned to points that belong to segment is between -1 and 1 (in other words |S| ...
to remove it. Then, we have to repeat this process. So algorithm is something likebubble sort, So algorithm is something like bubble sort: while b[] array has changed last step, continue

Full text and comments »

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

24.
By szdytom, history, 3 years ago, In English
2022 Joint exam of 5 schools (GZEZ Round2) Editorial [A. Refreshed](https://codeforces.me/gym/104538/problem/A) ------------------ If we don't take the shortest path from $s$ to $t$ but instead detour to some vertices to gain health, we must pass through an edge with both endpoints having a sum of weights greater than 0. If we reach either vertex of such an edge, we can gain infinite health. We mark such vertices as infinite health vertices. So, either we take the shortest path from $s$ to $t$, or we take the shortest path from $s$ to an infinite health vertex, gain infinite health, and then walk to $t$. The second case can be maintained through up and down DP, which keeps track of the minimum health required to reach an infinite health vertex from each vertex. The first case is to find the prefix minimum value of the path from $s$ to $t$. It is easy to see that the prefix minimum value is either the entire path or the entire path excluding the vertex $t$. Otherwise, there must be infinite health on the path, which can b...
being able to swap the positions of any two adjacent numbers, so we can perform bubble sort on the, swap the positions of any two adjacent numbers, so we can perform bubble sort on the permutations

Full text and comments »

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

25.
By yeputons, 16 years ago, translation, In English
Tutorial for problems of Codeforces Beta Round #49 (Div.2). All problems now. Let's go.<br><br><div class="title" align="center">A. Autocomplete</div><br><div align="left">In this problem you should read the statement and solve in any way. One of the most simple solutions is read string and last visited pages, sort (even bubble source - 100<sup>3</sup> isn't a lot, 3rd power because we need 100 operations to compare two strings), and rundown pages. When we find good string, we should write it and exit.<br>If there are no such one, write source string. 'Goodness' of string is checking with one <i>if</i> (to check lengths and avoid <i>RTE</i>) and <i>for</i>.<br>[cut]<br><br><div class="title" align="center">C. Froggy (Little Frog)</div><br></div>IMHO it's the second difficulty problem. If you cannot see solution just after you saw the statement, you can write brute-force solution (rundown all permutation and check), run it for <i>n=10</i> and see beautiful answer.<br>Answer is <i>1 n 2 (n-1) 3 (n-2) 4 (n-3) ... </i>Let's define two pointers - <i>l</i> and <i>r</i...
read string and last visited pages, sort (even bubble source - 1003 isn't a lot, 3rd power, the most simple solutions is read string and last visited pages, sort (even bubble source - 1003

Full text and comments »

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

26.
By pothikerdiary, 15 years ago, In English
Sorting Algorithm (C++ general implementation) In Algorithm Design, Sorting is an important part. Different algorithm use the sorting algorithm. Some Interesting sorting algorithm are include here: Bubble Sort, Heap Sort, Quick Sort, Counting Sort, Selection Sort, Insertion Sort etc.<br /><br />In computer science and mathematics, a sorting algorithm is an algorithm that puts elements of a list in a certain&nbsp; order. The most-used&nbsp; orders are numerical order and&nbsp; lexicographical order. Efficient&nbsp; sorting&nbsp; is important to optimizing the use of other algorithms (such as&nbsp; search&nbsp; and merge&nbsp; algorithms) that require sorted lists to work correctly; it is also often useful for&nbsp; canonicalizing&nbsp; data and for producing human-readable output.<br />Bubble Sort:<br /><br />Bubble sort is a simple sorting algorithm&nbsp; that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and&nbsp; swapping&nbsp; them if they are in the wrong order. The pass throu...
/>Bubble Sort:, ) algorithms such as selection sort or bubble sort; the best case (nearly sorted input) is O(n), . Some Interesting sorting algorithm are include here: Bubble Sort, Heap Sort, QuickSort, Counting, Bubble sort is a simple sorting algorithm that works by repeatedly stepping through the list

Full text and comments »

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

27.
By rishabh-malhotra, history, 6 years ago, In English
Codeforces Diary Hey everyone, Happy New Year to all of you, I hope you all have a better 2021 than 2020. I would like to present you with this tool I made called [Codeforces Diary](https://codeforces-diary.netlify.app/). Which helps you check all your submission you made on a given day at a glance. It also displays certain account stats which I found were interesting. #### [Website](https://codeforces-diary.netlify.app/) | [Code](https://github.com/Rishabh-malhotraa/codeforces-diary) |Landing Page | Dashboard | Submission List(click on the cell on the heatmap) | |---|---|---|---| | ![Landing PAge](/predownloaded/4e/6c/4e6c382f05f1304627ea7d10338f571d8e55d758.png) | ![Dashboard](/predownloaded/9a/40/9a4017606f001b550b49447b47c9fd0b3a2e38b9.png) | ![Submission List](/predownloaded/66/f8/66f84479901e40af106586519af2810d19f693ee.png) | I plan to add the following features in the coming days (OPEN to suggestions from the community!) - Rating change calculator - Bubble Chart of ...
coming days (OPEN to suggestions from the community!) - Rating change calculator -Bubble Chart of, - Bubble Chart of questions (sorted by tags), [like this demo](https://observablehq.com/@unkleho

Full text and comments »

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

28.
By hitler_sort, history, 16 months ago, In English
A New and Efficient Sorting Algorithm As we all learned in kindergarten, you can easily sort an array in $O(n^{2})$ using well-known algorithms such as bubble sort, insertion sort, and such. We took inspiration from [Stalin Sort](https://codeforces.me/problemset/problem/2027/B) (SS for short) and improved the upper bound from $O(n^{2})$ to $O(n\sqrt{n}log(n))$ with an algorithm that we called Hitler Sort (HS). In this blog we will describe the algorithm and prove the upper bound on sorting, breaking the previously known bound of $O(n^{2})$. The algorithm: We will use the well-known $O(nlogn)$ time [LIS/LDS algorithm](https://cp-algorithms.com/sequences/longest_increasing_subsequence.html) to find the LIS and LDS of the input array $A$ of length $n$, by the [Erdős–Szekeres theorem](https://en.wikipedia.org/wiki/Erd%C5%91s%E2%80%93Szekeres_theorem), $max(LIS,LDS)\ge \sqrt{n}$ and therfore, if we erase the maximal monotonic subseqence $S$ from the array, we will be left with an array $A\\S$ of size at most $n-\sqr...
algorithms such as bubble sort, insertion sort, and such.

Full text and comments »

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

29.
By panda_2500, history, 4 years ago, In English
Biweekly contest 1 Editorial [user:Panda_2500,2022-11-14] #### Note from Author: Congrats to all the Winners. Glad to see so much participation. Hope to see you all participate in the next biweekly as well. You can contact me (Abhijit Mishra) for any queries related to the contest or problem discussion. I would recommend first looking at the hints for the problem if your facing logical issue, if you are absolutely clear with logic then move on to look at the solution and the code. efforts will be made towards making code for other languages (Java and Python) available as well. ## [A — Try-logy](https://codeforces.me/gym/408062/problem/A) <br> <spoiler summary="Hints"> <spoiler summary="Hint 1"> Think of the cases in which the team will solve a problem. </spoiler> <spoiler summary="Hint 2"> Repeat **for** the n problems. </spoiler> </spoiler> <spoiler summary="Solution"> A problem will be solved by the team if there are **atleast** two 1s in a row. count this for every row i....
comparison-based sorting algorithm you want: even bubble sort will not exceed the allowed number of, : even bubble sort will not exceed the allowed number of swaps.

Full text and comments »

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

30.
By sbakic, history, 11 years ago, In English
Bubble Cup Conference Hello, Codeforces! As you know from this [post](http://codeforces.me/blog/entry/20072) and this [post](http://codeforces.me/blog/entry/19957), [Bubble Cup](http://www.bubblecup.org/) is a programming competition organized by [Microsoft Development Center Serbia](http://www.microsoft.com/serbia/mdcs/). This year was held the first BubbleCup Conference where competitions gurus talked about competitive programming and more! And I wanted to share with you some great and useful talks. I sorted them in order of when they were presented, because some part of one lecturer is in the video of the other lecturer. I would suggest you to start from begging. Enjoy :) Michal Forisek ([user:misof,2015-10-21]) &mdash; talked about how it's easy to get discouraged in competitive programming; how to practise, **do what gives you the largest benefits**; about new point of view through, at first glance, easy graph problem. - [BBC8 Lecture &mdash; Michal (part 1)](https://www.youtube.com/watch...
Bubble Cup Conference, [post](http://codeforces.me/blog/entry/19957), [Bubble Cup](http://www.bubblecup.org/) is a

Full text and comments »

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

31.
By Arbuzik342, history, 5 weeks ago, translation, In English
**Qualification Round Editorial** ### A. Queue for Puffball **Idea:** [user:Arbuzik342,2026-10-04] **Preparation:** [user:Arbuzik342,2026-10-04], [user:zeyd1234,2026-10-04] <spoiler summary="Hint 1"> For each family, compute two values: how many of its members are in the queue, and the position of the earliest one. </spoiler> <spoiler summary="Hint 2"> The sorting of families is two-level: first by count (descending), and on ties — by the position of the earliest member (ascending). </spoiler> <spoiler summary="Solution"> Try to maintain two arrays: `amount[x]` — the number of people from family `x`, and `firstTime[x]` — the smallest index at which family `x` appears. Go through the input once and fill in both. Then collect all distinct family IDs into a vector and sort them with the comparator: ```cpp if (amount[a] != amount[b]) return amount[a] > amount[b]; return firstTime[a] < firstTime[b]; ``` All that's left is to print each family as many times as it has people. Complexity — `O(n log n...
This is the ordinary bubble sort with an optimization: after each pass, ordinary bubble sort with an optimization: after each pass, the right part of the array is already sorted

Full text and comments »

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

32.
By Ahnaf.Shahriar.Asif, history, 9 years ago, In English
How to learn step by step to be a good programmer !!! Hello everybody , how are you ? Today I am going to describe some contents (programming) Which can be helpful for contestants. At first I assume that you all know about C/C++ language . But It doesn't matter . I think you also know about conditional logic , loop , datatype(input/output) , strings, array, function , basic bitwise operation etc . I think then you should learn lots of Mathematical terms such as : Prime number , GCD , LCM , Eular's Totirnt Function , Bigmod , Modular inverse , Extended GCD , combinatorics, permutation , combination , inclusion exclusion principle ,probability , Expected value , Base conversation , Big integer , cycle , Gawssian elimination etc etc........ **Then.....** you have to learn about sorting and searching . like : Insertion sort , bubble sort , merge sort , selection sort , merge sort , county sort etc . NOTE : THERE IS A THING NAMED "qsort" function is C language.....don't use it . There is an algorithm named "anti-qsort" . If you u...
........ **Then.....** you have to learn about sorting and searching . like : Insertionsort , bubble, you have to learn about sorting and searching . like : Insertion sort , bubble sort , merge sort

Full text and comments »

33.
By mohit07dec, 17 months ago, In English
Codeforces Round 1032 (Div. 3) — Problem Intuitions # Codeforces Contest — Problem Intuitions --- ## Problem A — Letter Home Given a sorted array of positions and a starting point, you must reach both ends of the array in the minimum number of steps. **Optimal Strategy:** - Move to the nearest boundary (either the smallest or largest position). - Then traverse the entire array to the opposite end. - The answer is: `abs(max_x - min_x) + min(abs(s - min_x), abs(s - max_x))` **Why:** You must visit both ends, so always minimize the initial distance to the closest end. --- ## Problem B — Above the Clouds **Core Idea:** Partition the string into three non-empty substrings `a`, `b`, `c` such that `b` is a substring of `a+c`. **Key Insight:** - For every possible split, check if the middle part (`b`) appears as a substring in the concatenation of the first and third parts (`a+c`). **Approach:** - Iterate over all valid split points. - For each, check the substring condition. - Output "Yes" if a...
that index. - Repeat sorting if necessary. **Approach:** - Bubble sort both arrays with, - Bubble sort both arrays with allowed swaps. - After sorting, for any `a[i] > b[i]`, swap them

Full text and comments »

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

34.
By stefdasca, history, 7 years ago, In English
Codeforces Round #632 - Unofficial Solutions + Video Editorials (ABCD, F) Hi! Since the editorial will be posted later, I decided to write some quick solutions for the problems I managed to solve, as well as video editorials for C and F. <spoiler summary="A - Little Artem"> Add $W$ on $(n, m)$ and $B$ on all other squares, we will have two black squares bordering one white square, which is good enough. Submission link: [submission:75925150] </spoiler> <spoiler summary="B - Kind Anton"> If $a_i$ $=$ $b_i$, do nothing. Otherwise, if $a_i$ $<$ $b_i$, check if we had some $a_i$ equal to $1$, otherwise, check if we had some $a_i$ equal to $-1$, this information can be kept while we iterate through the elements. Total complexity: $O(n)$. Submission link: [submission:75925202] </spoiler> <spoiler summary="C - Eugene and an array"> [Video Editorial here](http://www.youtube.com/watch?v=XR_ZQvr9zyU) Submission link: [submission:75916951] </spoiler> <spoiler summary="D - Challenges in school №41"> Simulate the bubble sort algorithm(a...
Simulate the bubble sort algorithm(assume, ] Simulate the bubble sort algorithm

Full text and comments »

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

35.
By SheTheRay, history, 4 months ago, In English
Algorithm //linear search #include <iostream> using namespace std; int main() { int n; cout << "Enter number of elements: "; cin >> n; int arr[n]; cout << "Enter " << n << " elements: "; for (int i = 0; i < n; i++) cin >> arr[i]; int key; cout << "Enter element to search: "; cin >> key; int index = -1; for (int i = 0; i < n; i++) { if (arr[i] == key) { index = i; break; } } if (index != -1) cout << "Element found at index " << index << endl; else cout << "Element not found" << endl; return 0; } //Binary search #include <iostream> using namespace std; int main() { int n; cout << "Enter number of elements: "; cin >> n; int arr[n]; cout << "Enter " << n << " elements in sorted order: "; for (int i = 0; i < n; i++) cin >> arr[i]; int key; cout << "Enter element to search: "; ci...
] << " "; cout << endl; return 0; } //Bubble sort #include using namespace std; int main, return 0; } //Bubble sort #include using namespace std;

Full text and comments »

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

36.
By Eren-Jaeger, 4 years ago, In English
Basic Round Editorial Thanks for participating! <br> The top 5 contestants from this week's contest are: <br> 1. [user:AnujS,2022-06-05] 2. [user:tushaar9876,2022-06-05] 3. [user:depanshusahu057,2022-06-05] 4. [user:sakshamm21,2022-06-05] 5. [user:adxmyt,2022-06-05] Great job guys! Here's the Editorial for the contest. Feedback of any kind is appreciated in the comments. <br> [A. Triple](https://codeforces.me/group/ctEtdi2TSJ/contest/384123/problem/A) <spoiler summary="Tutorial"> Approach 1: Sort the array using an efficient sorting algorithm. For every element check if the next two in the array are equal to it. If you find such an element output it. Time complexity is $O(nlogn)$. Approach 2: Notice that elements have an upper bound of $n$, you can use an auxiliary array to store the count of each value. Go through each value and see if its count is bigger than or equal to $3$. Time complexity is $O(n)$. </spoiler> <spoiler summary="Solution"> ~~~~~ #include ...
want: even bubble sort will not exceed the allowed number of swaps., sort $a$ with any comparison-based sorting algorithm you want: even bubble sort will not exceed the

Full text and comments »

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

37.
By shankysodhi, 15 years ago, In English
Sorting simultaneous arrays Hi,<br><br>Quite a no of times when i am participating in the contests, i come across the problem where i have to sort 2 or 3 arrays according to a condition applied only on one of them .<br><br>For eg :<br><br>Cordinates of a point in 3d space are given as (x,y,z)<br><br>Now the input comes as (X[], Y[], Z[] .... are different arrays)<br><br><blockquote><blockquote><blockquote>X[j]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Y[j]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Z[j]<br></blockquote>j<br><br>0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1<br>1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5<br>2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 9&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...
function ... preferably in java).. ?? Or do i have to go for simultaneous bubble sort or some other, have to go for simultaneous bubble sort or some other sort every time ...??

Full text and comments »

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

38.
By yashdeora, history, 6 years ago, In English
Best Data Structures resources for learning competitive programming Basics of algorithm =================== 1. [What is an Algorithm explanation with an example](https://programmingoneonone.com/what-is-algorithm-in-programming.html) 1. [Algorithm Design and Analysis](https://datastructure.us/algorithm-design-and-analysis.html) 1. [Classification of algorithms](https://datastructure.us/classification-of-algorithms.html) 1. [Evaluating and Expressing an algorithm](https://datastructure.us/evaluating-and-expressing-algorithm.html) 1. [What is Data Structures and algorithms](https://programmingoneonone.com/what-is-data-structures-and-algorithms.html) 1. [How to calculate running time of an algorithm](https://programmingoneonone.com/how-to-calculate-running-time-of-an-algorithm.html) 1. [Worst, Everage and Best-case analysis of algorithm](https://programmingoneonone.com/worst-average-and-best-case-analysis-of-algorithm.html) 1. [Big o notation](https://programmingoneonone.com/big-o-notation.html) 1. [Big o notation examples](https://programmingone...
sorting in C programming](https://datastructure.us/selection-sorting-in-c.html) 1. [Bubble sorting, -c.html) 1. [Bubble sorting in C programming](https://datastructure.us/bubble -sorting-in-c

Full text and comments »

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

39.
By SummerSky, 9 years ago, In English
Notes on Codeforces Beta Round #49, A, B(Trick to avoid using floor and ceil functions), C, D A. Autocomplete We can enumerate all the given strings, and for each one that has the required beginning, we select the lexicographically minimal one as the answer. B. Blog Photo The problem requires that at least one of the sides should have a length of form 2^n. Thus, we can first let the length of height have a form of 2^n,2^(n-1),...,2^0, where 2^n should be no larger than h. For each height=2^i, we calculate the largest length of width so that it will not exceed the given w and meanwhile the area can achieve the maximum value. Next, we let the length of width have a form of 2^n,2^(n-1),...,2^0, and calculate the height in a similar manner. As an example, we investigate how to calculate the width, denoted as W, given that the current length of height is H=2^i. Due to the constraints, we have 0.8<=H/W<=1.25, which means that H/1.25<=W<=H/0.8. As both the height and width are integers, one might use ceil(H/1.25)<=W<=floor(H/0.8) to obtain the values that W can take. Howev...
implemented like Bubble Sort, and the process should be recorded as part of the final answer. Similarly, like Bubble Sort, and the process should be recorded as part of the final answer. Similarly, we deal

Full text and comments »

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

40.
By ahnaf_cp, history, 22 months ago, In English
Beginner DSA Curriculum Made by Me Hello, Codeforces community! As a beginner in competitive programming, diving into Data Structures and Algorithms (DSA) can feel overwhelming. To make it more approachable, I decided to create my own DSA curriculum tailored for beginners like myself. This curriculum is structured, beginner-friendly, and covers the essential concepts you need to progress in problem-solving and competitive programming. I’d love to share it with you all! Let’s dive in. --- ## Why Create This Curriculum? When I started my journey in programming, I faced these common challenges: - Lack of a clear roadmap. - Getting stuck on advanced topics without mastering the basics. - Feeling lost with random tutorials and problem sets. This curriculum addresses these issues by providing a **structured, progressive approach** to learning DSA. It’s designed to build a solid foundation, grow confidence, and gradually tackle harder problems. --- ## Curriculum Overview ### 1. **Foundations of...
### 3. **Sorting and Searching** - **Topics to Learn**: - Bubble Sort, Selection Sort, ** - **Topics to Learn**: - Bubble Sort, Selection Sort, Insertion Sort - Binary Search and its

Full text and comments »

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

41.
By Islam, history, 3 years ago, In Russian
Republic Olympiad Topics Republic Olympiad Topics for preparation ==== **====== lvl 1 | basic knowledge =====** Introductory lesson math (formulas, basic mathematic operations) if/else loop string, array asymptotics sort (bubble, merge) STL, map, set **======= lvl 2 | pre-intermediate =====** Two pointers Binary Search/Ternary Search prefix sum sliding window functions / recursion (prime) Bruteforce Greedy scan line permutation **========= lvl 3 | intermediate ===============** prime, factorization, number theory dp basic graph, dfs, bfs Sieve combinatorics modular arith Hash **========= lvl 4 | upper-intermediate ==========** fenwick tree sqrt decomposition Segment Tree Sparse Table TopSort Eulerian cycle, path Finding path algos dsu, mst bitmasks and dp bitmasks Mo's Algo digit dp DP on substring invariant, monovariant, dirichlet **======== lvl 5 | advanced ========** Cut verti...
sort (bubble, merge)

Full text and comments »

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

42.
By harrypotter0, history, 10 years ago, In English
How to prepare for ACM ICPC? Well I would suggest you to check out Programming Competition,Programming Contest,Online Computer Programming. Here is the details about as the codechef team promote the students for ACM-ICPC or you can also check out the actual university site which conduct ICPC The ACM-ICPC International Collegiate Programming Contest And to practice problems you can you can refer following sites 1. http://codechef.com 2. http://spoj.com 3. http://hackerrank.com 4. http://codecademy.com 5. http://topcoder.com 6. http://codeforces.com Good Luck... for the details about ACM-ICPC 2015 you can read the details ACM ICPC 2015 | CodeChef. I hope you'll find most of the things... Here are some steps to get started and be good at it. Get comfortable writing code in either of one of these languages C, C++ or Java. Why only C, C++ or Java? Because these are the standard languages allowed in any programming competition. If you are already good at C, it is suggested to learn C++. It...
few of them like these in this order: Bubble sort, Insertion sort, Merge sort, Heapsort, Quicksort, list of sorting algorithms (They usually teach a few of them like these in this order:Bubble sort

Full text and comments »

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

43.
By Saxena12, history, 3 years ago, In English
RANK-WISE classification of topics ? So Look at this Article ? I am not able to access the specific article you mentioned, but I can definitely help you with your query. If you're looking for a comprehensive list of data structures and algorithms relevant to each skill level in programming, you can follow a structured approach to practice competitive programming effectively. Competitive programming requires a solid foundation in basic data structures and algorithms before moving on to more advanced topics. Here is a suggested step-by-step approach to practice competitive programming: 1. **Basic Data Structures**: Start by mastering fundamental data structures like arrays, linked lists, stacks, queues, and hash tables. Understand their operations, time complexity, and implementation details. 2. **Basic Algorithms**: Learn and implement basic algorithms such as sorting (e.g., bubble sort, insertion sort, merge sort, quicksort), searching (e.g., linear search, binary search), and basic graph algorithms (e.g., depth-first search, breadth-firs...
algorithms such as sorting (e.g., bubble sort, insertion sort, merge sort, quicksort), searching, 2. **Basic Algorithms**: Learn and implement basic algorithms such as sorting (e.g.,bubble sort

Full text and comments »

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

44.
By xuanquang1999, history, 11 years ago, In English
Weird Behavior of std::sort (and std::stable_sort), or it's my fault? I'm trying to solve [103 &mdash; Stacking Boxes](https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=39) on UVa online judge. My idea is first, sort all the box that no box can be nested in the previous box, then run O(n^2) LIS DP on it. However, when I print the order and the sizes of all boxes, I found something weird: The Bubble sort algorithm gave correct sorting order: [Code used Bubble sort](http://ideone.com/sl7h1J) But std::sort gave wrong sorting order (more specific, box 5 should stay before box 1): [Code used std::sort](http://ideone.com/gwAHOM) std::stable_sort also gave wrong sorting order: [Code used std::stable_sort](http://ideone.com/LaXbMR) Did something go wrong with my implementation? Or something went wrong with std::sort and std::stable_sort?
Weird Behavior of std::sort (and std::stable_sort), or it's my fault?, I print the order and the sizes of all boxes, I found something weird: The Bubble sort algorithm, The Bubble sort algorithm gave correct sorting order:, [Code used Bubble sort](http://ideone.com/sl7h1J)

Full text and comments »

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

45.
By Sal3h.Sa3d, history, 4 years ago, In English
algorithms The Algorithm or Algorithms was named after Muhammad bin Musa Al-Khwarizmi, the Arab mathematician, and what is meant by algorithms in the field of programming are the steps that we use to solve the problems that we meet. And that's it And of course, there is a basis in his book, the algorithm, not anything, and that's it, I can say about it algorithm 1- Simplicity: This is an important thing in writing any algorithm so that I, as a programmer, can turn it into code that I really use. The simpler the steps you use, the easier it is for you to use them later 2 General: And here what is meant by it is that when I create an algorithm, I do it in a way that I can use it on a large scale. I mean, for example, I can’t say 1 + 2 = 3. This is an algorithm because it has a limited scale, which is only these two numbers. But it is possible that x + y = z is an algorithm. So I can use any number and it will do exactly the same job 3- Efficiency: And here we will need to understand the con...
Heap sort Bubble Sort 2- The Search Algorithms or search algorithms And this is used to search, Bubble Sort 2- The Search Algorithms or search algorithms And this is used to search for a specific

Full text and comments »

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

46.
By eduardische, history, 10 years ago, In English
Helping Contestants Help Us All or Competition Pitfalls During my competition history I've collected a vast amount of different fail stories. And those usually come in two flavours. You either get an aftertaste of a personal failure or you get a feeling that you were helped by organisers in your adventure. And it's always helpful to try and learn something from these failures. The first ones are kind of personal, and only affect you or your team, so they are not that interesting to talk about. The second ones however are more important. First of all, this is a direct feedback to the organisers, in hopes that it might make future contest better. And then you usually try to use that feedback yourself when you move on the organisers side in an attempt to make sure that you avoid setting all those pitfalls that you were annoyed about when competing. So here I'm going to try and describe two types of pitfalls that in my opinion the organisers can deliberately or accidentally set that helps teams to embark on a wonderful journey to fail-land a lo...
lot easier. This was originally intended to be a comment about Bubble Cup problem set, but since I've

Full text and comments »

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

47.
By NaN7, history, 8 years ago, In English
A little about DP Hello CodeForces! Let's take a look at DP -Dynamic Programming. I, as an experienced profession in programming, have prepared a sentence to tell everyone; The sentence I am going to note, is a result of years of studying and coding; here it is : "DP solves any problem" Here, I have collected some problems which can be easily solved using DP : [Boredom](http://codeforces.me/problemset/problem/455/A) [Three Displays](http://codeforces.me/problemset/problem/987/C) [Longest Regular sequence](http://codeforces.me/problemset/problem/5/C) [Bubble Sort Graph](http://codeforces.me/problemset/problem/340/D) [Zuma](http://codeforces.me/problemset/problem/607/B) [The value you can make](http://codeforces.me/problemset/problem/687/C) [Permutation Game](http://codeforces.me/problemset/problem/1033/C) [Civilization](http://codeforces.me/problemset/problem/455/C) [Once Again...](http://codeforces.me/problemset/problem/582/B) [Alyona and Strings](...
) [Longest Regular sequence](http://codeforces.me/problemset/problem/5/C) [ Bubble Sort Graph](http, [Bubble Sort Graph](http://codeforces.me/problemset/problem/340/D)

Full text and comments »

Tags #dp
  • Vote: I like it
  • -19
  • Vote: I do not like it

48.
By saprykin, 5 years ago, translation, In English
Forbidden sets\Find the kth maximum among a large set Hello, Codeforces! ================== <spoiler summary="Really sorry"> Text may have a lot of mistakes, but i really tried very hard to make my post understandable. </spoiler> In this post I would like to talk about solving two types of problems, with almost the same solution. Unfortunately, I do not know how popular this idea is. For the first time I came up with it at the regional stage of 2021/22 in informatics for a certain subtask. And few days ago I noticed the idea in a problem from Google Kick Start and [problem:1637E], so I decided to write this post. Problem 1 ------------------ **Definition:** Given an integer $0 \leq K < 10^5$ and 2 _sorted in ascending order_ arrays $a_1, a_2, \ldots, a_n \ (a_i \leq 10^9)$ and $b_1, b_2, \ldots, b_n \ (b_i \leq 10^9)$. Were written $n^2$ fractions of the form $\frac{a_i}{b_j}, 1 \leq i \leq n, 1 \leq j \leq n$. After that, all these fractions were sorted in ascending order. You need to print the value of the $k$-th ascending...

Full text and comments »

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

49.
By Azizur_Rahaman, history, 2 years ago, In English
Important topics for a beginner problem solver Here are some important topics for a beginner problem solver: ============================================================= **Loops:** Learn how to repeat tasks using for, while, and do-while loops. **Conditionals:** Understand how to make decisions using if, else if, and else. **Arrays:** Practice storing and accessing multiple values in a single variable. **Functions:** Learn how to break your code into reusable blocks. **Recursion:** Understand how a function can call itself to solve a problem. **Sorting:** Practice ordering numbers or strings using algorithms like bubble sort or insertion sort. **Searching:** Learn how to find an item in a list, such as with linear search or binary search. **String manipulation:** Practice working with text, including reversing or finding parts of a string. **Mathematics:** Practice basic number problems like finding the greatest common divisor (GCD) or prime numbers. **Debugging:** Learn how to find and fix errors in...
**Sorting:** Practice ordering numbers or strings using algorithms like bubble sort or insertion, bubble sort or insertion sort. **Searching:** Learn how to find an item in a list, such as with linear

Full text and comments »

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

50.
By nuredinbederu10k, history, 20 months ago, In English
Editorial for A2SV Education Phase I — Contest #6 [A. Zoro’s Bounty Dilemma ](https://codeforces.me/gym/594356/problem/A) <spoiler summary="Solution"> There is four possible outcomes to this problem, if there has been both a '>' and '<' in your string , then you cant determine the winner so you return '?'. with that case out of the way you just need to keep track of if theres been a '<' or '>' since we know both couldnt have been there, so which ever one you find, you print, if its neither , you can return '='. </spoiler> <spoiler summary="Code"> ```python for _ in range(int(input())): s = input() if '<' in s and '>' in s: print('?') elif '<' in s: print('<') elif '>' in s: print('>') else: print('=') ``` </spoiler> [B. Thousand Sunny's Network Setup](https://codeforces.me/gym/594356/problem/B) <spoiler summary="Solution"> The problem requires selecting k computers with the highest possible equal internet speed, given that we can only decrease speeds but not increase them. A simple a...
(similar to bubble sort). At each step, we compare adjacent elements, and if they are in the wrong order, , we simulate sorting it into the correct order using adjacent swaps (similar to bubble sort). At each

Full text and comments »

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

51.
By Not-Afraid, history, 6 years ago, In English
[REALLY] Best Resource to learn Algorithms - Bubble Sort [Link](https://www.youtube.com/watch?v=Xg3WJs5wW9A) . <br> - Insertion Sort [Link](https://www.youtube.com/watch?v=VIPvAZnLx6E) . <br> - Binary Search [Link](https://www.youtube.com/watch?v=3-nQ1nbeBNU) . <br> - Breadth First Search [Link](https://www.youtube.com/watch?v=cfs47D_L71I) . <br> - Depth First Search [Link](https://www.youtube.com/watch?v=zPVDlPv0W3I) . <br> - Dijkstra [Link](https://www.youtube.com/watch?v=sWnCYL5DDyE) . <br><br> Hope it helps someone ^_^.
- Bubble Sort [Link](https://www.youtube.com/watch?v=Xg3WJs5wW9A) . - Insertion Sort [Link

Full text and comments »

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

52.
By Danzev, history, 7 years ago, In English
Just a simple bubble sort question Given an array $a_1,a_2,\dots,a_n$, $a_i=i$ and a permutation of this array $p_1,p_2,\dots,p_n$. We sort this permutation to get initial array using bubble sort. **Question:** how to calculate a number of swaps in $O(n)$ instead $O(n^2)$?
Just a simple bubble sort question, $. We sort this permutation to get initial array using bubble sort.

Full text and comments »

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

53.
By sarthakjoleya, history, 3 years ago, In English
Need Help for my Sorting Visualizer Hi Codeforces Community, I am currently developing a Sorting Visualizer using Svelte for Frontend [Github Repo](https://github.com/joleyasarthak/sorting-visualizer-svelte) and I'm not able to generate logic for merge and quick sort. The strategy I'm using for showing visualizations is that I sort the randomly generated list using the algorithm specified and then generate the swaps array, which stores which index was swapped with which index. You can find the implementation for selection, insertion, and bubble sort in the src/algos folder. <br> Can anyone please help me complete this project? I understand that the approach I followed till now might not be correct, and I'm open to any constructive criticism and fixes from this awesome community. Thanks :)
, insertion, and bubble sort in the src/algos folder. Can anyone please help me complete this project

Full text and comments »

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

54.
By txingml, history, 6 years ago, In English
Why does a hacked solution display as Accepted? I want to learn a fast solution for `Bubble Cup 13 - Finals [Online Mirror, unrated, Div. 1] B Valuable Paper` https://codeforces.me/contest/1423 So I click here. ![ ](/predownloaded/1c/ab/1cab2b5cd36c417355a87ef5de5c769fdead484a.png) And sort all **accepted** solutions by **Execution Time**. ![ ](/predownloaded/fa/c5/fac57166e684d1f25b02851d34f2a207ba33be31.png) The fastest one is https://codeforces.me/contest/1423/submission/94770930. ![ ](/predownloaded/d7/d7/d7d7179696eb5cb97df4685d965eecca5d83a2b5.png) I read it carefully and found it is wrong. Then I noticed that it already has been hacked. https://codeforces.me/contest/1423/hacks/669563 Why does a hacked solution display as **Accepted**? I think it can mislead users.
I want to learn a fast solution for `Bubble Cup 13 - Finals [Online Mirror, unrated, Div. 1] B

Full text and comments »

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

55.
By SsToRR, history, 4 years ago, In English
Is std::sort enough? Is sorting algorithm in C++ library enough? What are the advantages of bubble sorting, merge sorting, or quick sorting? Do you need to know them for example for the national olympiad?
Is std::sort enough?, Is sorting algorithm in C++ library enough? What are the advantages of bubble sorting, merge

Full text and comments »

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

56.
By tibinyte2006, 4 years ago, In English
Problemsetting Goal Since goals are very important in any individual's life, I decided to **set** a goal for myself. The target is to **set** 100 problems until I quit cp. Current progress: **40** | # | Date | <center>Problem</center> | <center>Contest</center> | <center>Difficulty</center> | Comments | Feedback | |----|---------------|----------------------------------------------------------------------------------------------|-----------------------------------------------------------------|-----------------------------------------------...
">1400* | First problem I ever set. It asks you to find the number of bubble sort, > | First problem I ever set. It asks you to find the number of bubble sort iterations tosort

Full text and comments »

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

57.
By gmiller, history, 11 years ago, In English
List of Fundamental C Programs for Beginners The following section gives a collection of Simple C Programs which are categorized into various Categories like Programs on Integers, Programs on Number Conversion, Programs on Recursion, Programs on Special Numbers. I strongly recommend programmers who recently started programming to go through below mentioned fundamental problems first to boost their knowledge of programming language basics. <ul> <li>[Hello World Program in C](http://www.techcrashcourse.com/2014/10/c-hello-world-program.html)</li> <li>[C Program to calculate factorial of a number](http://www.techcrashcourse.com/2014/10/c-program-find-factorial-of-number.html)</li> <li>[C program to check a number is palindrome or not](http://www.techcrashcourse.com/2014/10/c-program-check-palindrome-number.html).</li> <li>[C program to calculate power of a number](http://www.techcrashcourse.com/2014/10/c-program-calculate-power-of-number.html)</li> </ul> <br/> This section gives a collection of C Programs on Array. <a href="...
://www.techcrashcourse.com/2015/11/c-program-to-sort -integer-array-increasing-order-bubble-sort.html)

Full text and comments »

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

58.
By mohamedhany1024, history, 6 years ago, In English
Easy Rated Contests For Begginers Hello, World! I am kind Of New To competitive Programming But i am not new To Programming In General.(My Background Of Programming was mostly JavaScript And Python) Does anyone recommend Any Upcoming Rated Contest That Is not very hard? I Took Codeforces round 670 div2 and it was really hard For me :( i know about Binary Search, Bubble Sort algrorithms and about arrays and stacks. But Still couldn't solve Problem A. Can Anyone Help Me Find A suitable Contest For Me?
:( i know about Binary Search, Bubble Sort algrorithms and about arrays and stacks. But Still

Full text and comments »

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

59.
By ok12, 8 months ago, In English
Editorial of ICPC de Tryst 2026 I hope you enjoyed the contest! [Contest link](https://codeforces.me/contestInvitation/f8ab858a73f3627f85787c828e7ba84d12495ce9) <spoiler summary="Rating Predictions and Tags for the Problem"> | Problem | Expected Rating | Tags| | :---: | :---: | :---: | | [A. Game is Game](https://codeforces.me/gym/675631/problem/A) | 1500 | games, math | | [B. Hakurei Shrine's Purification Ritual](https://codeforces.me/gym/675631/problem/B)| 1600 |number theory, binary search| | [C. Permutation Game](https://codeforces.me/gym/675631/problem/C) | 2600 | dp, greedy, implementation,brute force | | [D. Path Blow-up?](https://codeforces.me/gym/675631/problem/D) | 2400|bitmasks, trees, dp, combinatorics, implementation| | [E. Coffee Date of MEX](https://codeforces.me/gym/675631/problem/E)|2100|constructive algorithms, brute force| | [F. Wordleforces](https://codeforces.me/gym/675631/problem/F) |1800 |math, combinatorics| | [G. Adaptive Guessing](https://codeforces.me/gym/675631/probl...
. * **Time Complexity:** $\mathcal{O}(N)$. Topo Sort and the distance calculation both require traversing the

Full text and comments »

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

60.
By worstesttest, history, 7 years ago, In English
masterpiece.txt Bee Movie Script According to all known laws of aviation, there is no way a bee should be able to fly. Its wings are too small to get its fat little body off the ground. The bee, of course, flies anyway because bees don't care what humans think is impossible. Yellow, black. Yellow, black. Yellow, black. Yellow, black. Ooh, black and yellow! Let's shake it up a little. Barry! Breakfast is ready! Ooming! Hang on a second. Hello? - Barry? - Adam? - Oan you believe this is happening? - I can't. I'll pick you up. Looking sharp. Use the stairs. Your father paid good money for those. Sorry. I'm excited. Here's the graduate. We're very proud of you, son. A perfect report card, all B's. Very proud. Ma! I got a thing going here. - You got lint on your fuzz. - Ow! That's me! - Wave to us! We'll be in row 118,000. - Bye! Ba...
formula is automatically color-corrected, scent-adjusted and bubble-contoured into this

Full text and comments »

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