Botafogo failed to advance to the Rio Cup semifinals despite beating America 3-1 on Sunday, losing the spot to Olaria following its 2-2 draw with Vasco.
Olaria and Fluminense advanced from Group B, while Vasco and Flamengo went through from Group A. The Rio Cup is the second stage of the Rio de Janeiro state tournament and its winner will face Guanabara Cup champion Flamengo for the state title.
Flamengo will have to play rival Fluminense instead of Olaria in one of the semifinals after Ronaldinho missed an injury-time penalty kick in the team's 1-1 draw with Macae. Vasco will play Olaria again.
Flamengo can automatically win the overall state title if it also wins the Rio Cup.
Botafogo right back Lucas scored twice and Uruguay striker Sebastian ''El Loco'' Abreu added another in the victory over relegated America at Sao Januario stadium.
But Botafogo needed Vasco to beat Olaria in Macae if it was to advance to the semifinals. Botafogo hadn't previously missed the semifinals of the Rio Cup or the Guanabara Cup since 2007.
Flamengo would have finished first in Group A if Ronaldinho had converted the penalty four minutes into second-half injury time against Macae in Volta Redonda.
The playmaker sent the ball over the crossbar, setting up his team's matchup against Fluminense, which beat Nova Iguacu 1-0 from a goal by striker Fred at Engenhao stadium.
''I'm sure things will go right for me when the time is right,'' Ronaldinho said.
In the Sao Paulo state tournament, the quarterfinal lineup was decided and the teams involved include Sao Paulo, Palmeiras, Corinthians and Santos.
Sao Paulo finished the group stage in first place after a 1-1 draw with Oeste in Mogi Mirim, while Palmeiras was second after losing 2-1 to Ponte Preta in Campinas. Sao Paulo and Palmeiras finished with 41 points from 19 rounds but Sao Paulo is ahead on matches won.
Sao Paulo will play against Portuguesa, which was the final team to advance after beating Sao Bernardo 1-0 from a late goal at Caninde stadium. Palmeiras will face Mirassol, Corinthians will meet Oeste and defending champion Santos takes on Ponte Preta.
The quarterfinals and the semifinals will be decided in one match.