A strange situation (possibly a bug) in #979 E

Revision en1, by wuhudsm, 2024-10-19 20:28:50

In today's Codeforces Round 979, I encountered a strange situation in Problem E.

This is my submission during the contest: https://mirror.codeforces.com/contest/2030/submission/286816828. It got TLE in test #9.

However, when I modified the code as follows, it passed in about 500ms: https://mirror.codeforces.com/contest/2030/submission/286824231.

The original code:

//
dp[i&1].clear();
f[i&1].clear();
sufdp[i&1].clear();
suff[i&1].clear();
//

The modified code:

//
/*
dp[i&1].clear();
f[i&1].clear();
sufdp[i&1].clear();
suff[i&1].clear();
*/
if(i>1)
{
    for(int j=0;j<=cnt[i-2];j++)
    dp[i&1][j]=f[i&1][j]=sufdp[i&1][j]=suff[i&1][j]=0;
}
//

This is the only part I modified.

I don't understand why this code caused TLE, and I would greatly appreciate it if anyone could help.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English wuhudsm 2024-10-19 20:28:50 888 Initial revision (published)