Open In App

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

Last Updated : 09 Nov, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

About the contest:

  • This contest was conducted by codeforces #873 for Div 3 Participants.
  • In this contest, there are a total of 6 problems, and 2 hours are given to solve this problem.
  • The penalty was 10 minutes for each wrong submission.

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

My Experience:

I was able to solve 5 out of 6 problems during these contests.

OVERVIEW OF ALL CONTEST PROBLEM:

Problem

Difficulty

Approx time to solve

Number of submissions by me

A. Counting Orders

Easy

10 – 15 minutes

1

B1. Range Sorting (Easy Version)

Easy

10 – 15 minutes

1

B2. Range Sorting (Hard Version)

Medium

10 – 15 minutes

1

C. Palindrome Partition

Medium

20 – 25 minutes

2

D. Two Centroids

Medium

20 – 25 minutes

2

E. Bus Routes

Medium

20 – 25 minutes

1

F.Copium Permutation

Hard

LET’S DISCUSS THE PROBLEM:

Problem A. Counting Orders

To solve this problem, we can follow these steps: Sort the arrays a and b separately. For each element in array a, find the number of elements in array b that are less than it. Calculate the number of ways to reorder array a such that ai > bi for all 1 ≤ i ≤ n by using combinatorics.

Problem B1. Range Sorting (Easy Version)

To solve this problem, we do this .For each element in the array a, find the number of elements to its left that are less than it. This can be done using a prefix count or prefix sum technique. Similarly, find the number of elements to the right that are less than the current element. This step also employs a prefix count or sum technique. For each element a[i], the count of subarrays in which a[i] will be the minimum element is left_count * right_count, where left_count represents the number of elements to the left less than a[i] and right_count represents the number of elements to the right less than a[i]. Calculate the beauty of each element by summing up the count of subarrays it contributes to. Sum up the beauty for all elements in the array a to get the final result.

Problem B2. Range Sorting (Hard Version)

Use a Divide and Conquer strategy employing a segment tree or merge sort-based approach. Count inversions for each element, representing the number of elements greater than the current element on both its left and right sides. Sum up these inversions for each element to obtain the total beauty of the array.

Problem C. Palindrome Partition

Iterate through the string and count the number of beautiful substrings by examining each character. For every character, verify both odd and even length substrings centered around it. Count these substrings that form even palindromes or are partitioned into even palindromes to determine the total count of beautiful substrings in the given string.

Problem D. Two Centroids

Initially, find centroids in the tree: nodes whose removal splits the tree into smaller subtrees with at most ⌊n/2⌋ vertices. After each query (adding a vertex and edge), recompute centroids. Calculate the minimum operations required to achieve two centroids in the updated tree and output this count for each query.

Problem E. Bus Routes

To solve this for a given city network forming a tree, the objective is to assess the feasibility of traveling between any pair of cities using a maximum of two bus routes. To address this, a graph representing the city connections is created, and then, for each city pair u and v, the code checks if there is a route via at most two buses to reach u from v. If such connections exist for every city pair, it outputs “YES”; otherwise, it outputs “NO” and specifies a pair of cities between which travel within two bus routes is unattainable.

Conclusion:

At the end I was able to solve 5 problem out of 6 problem. last question was difficult to me. I waste lot of time to solve last question but I was not able to solve it. All the best for upcoming contest.
Thank you !!!


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads