The defending champions suffered a humiliating defeat at the hands of tiny Equatorial Guinea on Sunday and must now beat the Ivory Coast in Douala in their last Group E match on Thursday to stand any chance of advancing to the last 16.
Algeria, whose 35-match unbeaten record went up in smoke amid one of the tournament's great upsets, are bottom of the group with a solitary point.
That came from another disappointing performance, at the start of the 24-team tournament in Cameroon, when they were held by lowly-ranked Sierra Leone, making their return for the first time since the 1996 finals.
"The message is simple: we have to win. We lacked efficiency and we must be more spontaneous in our attacking," Mahrez said.
"When your back is against the wall, you shouldn't talk too much. Everyone knows what they have to do."
Algeria could follow the way of fellow heavyweight contenders Ghana, who were knocked out on Tuesday in another shock result as they went down to the Comoros Islands, but coach Djamel Belmadi said he was confident of a positive response from his team.
"We absolutely have to win if we want to continue. It's a big challenge but we have the ability to respond," he added.
Algeria have only beaten the Ivorians twice in eight previous meetings at the finals, but got past them on penalties at the last edition in Egypt in 2019, before going onto take the trophy.