CSES Mex Grid Construction Explained | Understanding the MEX Approach | C++
Tutorial2Heaven
0:00 / 0:00
CSES Mex Grid Construction Explained | Understanding the MEX Approach | C++
28 просмотров · 2 нед. назад
Tutorial2Heaven
32 подписчика
28 просмотров · 2 нед. назад
In this CSES problem, you are given an \(n \times n\) grid that needs to be constructed using non-negative integers. The task is to fill each cell with the MEX (Minimum EXcludant) of the elements present above and to the left of that cell.
The MEX of a set is the smallest non-negative integer that is not present in the set.
In this video, the solution is explained step by step using a simple observation: for each cell, consider the elements above and to its left, insert them into a set, and find their MEX to determine the value of the current cell.
The main approach focuses on understanding how this observation leads to the grid construction, followed by the C++ implementation.
*Topics Covered:* MEX, Grid Construction, Constructive Algorithms, C++