Open In App

Contest Experiences | Educational Codeforces Round #148 (Div. 2)

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

ABOUT THE CONTEST:

  • This Educational contest was conducted on 12 May 2023 by codeforces #148 for Div 2 Participants.
  • In this Contest, there are a total of 6 (question D-two Version )problems, and 2 hours and 15 minutes are given to you to solve this problem.
  • The penalty for each wrong submission was 10 minutes.

Link of the Contest: https://codeforces.com/contest/1832

OVERVIEW OF ALL CONTEST PROBLEM:

Problem Name

Difficulty

Approx time to solve for me

Number of submissions by me

New Palindrome

Easy

5 – 10 minutes

1

Maximum Sum

Easy-Medium

5 – 10 minutes

1

Contrast Value

Medium

10 – 15 minutes

1

Red-Blue Operations(Easy Version)

Medium

10 – 15 minutes

2

Red-Blue Operations (Hard Version)

Hard

20 – 25 minutes

2

Combinatorics Problem

Hard

20 – 25 minutes

3

Zombies

Hard

LET’S DISCUSS THE QUESTIONS:

Problem A: New Palindrome

Approach: The approach to this problem is we need to check whether it’s possible to rearrange the letters in the given palindrome to create another palindrome. We first count the frequency of each letter in the palindrome string. For a palindrome to be possible to rearrange, the number of characters with odd frequencies should be either 0 or 1 (for even-length palindromes, it should be 0, and for odd-length palindromes, it should be 1). If the above condition is met, we can rearrange the letters to form another palindrome; otherwise, it’s not possible.

Problem B: Maximum Sum

Approach: To solve this problem, we need to determine the maximum possible sum of elements in the array after performing exactly k operations, where each operation involves either removing the two minimum elements or removing the maximum element. Sort the array in non-decreasing order. Initialize a variable “result” to 0. Check If k is greater than 0 and the array size is at least 2, do these: If the last operation was to remove the maximum element, add the two minimum elements to “result” and remove them from the array. Otherwise, remove the maximum element and subtract it from “result.” and Decrease k by 1. At the end return the final “result” as the maximum possible sum.

Problem C: Contrast Value

Approach: In this problem, we need to find the minimum possible size of array b with the same contrast as array a. Initialize a variable “min_size” to 1 because the smallest subsequence of a must have at least one element. Then calculate the contrast of array a. Iterate through array a from left to right and calculate the contrast while incrementally removing elements one by one from the left. Compare the contrast of the current subsequence with the contrast of the whole array. If the contrast of the current subsequence is equal to the contrast of the whole array then update “min_size” to the length of the current subsequence. At last print “min_size” as the minimum possible size of array b.

Problem D1: Red-Blue Operations(Easy Version)

Approach: In this time-solvingproblem, we need to determine the largest minimum value in the array after applying each query’s operations. Initialize an array b of the same size as array a to keep track of whether each element is red (0) or blue (1). Initialize a variable “prefix_sum” to keep track of the prefix sum of elements in b up to a given index. This will help to determine how many red and blue elements are in the array at any point in time. Iterate through the queries: For each query “k,” find the maximum possible minimum value: First initialize “min_val” to a large number. Iterate through the elements of “a” and compute the potential minimum value if you apply the operations on each element as specified in the query. Track this value in min_val. At last print “min_val” as the answer for the query.

Problem D2: Red-Blue Operations (Hard Version)

Approach: The approach to solving the hard version of the “Red-Blue Operations” problem is similar to the easy version with some optimizations for larger inputs: Initialize an array to track the colors of elements.Precompute differences between elements when they become blue and red. For each query, calculate the prefix sum of the blue elements, then iterate through the array to find the maximum possible minimum value considering the operations specified in the query. At last print the maximum possible minimum value for each query.

Problem E: Combinatorics Problem

Approach: We need to calculate the array b and then compute the integer c as specified in the problem statement. First, calculate the array b based on the given formula. Initialize the variables and result. Iterate through each element in the array a (starting from the first element): and then calculate bi as specified in the problem statement. Update s with bi * i and then update the result by XOR-ing it with s. Finally print the final result, which is the XOR of all the values of s.

Conclusion:

In the end, I was able to solve A, B, C, D1, D2, and E problems. For me problem F was difficult. I wasted a lot of time-solving problems D2 and F, but I was not able to solve the last F problem. All the best for the upcoming contest.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads