Cow and Message

Правка en1, от jhjfbsbfkbjfnfnfjfj, 2020-04-28 11:38:27

Can anyone please help me explain the solution? https://codeforces.net/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);

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский jhjfbsbfkbjfnfnfjfj 2020-04-28 11:38:27 553 Initial revision (published)