When the grounds for divorce occurred in Maryland, just must be currently living in Maryland at the time you file the divorce paperwork. If the grounds for divorce occurred outside Maryland, then one of the parties had to live in Maryland for at least six months before filing a divorce complaint.
In DC a resident can file for divorce in DC if either party has been a resident of DC for six months before the date you file the divorce papers with the court.