problem_number
stringclasses
123 values
problem_letter
stringclasses
33 values
problem_title
stringlengths
1
46
tags
stringlengths
2
129
difficulty
stringclasses
41 values
problem_link
stringlengths
43
56
start_time
stringclasses
117 values
language
stringclasses
2 values
problem_site
stringclasses
3 values
description
stringlengths
331
6.84k
2041
E
Beautiful Array
["constructive algorithms", "math"]
1200
https://codeforces.com/problemset/problem/2041/E
1732431900
en
codeforces
# Beautiful Array ## Problem Description ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2041E/123e9f2378be455eca9fba5ff4bfa308ab2b1a77.png) Image generated by ChatGPT 4o.A-Ming's birthday is coming and his friend A-May decided to give him an integer array as a present. A-Ming has two favorite numbers $ a $ and $ b ...
2041
D
Drunken Maze
["brute force", "dfs and similar", "graphs", "shortest paths"]
1700
https://codeforces.com/problemset/problem/2041/D
1732431900
en
codeforces
# Drunken Maze ## Problem Description ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2041D/ac90366c626ba21a7610cf55d06b2398a53105ff.png) Image generated by ChatGPT 4o.You are given a two-dimensional maze with a start and end position. Your task is to find the fastest way to get from the start to the end position. T...
2041
C
Cube
["bitmasks", "dfs and similar", "dp"]
2000
https://codeforces.com/problemset/problem/2041/C
1732431900
en
codeforces
# Cube ## Problem Description ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2041C/83a685de6f3f0e2c5499a1f04f05272c24e66bde.png)You are given an $ n\times n\times n $ big three-dimensional cube that contains $ n^3 $ numbers. You have to choose $ n $ of those numbers so that their sum is as small as possible. It is,...
2041
A
The Bento Box Adventure
["implementation", "sortings"]
1300
https://codeforces.com/problemset/problem/2041/A
1732431900
en
codeforces
# The Bento Box Adventure ## Problem Description ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2041A/6724e41fa1b725d06db3c22a7057ae0e507a6d98.png) Image generated by ChatGPT 4o.Boxed meals in Taiwan are very common, offering convenient and affordable nutrition-balanced choices for students and office workers. Thes...
2040
F
Number of Cubes
["combinatorics", "dp", "math", "number theory"]
2700
https://codeforces.com/problemset/problem/2040/F
1733668500
en
codeforces
# Number of Cubes ## Problem Description Consider a rectangular parallelepiped with sides $ a $ , $ b $ , and $ c $ , that consists of unit cubes of $ k $ different colors. We can apply cyclic shifts to the parallelepiped in any of the three directions any number of times $ ^{\text{โˆ—}} $ . There are $ d_i $ cubes of...
2040
E
Control of Randomness
["combinatorics", "dfs and similar", "dp", "graphs", "greedy", "math", "probabilities", "trees"]
2100
https://codeforces.com/problemset/problem/2040/E
1733668500
en
codeforces
# Control of Randomness ## Problem Description You are given a tree with $ n $ vertices. Let's place a robot in some vertex $ v \ne 1 $ , and suppose we initially have $ p $ coins. Consider the following process, where in the $ i $ -th step (starting from $ i = 1 $ ): - If $ i $ is odd, the robot moves to an adjace...
2040
D
Non Prime Tree
["brute force", "constructive algorithms", "dfs and similar", "greedy", "number theory", "trees", "two pointers"]
1900
https://codeforces.com/problemset/problem/2040/D
1733668500
en
codeforces
# Non Prime Tree ## Problem Description You are given a tree with $ n $ vertices. You need to construct an array $ a_1, a_2, \ldots, a_n $ of length $ n $ , consisting of unique integers from $ 1 $ to $ 2 \cdot n $ , and such that for each edge $ u_i \leftrightarrow v_i $ of the tree, the value $ |a_{u_i} - a_{v_i}|...
2040
C
Ordered Permutations
["bitmasks", "combinatorics", "constructive algorithms", "greedy", "math", "two pointers"]
1600
https://codeforces.com/problemset/problem/2040/C
1733668500
en
codeforces
# Ordered Permutations ## Problem Description Consider a permutation $ ^{\text{โˆ—}} $ $ p_1, p_2, \ldots, p_n $ of integers from $ 1 $ to $ n $ . We can introduce the following sum for it $ ^{\text{โ€ }} $ : $ $$$S(p) = \sum_{1 \le l \le r \le n} \min(p_l, p_{l + 1}, \ldots, p_r) $ $ </p><p>Let us consider all permuta...
2040
B
Paint a Strip
["constructive algorithms", "greedy", "math"]
1000
https://codeforces.com/problemset/problem/2040/B
1733668500
en
codeforces
# Paint a Strip ## Problem Description You have an array of zeros $ a_1, a_2, \ldots, a_n $ of length $ n $ . You can perform two types of operations on it: 1. Choose an index $ i $ such that $ 1 \le i \le n $ and $ a_i = 0 $ , and assign $ 1 $ to $ a_i $ ; 2. Choose a pair of indices $ l $ and $ r $ such that $ 1 ...
2040
A
Game of Division
["games", "math"]
800
https://codeforces.com/problemset/problem/2040/A
1733668500
en
codeforces
# Game of Division ## Problem Description You are given an array of integers $ a_1, a_2, \ldots, a_n $ of length $ n $ and an integer $ k $ . Two players are playing a game. The first player chooses an index $ 1 \le i \le n $ . Then the second player chooses a different index $ 1 \le j \le n, i \neq j $ . The first ...
2039
H2
Cool Swap Walk (Hard Version)
["constructive algorithms", "constructive algorithms", "constructive algorithms", "implementation", "sortings"]
3500
https://codeforces.com/problemset/problem/2039/H2
1732372500
en
codeforces
# Cool Swap Walk (Hard Version) ## Problem Description This is the hard version of the problem. The only difference is the maximum number of operations you can perform. You can only make hacks if both versions are solved. You are given an array $ a $ of size $ n $ . A cool swap walk is the following process: - In ...
2039
H1
Cool Swap Walk (Easy Version)
["constructive algorithms", "implementation", "sortings"]
3500
https://codeforces.com/problemset/problem/2039/H1
1732372500
en
codeforces
# Cool Swap Walk (Easy Version) ## Problem Description This is the easy version of the problem. The only difference is the maximum number of operations you can perform. You can only make hacks if both versions are solved. You are given an array $ a $ of size $ n $ . A cool swap walk is the following process: - In ...
2039
G
Shohag Loves Pebae
["math", "number theory"]
3500
https://codeforces.com/problemset/problem/2039/G
1732372500
en
codeforces
# Shohag Loves Pebae ## Problem Description Shohag has a tree with $ n $ nodes. Pebae has an integer $ m $ . She wants to assign each node a value โ€” an integer from $ 1 $ to $ m $ . So she asks Shohag to count the number, modulo $ 998\,244\,353 $ , of assignments such that following conditions are satisfied: - For ...
2039
F2
Shohag Loves Counting (Hard Version)
["dp", "number theory"]
3200
https://codeforces.com/problemset/problem/2039/F2
1732372500
en
codeforces
# Shohag Loves Counting (Hard Version) ## Problem Description This is the hard version of the problem. The only differences between the two versions of this problem are the constraints on $ t $ , $ m $ , and the sum of $ m $ . You can only make hacks if both versions of the problem are solved. For an integer array $...
2039
F1
Shohag Loves Counting (Easy Version)
["combinatorics", "dp", "math", "number theory"]
2800
https://codeforces.com/problemset/problem/2039/F1
1732372500
en
codeforces
# Shohag Loves Counting (Easy Version) ## Problem Description This is the easy version of the problem. The only differences between the two versions of this problem are the constraints on $ t $ , $ m $ , and the sum of $ m $ . You can only make hacks if both versions of the problem are solved. For an integer array $...
2039
E
Shohag Loves Inversions
["combinatorics", "dp", "implementation", "math"]
2200
https://codeforces.com/problemset/problem/2039/E
1732372500
en
codeforces
# Shohag Loves Inversions ## Problem Description Shohag has an array $ a $ of integers. Initially $ a = [0, 1] $ . He can repeatedly perform the following operation any number of times: - Let $ k $ be the number of inversions $ ^{\text{โˆ—}} $ in the current array $ a $ . - Insert $ k $ at any position in $ a $ , incl...
2039
D
Shohag Loves GCD
["constructive algorithms", "greedy", "math", "number theory"]
1700
https://codeforces.com/problemset/problem/2039/D
1732372500
en
codeforces
# Shohag Loves GCD ## Problem Description Shohag has an integer $ n $ and a set $ S $ of $ m $ unique integers. Help him find the lexicographically largest $ ^{\text{โˆ—}} $ integer array $ a_1, a_2, \ldots, a_n $ such that $ a_i \in S $ for each $ 1 \le i \le n $ and $ a_{\operatorname{gcd}(i, j)} \neq \operatorname{g...
2039
C2
Shohag Loves XOR (Hard Version)
["bitmasks", "brute force", "math", "number theory"]
1800
https://codeforces.com/problemset/problem/2039/C2
1732372500
en
codeforces
# Shohag Loves XOR (Hard Version) ## Problem Description This is the hard version of the problem. The differences between the two versions are highlighted in bold. You can only make hacks if both versions of the problem are solved. Shohag has two integers $ x $ and $ m $ . Help him count the number of integers $ 1 \...
2039
C1
Shohag Loves XOR (Easy Version)
["bitmasks", "brute force", "math", "number theory"]
1200
https://codeforces.com/problemset/problem/2039/C1
1732372500
en
codeforces
# Shohag Loves XOR (Easy Version) ## Problem Description This is the easy version of the problem. The differences between the two versions are highlighted in bold. You can only make hacks if both versions of the problem are solved. Shohag has two integers $ x $ and $ m $ . Help him count the number of integers $ 1 \...
2039
B
Shohag Loves Strings
["constructive algorithms", "greedy", "implementation", "strings"]
1000
https://codeforces.com/problemset/problem/2039/B
1732372500
en
codeforces
# Shohag Loves Strings ## Problem Description For a string $ p $ , let $ f(p) $ be the number of distinct non-empty substrings $ ^{\text{โˆ—}} $ of $ p $ . Shohag has a string $ s $ . Help him find a non-empty string $ p $ such that $ p $ is a substring of $ s $ and $ f(p) $ is even or state that no such string exists...
2039
A
Shohag Loves Mod
["constructive algorithms", "number theory"]
800
https://codeforces.com/problemset/problem/2039/A
1732372500
en
codeforces
# Shohag Loves Mod ## Problem Description Shohag has an integer $ n $ . Please help him find an increasing integer sequence $ 1 \le a_1 \lt a_2 \lt \ldots \lt a_n \le 100 $ such that $ a_i \bmod i \neq a_j \bmod j $ $ ^{\text{โˆ—}} $ is satisfied over all pairs $ 1 \le i \lt j \le n $ . It can be shown that such a seq...
2038
N
Fixing the Expression
["implementation"]
800
https://codeforces.com/problemset/problem/2038/N
1731926100
en
codeforces
# Fixing the Expression ## Problem Description An expression is a string consisting of three characters, where the first and the last characters are digits (from $ 0 $ to $ 9 $ ), and the middle character is a comparison symbol (&lt;, = or &gt;). An expression is true if the comparison symbol matches the digits (for...
2038
M
Royal Flush
["dp", "implementation"]
2800
https://codeforces.com/problemset/problem/2038/M
1731926100
en
codeforces
# Royal Flush ## Problem Description Consider the following game. There is a deck, which consists of cards of $ n $ different suits. For each suit, there are $ 13 $ cards in the deck, all with different ranks (the ranks are $ 2 $ , $ 3 $ , $ 4 $ , ..., $ 10 $ , Jack, Queen, King and Ace). Initially, the deck is shuf...
2038
L
Bridge Renovation
["brute force", "dp", "greedy", "math", "two pointers"]
1400
https://codeforces.com/problemset/problem/2038/L
1731926100
en
codeforces
# Bridge Renovation ## Problem Description Recently, Monocarp started working as a director of a park located near his house. The park is quite large, so it even has a small river splitting it into several zones. Several bridges are built across this river. Three of these bridges are especially old and need to be rep...
2038
K
Grid Walk
["brute force", "dp", "greedy", "math", "number theory"]
2100
https://codeforces.com/problemset/problem/2038/K
1731926100
en
codeforces
# Grid Walk ## Problem Description You have an $ n \times n $ grid and two integers $ a $ and $ b $ . Both the rows and the columns are numbered from $ 1 $ to $ n $ . Let's denote the cell at the intersection of the $ i $ -th row and the $ j $ -th column as $ (i, j) $ . You are standing in the cell $ (1, 1) $ and wa...
2038
J
Waiting for...
["greedy", "implementation"]
800
https://codeforces.com/problemset/problem/2038/J
1731926100
en
codeforces
# Waiting for... ## Problem Description Monocarp is waiting for a bus at the bus stop. Unfortunately, there are many people who want to ride a bus too. You are given a list of events of two types: - B $ b_i $ โ€” a bus with $ b_i $ free seats arrives at the stop; - P $ p_i $ โ€” $ p_i $ people arrive at the stop. Thes...
2038
I
Polyathlon
["binary search", "data structures", "hashing", "string suffix structures", "strings"]
2500
https://codeforces.com/problemset/problem/2038/I
1731926100
en
codeforces
# Polyathlon ## Problem Description Berland is this year's host country of the International Collegiate Polyathlon Competition! Similar to biathlon being a competition of two sports, polyathlon is a competition of many sports. This year, there are $ m $ sports. Also, there are $ n $ participants in the event. The spo...
2038
H
Galactic Council
["flows"]
3000
https://codeforces.com/problemset/problem/2038/H
1731926100
en
codeforces
# Galactic Council ## Problem Description Monocarp plays a computer game. In this game, he maintains a space empire. The empire is governed by $ n $ political parties. Initially, every party has political power equal to $ 0 $ , and there is no ruling party. During each of the next $ m $ turns, the following happens:...
2038
G
Guess One Character
["constructive algorithms", "implementation", "interactive"]
1900
https://codeforces.com/problemset/problem/2038/G
1731926100
en
codeforces
# Guess One Character ## Problem Description This is an interactive problem. You have to use flush operation right after printing each line. For example, in C++ you should use the function fflush(stdout) or cout.flush(), in Java or Kotlin โ€” System.out.flush(), and in Python โ€” sys.stdout.flush(). The jury has a strin...
2038
F
Alternative Platforms
["combinatorics", "data structures", "fft", "math", "sortings"]
2500
https://codeforces.com/problemset/problem/2038/F
1731926100
en
codeforces
# Alternative Platforms ## Problem Description Suppose you are working in the Ministry of Digital Development of Berland, and your task is to monitor the industry of video blogging. There are $ n $ bloggers in Berland. Recently, due to the poor state of the main video platform in Berland, two alternative platforms w...
2038
E
Barrels
["data structures", "greedy", "math"]
2900
https://codeforces.com/problemset/problem/2038/E
1731926100
en
codeforces
# Barrels ## Problem Description Suppose you have $ n $ water barrels standing in a row, numbered from $ 1 $ to $ n $ . All barrels are equal and have a bottom area equal to one unit, so the volume of the water inside a barrel is equal to the height of the water column. Initially, the $ i $ -th barrel has $ v_i $ un...
2038
D
Divide OR Conquer
["binary search", "bitmasks", "data structures", "dp", "implementation"]
2400
https://codeforces.com/problemset/problem/2038/D
1731926100
en
codeforces
# Divide OR Conquer ## Problem Description You are given an array $ [a_1, a_2, \ldots a_n] $ consisting of integers between $ 0 $ and $ 10^9 $ . You have to split this array into several segments (possibly one) in such a way that each element belongs to exactly one segment. Let the first segment be the array $ [a_{l...
2038
C
DIY
["data structures", "geometry", "greedy", "sortings"]
1400
https://codeforces.com/problemset/problem/2038/C
1731926100
en
codeforces
# DIY ## Problem Description You are given a list of $ n $ integers $ a_1, a_2, \dots, a_n $ . You need to pick $ 8 $ elements from the list and use them as coordinates of four points. These four points should be corners of a rectangle which has its sides parallel to the coordinate axes. Your task is to pick coordina...
2038
B
Make It Equal
["binary search", "brute force", "greedy", "math"]
2100
https://codeforces.com/problemset/problem/2038/B
1731926100
en
codeforces
# Make It Equal ## Problem Description You are given an integer array $ a $ of size $ n $ . The elements of the array are numbered from $ 1 $ to $ n $ . You can perform the following operation any number of times (possibly, zero): choose an index $ i $ from $ 1 $ to $ n $ ; decrease $ a_i $ by $ 2 $ and increase $ a...
2038
A
Bonus Project
["games", "greedy"]
1400
https://codeforces.com/problemset/problem/2038/A
1731926100
en
codeforces
# Bonus Project ## Problem Description There is a team of $ n $ software engineers numbered from $ 1 $ to $ n $ . Their boss promises to give them a bonus if they complete an additional project. The project requires $ k $ units of work in total. The bonus promised to the $ i $ -th engineer is $ a_i $ burles. The boss...
2037
G
Natlan Exploring
["bitmasks", "combinatorics", "data structures", "dp", "math", "number theory"]
2000
https://codeforces.com/problemset/problem/2037/G
1731854100
en
codeforces
# Natlan Exploring ## Problem Description You are exploring the stunning region of Natlan! This region consists of $ n $ cities, and each city is rated with an attractiveness $ a_i $ . A directed edge exists from City $ i $ to City $ j $ if and only if $ i < j $ and $ \gcd(a_i,a_j)\neq 1 $ , where $ \gcd(x, y) $ deno...
2037
F
Ardent Flames
["binary search", "data structures", "math", "sortings", "two pointers"]
2100
https://codeforces.com/problemset/problem/2037/F
1731854100
en
codeforces
# Ardent Flames ## Problem Description You have obtained the new limited event character Xilonen. You decide to use her in combat. There are $ n $ enemies in a line. The $ i $ 'th enemy from the left has health $ h_i $ and is currently at position $ x_i $ . Xilonen has an attack damage of $ m $ , and you are ready t...
2037
E
Kachina's Favorite Binary String
["dp", "greedy", "interactive", "two pointers"]
1600
https://codeforces.com/problemset/problem/2037/E
1731854100
en
codeforces
# Kachina's Favorite Binary String ## Problem Description This is an interactive problem. Kachina challenges you to guess her favorite binary string $ ^{\text{โˆ—}} $ $ s $ of length $ n $ . She defines $ f(l, r) $ as the number of subsequences $ ^{\text{โ€ }} $ of $ \texttt{01} $ in $ s_l s_{l+1} \ldots s_r $ . Two sub...
2037
D
Sharky Surfing
["data structures", "greedy", "two pointers"]
1300
https://codeforces.com/problemset/problem/2037/D
1731854100
en
codeforces
# Sharky Surfing ## Problem Description Mualani loves surfing on her sharky surfboard! Mualani's surf path can be modeled by a number line. She starts at position $ 1 $ , and the path ends at position $ L $ . When she is at position $ x $ with a jump power of $ k $ , she can jump to any integer position in the inter...
2037
C
Superultra's Favorite Permutation
["constructive algorithms", "greedy", "math", "number theory"]
1000
https://codeforces.com/problemset/problem/2037/C
1731854100
en
codeforces
# Superultra's Favorite Permutation ## Problem Description Superultra, a little red panda, desperately wants primogems. In his dreams, a voice tells him that he must solve the following task to obtain a lifetime supply of primogems. Help Superultra! Construct a permutation $ ^{\text{โˆ—}} $ $ p $ of length $ n $ such ...
2037
B
Intercepted Inputs
["brute force", "implementation"]
800
https://codeforces.com/problemset/problem/2037/B
1731854100
en
codeforces
# Intercepted Inputs ## Problem Description To help you prepare for your upcoming Codeforces contest, Citlali set a grid problem and is trying to give you a $ n $ by $ m $ grid through your input stream. Specifically, your input stream should contain the following: - The first line contains two integers $ n $ and $ ...
2037
A
Twice
["implementation"]
800
https://codeforces.com/problemset/problem/2037/A
1731854100
en
codeforces
# Twice ## Problem Description Kinich wakes up to the start of a new day. He turns on his phone, checks his mailbox, and finds a mysterious present. He decides to unbox the present. Kinich unboxes an array $ a $ with $ n $ integers. Initially, Kinich's score is $ 0 $ . He will perform the following operation any num...
2036
G
Library of Magic
["binary search", "constructive algorithms", "divide and conquer", "interactive", "math", "number theory"]
2200
https://codeforces.com/problemset/problem/2036/G
1730558100
en
codeforces
# Library of Magic ## Problem Description This is an interactive problem. The Department of Supernatural Phenomena at the Oxenfurt Academy has opened the Library of Magic, which contains the works of the greatest sorcerers of Redania โ€” $ n $ ( $ 3 \leq n \leq 10^{18} $ ) types of books, numbered from $ 1 $ to $ n $ ...
2036
F
XORificator 3000
["bitmasks", "dp", "number theory", "two pointers"]
1900
https://codeforces.com/problemset/problem/2036/F
1730558100
en
codeforces
# XORificator 3000 ## Problem Description Alice has been giving gifts to Bob for many years, and she knows that what he enjoys the most is performing [bitwise XOR](http://tiny.cc/xor_wiki_eng) of interesting integers. Bob considers a positive integer $ x $ to be interesting if it satisfies $ x \not\equiv k (\bmod 2^i...
2036
E
Reverse the Rivers
["binary search", "constructive algorithms", "data structures", "greedy"]
1600
https://codeforces.com/problemset/problem/2036/E
1730558100
en
codeforces
# Reverse the Rivers ## Problem Description A conspiracy of ancient sages, who decided to redirect rivers for their own convenience, has put the world on the brink. But before implementing their grand plan, they decided to carefully think through their strategy โ€” that's what sages do. There are $ n $ countries, each...
2036
D
I Love 1543
["brute force", "implementation", "matrices"]
1300
https://codeforces.com/problemset/problem/2036/D
1730558100
en
codeforces
# I Love 1543 ## Problem Description One morning, Polycarp woke up and realized that $ 1543 $ is the most favorite number in his life. The first thing that Polycarp saw that day as soon as he opened his eyes was a large wall carpet of size $ n $ by $ m $ cells; $ n $ and $ m $ are even integers. Each cell contains o...
2036
C
Anya and 1100
["brute force", "implementation"]
1100
https://codeforces.com/problemset/problem/2036/C
1730558100
en
codeforces
# Anya and 1100 ## Problem Description While rummaging through things in a distant drawer, Anya found a beautiful string $ s $ consisting only of zeros and ones. Now she wants to make it even more beautiful by performing $ q $ operations on it. Each operation is described by two integers $ i $ ( $ 1 \le i \le |s| $...
2036
B
Startup
["greedy", "sortings"]
800
https://codeforces.com/problemset/problem/2036/B
1730558100
en
codeforces
# Startup ## Problem Description Arseniy came up with another business plan โ€” to sell soda from a vending machine! For this, he purchased a machine with $ n $ shelves, as well as $ k $ bottles, where the $ i $ -th bottle is characterized by the brand index $ b_i $ and the cost $ c_i $ . You can place any number of b...
2036
A
Quintomania
["implementation"]
800
https://codeforces.com/problemset/problem/2036/A
1730558100
en
codeforces
# Quintomania ## Problem Description Boris Notkin composes melodies. He represents them as a sequence of notes, where each note is encoded as an integer from $ 0 $ to $ 127 $ inclusive. The interval between two notes $ a $ and $ b $ is equal to $ |a - b| $ semitones. Boris considers a melody perfect if the interval ...
2035
H
Peak Productivity Forces
["constructive algorithms"]
3500
https://codeforces.com/problemset/problem/2035/H
1730039700
en
codeforces
# Peak Productivity Forces ## Problem Description I'm peakly productive and this is deep. You are given two permutations $ ^{\text{โˆ—}} $ $ a $ and $ b $ , both of length $ n $ . You can perform the following three-step operation on permutation $ a $ : 1. Choose an index $ i $ ( $ 1 \le i \le n $ ). 2. Cyclic shi...
2035
G2
Go Learn! (Hard Version)
["divide and conquer", "dp"]
3500
https://codeforces.com/problemset/problem/2035/G2
1730039700
en
codeforces
# Go Learn! (Hard Version) ## Problem Description The differences between the easy and hard versions are the constraints on $ n $ and the sum of $ n $ . In this version, $ n \leq 3\cdot 10^5 $ and the sum of $ n $ does not exceed $ 10^6 $ . You can only make hacks if both versions are solved. Well, well, well, let's...
2035
G1
Go Learn! (Easy Version)
["dp", "trees"]
3300
https://codeforces.com/problemset/problem/2035/G1
1730039700
en
codeforces
# Go Learn! (Easy Version) ## Problem Description The differences between the easy and hard versions are the constraints on $ n $ and the sum of $ n $ . In this version, $ n \leq 3000 $ and the sum of $ n $ does not exceed $ 10^4 $ . You can only make hacks if both versions are solved. Well, well, well, let's see ho...
2035
F
Tree Operations
["binary search", "brute force", "dfs and similar", "dp", "trees"]
2500
https://codeforces.com/problemset/problem/2035/F
1730039700
en
codeforces
# Tree Operations ## Problem Description This really says a lot about our society. One day, a turtle gives you a tree with $ n $ nodes rooted at node $ x $ . Each node has an initial nonnegative value; the $ i $ -th node has starting value $ a_i $ . You want to make the values of all nodes equal to $ 0 $ . To do ...
2035
E
Monster
["binary search", "brute force", "constructive algorithms", "greedy", "implementation", "math", "ternary search"]
2300
https://codeforces.com/problemset/problem/2035/E
1730039700
en
codeforces
# Monster ## Problem Description Man, this Genshin boss is so hard. Good thing they have a top-up of $ 6 $ coins for only $ \$4.99 $ . I should be careful and spend no more than I need to, lest my mom catches me... You are fighting a monster with $ z $ health using a weapon with $ d $ damage. Initially, $ d=0 $ ....
2035
D
Yet Another Real Number Problem
["binary search", "data structures", "divide and conquer", "greedy", "implementation", "math"]
1800
https://codeforces.com/problemset/problem/2035/D
1730039700
en
codeforces
# Yet Another Real Number Problem ## Problem Description Three r there are's in strawberry. You are given an array $ b $ of length $ m $ . You can perform the following operation any number of times (possibly zero): - Choose two distinct indices $ i $ and $ j $ where $ \bf{1\le i < j\le m} $ and $ b_i $ is even, ...
2035
C
Alya and Permutation
["bitmasks", "constructive algorithms", "math"]
1400
https://codeforces.com/problemset/problem/2035/C
1730039700
en
codeforces
# Alya and Permutation ## Problem Description Alya has been given a hard problem. Unfortunately, she is too busy running for student council. Please solve this problem for her. Given an integer $ n $ , construct a permutation $ p $ of integers $ 1, 2, \ldots, n $ that maximizes the value of $ k $ (which is initially...
2035
B
Everyone Loves Tres
["constructive algorithms", "greedy", "math", "number theory"]
900
https://codeforces.com/problemset/problem/2035/B
1730039700
en
codeforces
# Everyone Loves Tres ## Problem Description There are 3 heroes and 3 villains, so 6 people in total. Given a positive integer $ n $ . Find the smallest integer whose decimal representation has length $ n $ and consists only of $ 3 $ s and $ 6 $ s such that it is divisible by both $ 33 $ and $ 66 $ . If no such in...
2035
A
Sliding
["implementation", "math"]
800
https://codeforces.com/problemset/problem/2035/A
1730039700
en
codeforces
# Sliding ## Problem Description Red was ejected. They were not the imposter. There are $ n $ rows of $ m $ people. Let the position in the $ r $ -th row and the $ c $ -th column be denoted by $ (r, c) $ . Number each person starting from $ 1 $ in row-major order, i.e., the person numbered $ (r-1)\cdot m+c $ is in...
2034
H
Rayan vs. Rayaneh
["brute force", "dfs and similar", "dp", "number theory"]
3300
https://codeforces.com/problemset/problem/2034/H
1732977300
en
codeforces
# Rayan vs. Rayaneh ## Problem Description Rayan makes his final efforts to win Reyhaneh's heart by claiming he is stronger than Rayaneh (i.e., computer in Persian). To test this, Reyhaneh asks [Khwarizmi](https://en.wikipedia.org/wiki/Al-Khwarizmi) for help. Khwarizmi explains that a set is integer linearly independ...
2034
G2
Simurgh's Watch (Hard Version)
["greedy", "implementation"]
3500
https://codeforces.com/problemset/problem/2034/G2
1732977300
en
codeforces
# Simurgh's Watch (Hard Version) ## Problem Description The only difference between the two versions of the problem is whether overlaps are considered at all points or only at integer points. The legendary [Simurgh](https://www.eavartravel.com/blog/2023/11/3/140727/simurgh/), a mythical bird, is responsible for keep...
2034
G1
Simurgh's Watch (Easy Version)
["constructive algorithms", "greedy", "implementation", "sortings"]
3500
https://codeforces.com/problemset/problem/2034/G1
1732977300
en
codeforces
# Simurgh's Watch (Easy Version) ## Problem Description The only difference between the two versions of the problem is whether overlaps are considered at all points or only at integer points. The legendary [Simurgh](https://www.eavartravel.com/blog/2023/11/3/140727/simurgh/), a mythical bird, is responsible for keep...
2034
F2
Khayyam's Royal Decree (Hard Version)
["combinatorics", "dp", "math", "sortings"]
2800
https://codeforces.com/problemset/problem/2034/F2
1732977300
en
codeforces
# Khayyam's Royal Decree (Hard Version) ## Problem Description This is the hard version of the problem. The only differences between the two versions are the constraints on $ k $ and the sum of $ k $ . In ancient Persia, [Khayyam](https://en.wikipedia.org/wiki/Omar_Khayyam), a clever merchant and mathematician, is p...
2034
F1
Khayyam's Royal Decree (Easy Version)
["combinatorics", "dp", "math", "sortings"]
2500
https://codeforces.com/problemset/problem/2034/F1
1732977300
en
codeforces
# Khayyam's Royal Decree (Easy Version) ## Problem Description This is the easy version of the problem. The only differences between the two versions are the constraints on $ k $ and the sum of $ k $ . In ancient Persia, [Khayyam](https://en.wikipedia.org/wiki/Omar_Khayyam), a clever merchant and mathematician, is p...
2034
E
Permutations Harmony
["combinatorics", "constructive algorithms", "greedy", "hashing", "math"]
2200
https://codeforces.com/problemset/problem/2034/E
1732977300
en
codeforces
# Permutations Harmony ## Problem Description Rayan wants to present a gift to Reyhaneh to win her heart. However, Reyhaneh is particular and will only accept a k-harmonic set of permutations. We define a k-harmonic set of permutations as a set of $ k $ pairwise distinct permutations $ p_1, p_2, \ldots, p_k $ of siz...
2034
D
Darius' Wisdom
["constructive algorithms", "greedy", "implementation", "sortings"]
1600
https://codeforces.com/problemset/problem/2034/D
1732977300
en
codeforces
# Darius' Wisdom ## Problem Description [Darius the Great](https://en.wikipedia.org/wiki/Darius_the_Great) is constructing $ n $ stone columns, each consisting of a base and between $ 0 $ , $ 1 $ , or $ 2 $ inscription pieces stacked on top. In each move, Darius can choose two columns $ u $ and $ v $ such that the d...
2034
C
Trapped in the Witch's Labyrinth
["constructive algorithms", "dfs and similar", "graphs", "implementation"]
1400
https://codeforces.com/problemset/problem/2034/C
1732977300
en
codeforces
# Trapped in the Witch's Labyrinth ## Problem Description In the [fourth labor of Rostam](https://www.gathertales.com/story/the-tale-of-the-haft-khan-seven-labors-of-rostam/sid-604), the legendary hero from the [Shahnameh](https://en.wikipedia.org/wiki/Shahnameh), an old witch has created a magical maze to trap him. ...
2034
B
Rakhsh's Revival
["data structures", "greedy", "implementation", "two pointers"]
1000
https://codeforces.com/problemset/problem/2034/B
1732977300
en
codeforces
# Rakhsh's Revival ## Problem Description [Rostam](https://en.wikipedia.org/wiki/Rostam)'s loyal horse, [Rakhsh](https://en.wikipedia.org/wiki/Rakhsh), has seen better days. Once powerful and fast, Rakhsh has grown weaker over time, struggling to even move. Rostam worries that if too many parts of Rakhsh's body lose ...
2034
A
King Keykhosrow's Mystery
["brute force", "chinese remainder theorem", "math", "number theory"]
800
https://codeforces.com/problemset/problem/2034/A
1732977300
en
codeforces
# King Keykhosrow's Mystery ## Problem Description There is a tale about the wise [King Keykhosrow](https://en.wikipedia.org/wiki/Kay_Khosrow) who owned a grand treasury filled with treasures from across the Persian Empire. However, to prevent theft and ensure the safety of his wealth, King Keykhosrow's vault was sea...
2033
G
Sakurako and Chefir
["data structures", "dfs and similar", "dp", "greedy", "trees"]
2200
https://codeforces.com/problemset/problem/2033/G
1729780500
en
codeforces
# Sakurako and Chefir ## Problem Description Given a tree with $ n $ vertices rooted at vertex $ 1 $ . While walking through it with her cat Chefir, Sakurako got distracted, and Chefir ran away. To help Sakurako, Kosuke recorded his $ q $ guesses. In the $ i $ -th guess, he assumes that Chefir got lost at vertex $ v...
2033
F
Kosuke's Sloth
["brute force", "math", "number theory"]
1800
https://codeforces.com/problemset/problem/2033/F
1729780500
en
codeforces
# Kosuke's Sloth ## Problem Description Kosuke is too lazy. He will not give you any legend, just the task: Fibonacci numbers are defined as follows: - $ f(1)=f(2)=1 $ . - $ f(n)=f(n-1)+f(n-2) $ $ (3\le n) $ We denote $ G(n,k) $ as an index of the $ n $ -th Fibonacci number that is divisible by $ k $ . For given ...
2033
E
Sakurako, Kosuke, and the Permutation
["brute force", "data structures", "dfs and similar", "dsu", "graphs", "greedy", "math"]
1400
https://codeforces.com/problemset/problem/2033/E
1729780500
en
codeforces
# Sakurako, Kosuke, and the Permutation ## Problem Description Sakurako's exams are over, and she did excellently. As a reward, she received a permutation $ p $ . Kosuke was not entirely satisfied because he failed one exam and did not receive a gift. He decided to sneak into her room (thanks to the code for her lock...
2033
D
Kousuke's Assignment
["data structures", "dp", "dsu", "greedy", "math"]
1300
https://codeforces.com/problemset/problem/2033/D
1729780500
en
codeforces
# Kousuke's Assignment ## Problem Description After a trip with Sakurako, Kousuke was very scared because he forgot about his programming assignment. In this assignment, the teacher gave him an array $ a $ of $ n $ integers and asked him to calculate the number of non-overlapping segments of the array $ a $ , such th...
2033
C
Sakurako's Field Trip
["dp", "greedy", "two pointers"]
1400
https://codeforces.com/problemset/problem/2033/C
1729780500
en
codeforces
# Sakurako's Field Trip ## Problem Description Even in university, students need to relax. That is why Sakurakos teacher decided to go on a field trip. It is known that all of the students will be walking in one line. The student with index $ i $ has some topic of interest which is described as $ a_i $ . As a teacher...
2033
B
Sakurako and Water
["brute force", "constructive algorithms", "greedy"]
900
https://codeforces.com/problemset/problem/2033/B
1729780500
en
codeforces
# Sakurako and Water ## Problem Description During her journey with Kosuke, Sakurako and Kosuke found a valley that can be represented as a matrix of size $ n \times n $ , where at the intersection of the $ i $ -th row and the $ j $ -th column is a mountain with a height of $ a_{i,j} $ . If $ a_{i,j} < 0 $ , then the...
2033
A
Sakurako and Kosuke
["constructive algorithms", "implementation", "math"]
800
https://codeforces.com/problemset/problem/2033/A
1729780500
en
codeforces
# Sakurako and Kosuke ## Problem Description Sakurako and Kosuke decided to play some games with a dot on a coordinate line. The dot is currently located in position $ x=0 $ . They will be taking turns, and Sakurako will be the one to start. On the $ i $ -th move, the current player will move the dot in some directi...
2032
F
Peanuts
["combinatorics", "dp", "games", "math"]
2700
https://codeforces.com/problemset/problem/2032/F
1730471700
en
codeforces
# Peanuts ## Problem Description Having the magical beanstalk, Jack has been gathering a lot of peanuts lately. Eventually, he has obtained $ n $ pockets of peanuts, conveniently numbered $ 1 $ to $ n $ from left to right. The $ i $ -th pocket has $ a_i $ peanuts. Jack and his childhood friend Alice decide to play a...
2032
E
Balanced
["constructive algorithms", "data structures", "greedy", "implementation", "math"]
2400
https://codeforces.com/problemset/problem/2032/E
1730471700
en
codeforces
# Balanced ## Problem Description You are given a cyclic array $ a $ with $ n $ elements, where $ n $ is odd. In each operation, you can do the following: - Choose an index $ 1 \le i \le n $ and increase $ a_{i - 1} $ by $ 1 $ , $ a_i $ by $ 2 $ , and $ a_{i + 1} $ by $ 1 $ . The element before the first element is ...
2032
D
Genokraken
["constructive algorithms", "data structures", "graphs", "greedy", "implementation", "interactive", "trees", "two pointers"]
1800
https://codeforces.com/problemset/problem/2032/D
1730471700
en
codeforces
# Genokraken ## Problem Description This is an interactive problem. Upon clearing the Waterside Area, Gretel has found a monster named Genokraken, and she's keeping it contained for her scientific studies. The monster's nerve system can be structured as a tree $ ^{\dagger} $ of $ n $ nodes (really, everything shoul...
2032
C
Trinity
["binary search", "math", "sortings", "two pointers"]
1400
https://codeforces.com/problemset/problem/2032/C
1730471700
en
codeforces
# Trinity ## Problem Description You are given an array $ a $ of $ n $ elements $ a_1, a_2, \ldots, a_n $ . You can perform the following operation any number (possibly $ 0 $ ) of times: - Choose two integers $ i $ and $ j $ , where $ 1 \le i, j \le n $ , and assign $ a_i := a_j $ . Find the minimum number of oper...
2032
B
Medians
["constructive algorithms", "greedy", "implementation", "math"]
1100
https://codeforces.com/problemset/problem/2032/B
1730471700
en
codeforces
# Medians ## Problem Description You are given an array $ a = [1, 2, \ldots, n] $ , where $ n $ is odd, and an integer $ k $ . Your task is to choose an odd positive integer $ m $ and to split $ a $ into $ m $ subarrays $ ^{\dagger} $ $ b_1, b_2, \ldots, b_m $ such that: - Each element of the array $ a $ belongs to...
2032
A
Circuit
["greedy", "implementation", "math", "number theory"]
800
https://codeforces.com/problemset/problem/2032/A
1730471700
en
codeforces
# Circuit ## Problem Description Alice has just crafted a circuit with $ n $ lights and $ 2n $ switches. Each component (a light or a switch) has two states: on or off. The lights and switches are arranged in a way that: - Each light is connected to exactly two switches. - Each switch is connected to exactly one lig...
2031
F
Penchick and Even Medians
["binary search", "constructive algorithms", "interactive", "probabilities"]
2800
https://codeforces.com/problemset/problem/2031/F
1731674100
en
codeforces
# Penchick and Even Medians ## Problem Description This is an interactive problem. Returning from a restful vacation on Australia's Gold Coast, Penchick forgot to bring home gifts for his pet duck Duong Canh! But perhaps a beautiful problem crafted through deep thought on the scenic beaches could be the perfect souv...
2031
E
Penchick and Chloe's Trees
["data structures", "dfs and similar", "dp", "greedy", "implementation", "math", "sortings", "trees"]
2100
https://codeforces.com/problemset/problem/2031/E
1731674100
en
codeforces
# Penchick and Chloe's Trees ## Problem Description With just a few hours left until Penchick and Chloe leave for Singapore, they could hardly wait to see the towering trees at the Singapore Botanic Gardens! Attempting to contain their excitement, Penchick crafted a rooted tree to keep Chloe and himself busy. Penchi...
2031
D
Penchick and Desert Rabbit
["binary search", "data structures", "dfs and similar", "dp", "dsu", "greedy", "implementation", "two pointers"]
1700
https://codeforces.com/problemset/problem/2031/D
1731674100
en
codeforces
# Penchick and Desert Rabbit ## Problem Description Dedicated to pushing himself to his limits, Penchick challenged himself to survive the midday sun in the Arabian Desert! While trekking along a linear oasis, Penchick spots a desert rabbit preparing to jump along a line of palm trees. There are $ n $ trees, each wi...
2031
C
Penchick and BBQ Buns
["constructive algorithms", "math", "number theory"]
1300
https://codeforces.com/problemset/problem/2031/C
1731674100
en
codeforces
# Penchick and BBQ Buns ## Problem Description Penchick loves two things: square numbers and Hong Kong-style BBQ buns! For his birthday, Kohane wants to combine them with a gift: $ n $ BBQ buns arranged from left to right. There are $ 10^6 $ available fillings of BBQ buns, numbered from $ 1 $ to $ 10^6 $ . To ensure ...
2031
B
Penchick and Satay Sticks
["brute force", "greedy", "sortings"]
900
https://codeforces.com/problemset/problem/2031/B
1731674100
en
codeforces
# Penchick and Satay Sticks ## Problem Description Penchick and his friend Kohane are touring Indonesia, and their next stop is in Surabaya! In the bustling food stalls of Surabaya, Kohane bought $ n $ satay sticks and arranged them in a line, with the $ i $ -th satay stick having length $ p_i $ . It is given that $...
2031
A
Penchick and Modern Monument
["constructive algorithms", "dp", "greedy", "math"]
800
https://codeforces.com/problemset/problem/2031/A
1731674100
en
codeforces
# Penchick and Modern Monument ## Problem Description Amidst skyscrapers in the bustling metropolis of Metro Manila, the newest Noiph mall in the Philippines has just been completed! The construction manager, Penchick, ordered a state-of-the-art monument to be built with $ n $ pillars. The heights of the monument's ...
2030
G2
The Destruction of the Universe (Hard Version)
["combinatorics", "math"]
3100
https://codeforces.com/problemset/problem/2030/G2
1729346700
en
codeforces
# The Destruction of the Universe (Hard Version) ## Problem Description This is the hard version of the problem. In this version, $ n \leq 10^6 $ . You can only make hacks if both versions of the problem are solved. Orangutans are powerful beingsโ€”so powerful that they only need $ 1 $ unit of time to destroy every vu...
2030
G1
The Destruction of the Universe (Easy Version)
["combinatorics", "greedy", "math"]
2900
https://codeforces.com/problemset/problem/2030/G1
1729346700
en
codeforces
# The Destruction of the Universe (Easy Version) ## Problem Description This is the easy version of the problem. In this version, $ n \leq 5000 $ . You can only make hacks if both versions of the problem are solved. Orangutans are powerful beingsโ€”so powerful that they only need $ 1 $ unit of time to destroy every vu...
2030
F
Orangutan Approved Subarrays
["binary search", "data structures", "dp", "greedy", "implementation", "two pointers"]
2400
https://codeforces.com/problemset/problem/2030/F
1729346700
en
codeforces
# Orangutan Approved Subarrays ## Problem Description Suppose you have an array $ b $ . Initially, you also have a set $ S $ that contains all distinct elements of $ b $ . The array $ b $ is called orangutan-approved if it can be emptied by repeatedly performing the following operation: - In one operation, select in...
2030
E
MEXimize the Score
["combinatorics", "data structures", "dp", "greedy", "implementation", "math"]
2200
https://codeforces.com/problemset/problem/2030/E
1729346700
en
codeforces
# MEXimize the Score ## Problem Description Suppose we partition the elements of an array $ b $ into any number $ k $ of non-empty multisets $ S_1, S_2, \ldots, S_k $ , where $ k $ is an arbitrary positive integer. Define the score of $ b $ as the maximum value of $ \operatorname{MEX}(S_1) $ $ ^{\text{โˆ—}} $ $ + \ope...
2030
D
QED's Favorite Permutation
["data structures", "implementation", "sortings"]
1700
https://codeforces.com/problemset/problem/2030/D
1729346700
en
codeforces
# QED's Favorite Permutation ## Problem Description QED is given a permutation $ ^{\text{โˆ—}} $ $ p $ of length $ n $ . He also has a string $ s $ of length $ n $ containing only characters $ \texttt{L} $ and $ \texttt{R} $ . QED only likes permutations that are sorted in non-decreasing order. To sort $ p $ , he can s...
2030
C
A TRUE Battle
["brute force", "games", "greedy"]
1100
https://codeforces.com/problemset/problem/2030/C
1729346700
en
codeforces
# A TRUE Battle ## Problem Description Alice and Bob are playing a game. There is a list of $ n $ booleans, each of which is either true or false, given as a binary string $ ^{\text{โˆ—}} $ of length $ n $ (where $ \texttt{1} $ represents true, and $ \texttt{0} $ represents false). Initially, there are no operators bet...
2030
B
Minimise Oneness
["combinatorics", "constructive algorithms", "games", "math"]
800
https://codeforces.com/problemset/problem/2030/B
1729346700
en
codeforces
# Minimise Oneness ## Problem Description For an arbitrary binary string $ t $ $ ^{\text{โˆ—}} $ , let $ f(t) $ be the number of non-empty subsequences $ ^{\text{โ€ }} $ of $ t $ that contain only $ \mathtt{0} $ , and let $ g(t) $ be the number of non-empty subsequences of $ t $ that contain at least one $ \mathtt{1} $ ....
2030
A
A Gift From Orangutan
["constructive algorithms", "greedy", "math", "sortings"]
800
https://codeforces.com/problemset/problem/2030/A
1729346700
en
codeforces
# A Gift From Orangutan ## Problem Description While exploring the jungle, you have bumped into a rare orangutan with a bow tie! You shake hands with the orangutan and offer him some food and water. In return... The orangutan has gifted you an array $ a $ of length $ n $ . Using $ a $ , you will construct two arrays...
2029
I
Variance Challenge
["flows", "graphs", "greedy"]
3400
https://codeforces.com/problemset/problem/2029/I
1731162900
en
codeforces
# Variance Challenge ## Problem Description Kevin has recently learned the definition of variance. For an array $ a $ of length $ n $ , the variance of $ a $ is defined as follows: - Let $ x=\dfrac{1}{n}\displaystyle\sum_{i=1}^n a_i $ , i.e., $ x $ is the mean of the array $ a $ ; - Then, the variance of $ a $ is $ ...
2029
H
Message Spread
["bitmasks", "brute force", "combinatorics", "dp"]
3500
https://codeforces.com/problemset/problem/2029/H
1731162900
en
codeforces
# Message Spread ## Problem Description Given is an undirected graph with $ n $ vertices and $ m $ edges. Each edge connects two vertices $ (u, v) $ and has a probability of $ \frac{p}{q} $ of appearing each day. Initially, vertex $ 1 $ has a message. At the end of the day, a vertex has a message if and only if itse...
2029
G
Balanced Problem
["data structures", "dp"]
3000
https://codeforces.com/problemset/problem/2029/G
1731162900
en
codeforces
# Balanced Problem ## Problem Description There is an array $ a $ consisting of $ n $ integers. Initially, all elements of $ a $ are equal to $ 0 $ . Kevin can perform several operations on the array. Each operation is one of the following two types: - Prefix addition โ€” Kevin first selects an index $ x $ ( $ 1\le x...
2029
F
Palindrome Everywhere
["constructive algorithms", "graphs", "greedy"]
2500
https://codeforces.com/problemset/problem/2029/F
1731162900
en
codeforces
# Palindrome Everywhere ## Problem Description You are given a cycle with $ n $ vertices numbered from $ 0 $ to $ n-1 $ . For each $ 0\le i\le n-1 $ , there is an undirected edge between vertex $ i $ and vertex $ ((i+1)\bmod n) $ with the color $ c_i $ ( $ c_i=\texttt{R} $ or $ \texttt{B} $ ). Determine whether the ...
2029
E
Common Generator
["brute force", "constructive algorithms", "math", "number theory"]
2100
https://codeforces.com/problemset/problem/2029/E
1731162900
en
codeforces
# Common Generator ## Problem Description For two integers $ x $ and $ y $ ( $ x,y\ge 2 $ ), we will say that $ x $ is a generator of $ y $ if and only if $ x $ can be transformed to $ y $ by performing the following operation some number of times (possibly zero): - Choose a divisor $ d $ ( $ d\ge 2 $ ) of $ x $ , t...