How to solve Sereja and Ways in the Cube (SEAWCU) problem which appeared in Nov 16 Long contest?

What logic is used to solve this problem? In general, how to approach such approximation type problems which appear in the long contest?