Open In App

Contest Experiences | Codeforce: Hello 2023

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

About the Contest:

This contest was organized on the codeforces platform. It took place on January 3, 2023, from 20:05(UTC+5:30), consisted of 8 problems and needed to be solved in 150 minutes.

Prizes/offers: Nothing as such, it was a rated contest for all.

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

Overview of the questions asked:

Problem Name

Difficulty

Pre-requisites

Approx time to solve by me

No. of submissions

A. Hall of Fame

Easy

Greedy Algorithms

3-4 minutes

1

B. MKnez’s ConstructiveForces Task

Easy

Math and Implementation

5-10 minutes

1

C. Least Prefix Sum

Easy-Medium

Greedy Algorithms and Priority Queue

15 minutes

1

D. Boris and His Amazing Haircut

Medium

Stack

20 minutes

2(1 TLE)

E. Anya’s Simultaneous Exhibition

Medium-Hard

Graph

60minutes

3

F. Xorcerer’s Stones

Hard

Trees , Dynamic Programming and Boolean Algebra

60 minutes

4

G. The Game of the Century

Hard

0-1 BFS

NA

1

H. Olympic Team Building

Very Hard

meet-in-the-middle

NA

0

A. Hall of Fame:

This was a pretty simple question on greedy. We can conclude that all trophies are illuminated if L appears right after some R. And quite well handle the other case.

B. MKnez’s ConstructiveForces Task

Here I just cared about, for an even number of elements, alternate between -1 and 1. For an odd number, fix the first two elements and alternate between them. Use algebra to solve for the remaining elements.

C. Least Prefix Sum

To decrease a prefix sum, the maximal element in the segment [x+1,m] is chosen and an operation is performed on it. If a new prefix sum emerges, the algorithm is repeated. If x>m, a minimal element in segment [m+1,x] is chosen and the algorithm is repeated. A priority queue is used to implement this in O(nlogn) time.

D. Boris and His Amazing Haircut

A simple solution to the problem can be implemented using a stack and some containers. The razor sizes are tracked and counted by putting them into a container and checking if they are a subset of the input array. Cuts are implemented using a monotone stack that represents all valid cuts until “now”. The stack is popped until the top is greater than or equal to bn, and if the new top is equal to bn, the algorithm continues. Otherwise, bn is added to the stack as a cut must be performed. The total complexity is O(nlogn+mlogm) due to sorting/mapping.

E. Anya’s Simultaneous Exhibition

A simul is hosted for each player, except themselves, to determine the necessary out-degrees and find the candidate master with the highest out-degree. Players are then sorted by out-degree and a current value w is maintained. Additional simuls are hosted for each player to update the set of candidate master’s and decrease w. The total number of simuls required is 2n.

F. Xorcerer’s Stone

If nodes u and v have even subtrees, performing a spell on u and then on v does not make sense if u is an ancestor of v or vice versa. If neither is a parent of the other, we only need to choose subtrees such that their total XOR is equal to the XOR of the root. Dynamic programming and reconstruction can be used to find the subtrees, with transitions done for each edge in similar fashion to the knapsack problem, but with XOR instead of sums. The time complexity is O(nA2) and memory complexity is O(nA).

Conclusion:

It was a great contest to start the year with, like a standard codeforces contest it was worth looking upon. Learned a lot of new skills and time management specifically.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads