A/B Matrix
HardRating 1900CodeforcesConstructive Algorithms
Approach hintTry it first, then revealHide
Counting the ones by rows and by columns gives a necessary condition on n, m, a, b. To meet it, spread the ones evenly over the columns, for example by letting each row continue cyclically from where the previous row stopped.