Open In App

Contest Experiences | Codeforces: Educational #141

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

ABOUT THE CONTEST:

  • This Educational contest was conducted by codeforces #141.
  • In this Contest, there are a total of 7 problems, and 2 hours time given to you to solve this problem.
  • For each wrong submission, the 10-minute extra penalty was there.

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

OVERVIEW OF ALL CONTEST PROBLEM:

Problem Name

Difficulty

Approx. time to solve

Number of submissions by me

Make it Beautiful

Easy

10

1

Matrix of Differences

Easy

10

1

Yet Another Tournament

Easy-Medium

10

1

Different Arrays

Medium

15-20

2

Game of the Year

Medium

15-20

1

Double Sort II

Hard

20-25

2

Weighed Tree Radius

Hard

25

3

LET’S DISCUSS THE QUESTIONS:

Problem A- Make it Beautiful

To solve this problem, First Iterate through the given array from left to right. Compare each element with the sum of all elements before it. If we find an element that is equal to the sum of elements before it, it means the array cannot be beautiful. Print “NO” for this test case and move to the next one. If there is no such element, it means the array is already beautiful. Print “YES” and the original array.

Problem B- Matrix of Differences

In this problem we need to find a square matrix of size n*n where each integer from 1 to n² occurs exactly once, and the beauty of this matrix is maximized. The beauty of a matrix is defined as the number of different numbers among the absolute differences between side-adjacent elements in the matrix. To solve this for each test case, print a matrix of size n*n, where each number from 1 to n² occurs exactly once, in such a way that the beauty of the matrix is maximized. If there are multiple valid answers, print any of them.

Problem C -Yet Another Tournament

To solve this problem we first sort the list of preparation times for your opponents in descending order. Initialize variables total_time to keep track of the total preparation time used and min_place to track the minimum possible place, initially set to 1. Iterate through the sorted list of opponents’ preparation times. For each opponent: If adding their preparation time to total_time doesn’t exceed your available preparation time m, add it to total_time and move on to the next opponent. If it exceeds m, stop the iteration, and the minimum possible place is min_place. If we reached the end of the list of opponents, the minimum possible place is min_place.

Problem D- Different Arrays

To solve this use dynamic programming to create a 2D array dp of size n x n, where dp[i][j] represents the number of ways to reach the subarray from index i to index j. Initialize the diagonal elements of dp to 1 because a single element is always reachable.Use a nested loop to iterate over the subarray lengths, starting from 2 to n. Within this loop, iterate over all possible subarrays. Update dp[i][j] based on the values of a[i] and a[j. If a[i] and a[j] are not equal, subtract dp[i + 1][j – 1] from the current dp[i][j].After calculating all values of dp, the result will be in dp[0][n – 1], which represents the number of reachable arrays. At the end print the result.

Problem E- Game of the Year

In this question Monocarp and Polycarp are playing a computer game where they have to defeat n bosses. They each make k attempts to kill a boss in alternating turns. Monocarp kills the i-th boss on his ai-th attempt, and Polycarp kills the i-th boss on his bi-th attempt. The game ends when one of them kills the n-th boss. We need to find all values of k from 1 to n for which Monocarp kills all bosses.

Problem F- Double Sort II

The goal is to sort two permutations, a and b, in ascending order using the minimum number of operations. To solve this first Identify elements in a and b that are not in their correct positions . For each such element, choose i and swap elements in a and b to place them in the correct positions. Repeat this process until both a and b are sorted. Output the minimum number of operations and the chosen i values for each operation.

Problem G-Weighed Tree Radius

To solve this first start with the initial tree and weights. For each query, change the weight of a specific vertex. Recalculate the eccentricity of each vertex and find the minimum eccentricity, which is the radius of the tree.Print the radius after each query.

Conclusion:

This Codeforces Educational #141 contest was not to difficult . At the end of this contest, I was able to solve all problem. For me last 2 problem F and G was difficult, I waste lot of time to solve this two questions. All the best for upcoming contest.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads