Cow and Message

Revision en1, by jhjfbsbfkbjfnfnfjfj, 2020-04-28 11:38:27

Can anyone please help me explain the solution? https://codeforces.com/problemset/problem/1307/C

ll dp[27][27] = {0}, cnt[27] ={0};
ll ans = 0;
for (ll i = 0; i < str.length(); ++i) {
    for (ll j = 0; j < 26; ++j)
    dp[str[i] - 'a'][j] += cnt[j]; //what are we calculating using this dp and how 
    cnt[str[i] - 'a']++;
}

for (ll i = 0; i < 26; ++i) {
    ans = max(ans, cnt[i]);
    for (ll j = 0; j < 26; ++j)
        ans = max(ans, dp[i][j]);
}

pf1(ans);

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English jhjfbsbfkbjfnfnfjfj 2020-04-28 11:38:27 553 Initial revision (published)