Open In App

Contest Experiences | Codeforce Round: #878 (Div. 3)

Last Updated : 30 Oct, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

About the Contest:

The contest was organized by Codeforces on June 6, 2023. It consisted of 8 questions and the time given to solve them was 2 hours 15 minutes i.e. 135 mins.

Link of the Contest: Codeforces Round #878 (Div 3)

Overview of the Questions:

Problem Name

Difficulty

Pre-Requisite

Time to Solve by Me

Number of Attempts

Cipher Shifer

Easy (800)

Implementation, String

9 mins

1

Binary Cafe

Easy (1100)

Implementation, combinatorics, math

39 mins

1

Ski Resort

Easy (1000)

combinatorics, math

33 mins

3

Wooden Toy Festival

Medium (1400)

sorting, binary search

47 mins

1

Character Blocking

Medium (1600)

data structures, sorting, implementation

After the contest

2 (Both WA)

Railguns

Hard (2200)

brute force, dfs and similar, dp, graph

In Search of Truth (Easy Version)

Hard (2200)

constructive algorithm, math, interactive, probability

In Search of Truth (Hard Version)

Hard (2500)

constructive algorithm, math, interactive, probability

EXPERIENCE:

Problem A: Cipher Shifer

My Experience: Like usual Div 3 contests, the first question was an easy cake-walk problem. This question was very straight-forward and the constraints were so low that it could even be solved through brute force approach using O(N2) loop.

Approach:

The approach was to use two pointer concept to find answer string. Whenever, we encounter two indexes where s[i] == s[j], we add that character to answer string and increment the both pointers for searching similar occurrences in the remaining string. The time complexity for each test case will be O(N).

Problem B: Binary Cafe

My Experience: Unlike other Div 3 contests, this question was a bit tedious and took comparatively more time to solve. My approach was to find sum of powers of 2 from 0 to m and compare it with n. I implemented it using binary exponentiation concept. However, the next day I was surprised to see a 2 liner approach to solve this problem.

Approach:

Based on my approach, initialize a sum variable and find the sum of powers of 2 from 0 to m. During the loop, if at any point, the sum value exceeds the number of coins, simply return n + 1 as the number of ways(+1 to indicate null set). This would take almost O(m) time complexity for each test case. However, a much smaller approach to this problem is to just find minimum of 2k and n + 1. Using this optimal approach, the problem could be solved in O(1) time complexity for each test case.

Problem C: Ski Resort

My Experience: After spending so long time in problem B, my rank was almost 6000+. Yet I was delighted that I got the approach for this question in the first go after reading it. I started coding accordingly and submitted but it gave wrong answer. I made a few changes with regards to the constraints of the problem, but it still gave wrong answer on the same test case. Then I tried to make a few test cases of my own and tried to dry run on my code. There I realized the missing condition. I rectified it and re-coded that block. The submission got accepted in the 3rd try and thereby I conceded a lot of penalties.

Approach:

The approach to this question is to sum the answers of all the consecutive indexes where elements are less than the value of q. More formally, the aim is to sum all the number of ways to choose travel dates for segments where consecutive elements arri <= q. Maintain a count for consecutive integers whose value is less than q and whenever the condition breaks, reset the count value to 0. At every index, sum the number of ways to choose travel dates like ans += cnt – k + 1. The time complexity to solve each test will be O(N).

Problem D: Wooden Toy Festival

My Experience: The questions statement was very lengthy so I had to read it multiple times to understand what it’s asking. It was very theoretical and not straight-forward. It was essential to extract certain keywords from the question through which you get hint as to which data structure or algorithm you can use. In this question, the statement, “maximum waiting time over all people”, gives the hint of using binary search to find the maximum value.

Approach:

More formally, the question is based on the concept of binary search on answer. Since each toy will take | x – y | time, hence the aim is to minimize this time by minimizing the value of y. More precisely, The aim is to calculate such a minimum value of mid for which count of indexes having | xi – p | > mid value is less than or equal to 3 (p represent the index of last encountered pattern). If the count is <= 3 then it is in desired range. However, we want to find the minimum value of mid, hence we store mid value as answer and shift the high pointer to mid – 1 to search even low value in the right side of array. If it returns false, then we move left pointer to mid + 1. The time complexity for each test case will be O(nlogn).

Problem E: Character Blocking

My Experience: Upon the successful submission to problem D, there were less than 10 minutes left in the contest. Yet I read the problem statement just for the sake of evaluating what concept it is based upon. The question was straight forward and asked to find answer to each query. Since the time was over, I attempted the question after the contest ended. However, I was unable to successfully solve the question as it gave wrong answer for initial test cases. The question was based on the concept of hashing and some additional data structures like set.

Conclusion

In comparison to other Div 3 contests, this contest’s difficulty level was very high. The potential reason for this was because every question was based on combination of multiple concepts. Especially the last 3 questions were so difficult that only a few people managed to solve them. Problem F was only solved by 9 people, problem G1 was only solved by 73 people and problem G2 was only solved by 4 people in the contest. The key takeaways from the concept is to never underestimate the non-standard concepts like combinatorics and probability. It must not be assumed that these concepts would rarely come in contests.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads