Cooperation in alternating interactions with memory constraints