HUNGALGO Implementation

Link: HUNGALGO - Editorial
I understand the logic. I unable to understand the implementation of 2nd loop.
Code Link:

for(int i = 0; i < N; i++) {
ok &= *min_element(a[i], a[i] + N) == 0 && *min_element(b[i], b[i] + N) == 0;
Please explain the loop.

It just checks if the minimum value of i^{th} row and i^{th} column are both 0 or not. If at any point either of them goes non-zero then ok is toggled to 0.
*min_{-}element(a[i],a[i]+N) fetches the value of minimum in i^{th} row.

1 Like