LOS ANGELES — Stanford was playing with a spring in its step Saturday, skipping into the halftime break with a 20-point lead after five points in a 10-second stretch before the buzzer.

It ended up being the best thing that could have happened — to USC.

Oneyka Okongwu scored 22 points and Elijah Weaver hit a clutch 3-pointer to force overtime as USC rallied from a 21-point second-half deficit to earn an 82-78 victory Saturday.

Stanford’s late first-half scoring outburst prompted a team admonishing by USC head coach Andy Enfield that was probably coming even if Stanford (15-3, 4-1 Pac-12) didn’t get a Jaiden Delaire layup with 10 seconds remaining in the first half and a 3-pointer from Tyrell Terry with one second on the clock.

Enfield’s halftime intensity transferred to his team’s defensive effort in the second half, which ended up making the offense click as the Trojans figured out a way to overcome the Cardinal.

USC (15-3, 4-1) trailed 46-25 early in the second half. The Trojans chased down the Cardinal over the next 19 minutes. They owned the extra period. Enfield supplied the fuel.

“After the halftime speech we got from Coach, it was time to lock in and play,” Weaver said. “One hundred percent that’s what it was; it was our defense.”

What did Enfield say exactly? Weaver smiled. Whatever it was, it worked.

“I used my dad’s deep voice at halftime,” Enfield said. “I yelled very loud and they responded. We beat a very good team. We came out with energy. We had missed so many close shots in the first half and they made shots. Some of the first half was them, but a lot was us.”

Weaver continued to deliver for the Trojans in overtime, scoring eight of his team’s 13 points. He finished with 13. His 3-pointer at the regulation buzzer was his only make from distance in five attempts.

USC trailed 69-64 with 33 seconds remaining in regulation after Stanford’s Lukas Kisunas made a layup. The Trojans took over from there.

Okongwu made a layup with 11 seconds remaining, and after a Daejon Davis turnover on the inbound pass, Weaver hit his off-balance 3-pointer while getting fouled by Davis. Weaver missed his free throw that would have given the Trojans the lead.

Despite that miss, Weaver remained confident in the extra period.

“Just have a short memory and keep playing,” Weaver said.

Oscar da Silva scored 21 points and Spencer Jones added 18 for Stanford. Terry had 16 for the Cardinal.