Generalized master equation for first-passage problems in partitioned spaces