Codeforces Round 875 (Div. 1)

Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
1830 Codeforces Round 875 (Div. 1) FINISHED False 9000 46538699 May 28, 2023, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 251 ) E Bully Sort PROGRAMMING data structures

B'On a permutation p of length n , we define a bully swap as follows: We define f(p) as the number of bully swaps we need to perform until p becomes sorted. Note that if p is the identity permutation, f(p)=0 . You are given n and a permutation p of length n . You need to process the following q updates. In each update, you are given two integers x and y . You will swap p_x and p_y and then find the value of f(p) . Note that the updates are persistent. Changes made to the permutation p will apply when processing future updates. The first line of the input contains two integers n and q ( 2 <= n <= 5 cdot 10^5 , 1 <= q <= 5 cdot 10^4 ) -- the length of the permutation and the number of updates. The second line of input contains n integer p_1,p_2, ldots,p_n ( 1 <= q p_i <= q n ) -- the permutation p . All elements of p are distinct. The i -th of the next q lines of input contains two integers x_i and y_i ( 1 <= x_i < y_i <= n ) -- describing the i -th update. After each update, output f(p) . After the first update, we have f(p)=5 . The 5 bully swaps are illustrated below. '...

Tutorials

Codeforces Round #875 (Div.1 + Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
207690733 ahmedmekawyxa E May 28, 2023, 11:01 p.m. OK GNU C++14 TESTS 40 6645 1015910400
207713105 DoNotMoZheng E May 29, 2023, 4:56 a.m. OK GNU C++17 (64) TESTS 40 5178 56115200
207716897 njwrz E May 29, 2023, 5:50 a.m. OK GNU C++20 (64) TESTS 40 1450 318771200
207686767 iliya7 E May 28, 2023, 9:02 p.m. OK GNU C++20 (64) TESTS 40 2854 235110400
207686738 ilyushaa E May 28, 2023, 9:02 p.m. OK GNU C++20 (64) TESTS 40 2854 235110400
207670984 maspy E May 28, 2023, 5:48 p.m. OK GNU C++20 (64) TESTS 40 2917 235110400
207716008 bachbeo2007 E May 29, 2023, 5:39 a.m. OK GNU C++20 (64) TESTS 40 3213 275353600
207717752 orz_z E May 29, 2023, 6:01 a.m. OK GNU C++20 (64) TESTS 40 3618 18329600
207716980 orz_z E May 29, 2023, 5:51 a.m. OK GNU C++20 (64) TESTS 40 5038 26316800
207715760 Crying E May 29, 2023, 5:35 a.m. OK GNU C++20 (64) TESTS 40 5475 306585600
207675540 Sputnik1234 E May 28, 2023, 6:22 p.m. OK GNU C++20 (64) TESTS 40 5849 201216000
207661818 ecnerwala E May 28, 2023, 4:50 p.m. OK GNU C++20 (64) TESTS 40 5849 201216000

remove filters

Back to search problems