fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4. #define tc int t; cin>>t; while(t--)
  5. #define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
  6. #define mod 1000000007;
  7. #define pb push_back
  8. #define vi vector<int>
  9. #define vc vector<char>
  10. #define eb emplace_back
  11. #define pii pair<int,int>
  12. #define all(x) x.begin(),x.end()
  13. #define rall(x) x.rbegin(),x.rend()
  14. #define fo(i,x,n) for(int i=x;i<n;i++)
  15. const int inf=0x3f3f3f3f3f3f3f3f;
  16. #define btoi(str,i) stoi(str,0,i)
  17. #define ff first
  18. #define ss second
  19. #define tz(x) __builtin_ctz(x)
  20. #define csb(x) __builtin_popcount(x)
  21.  
  22. int dp[30][30];
  23. int vis[26];
  24. int32_t main(){
  25. string s;cin>>s;
  26. int n=s.size();
  27. vi v(30,0);
  28. for(int i=0;i<n;i++){
  29. v[s[i]-'a']+=1;
  30. vis[s[i]-'a']=1;
  31. for(int j=0;j<26;j++){
  32. if(j==s[i]-'a')continue;
  33. if(vis[j]){
  34. dp[s[i]-'a'][j]+=v[s[i]-'a'];
  35. }
  36.  
  37. }
  38. }
  39. int sss=0;
  40. for(int i=0;i<26;i++){
  41. for(int j=0;j<26;j++){
  42. cout<<dp[i][j]<<" ";
  43. sss=max(sss,dp[i][j]);
  44. }cout<<endl;
  45. }
  46. cout<<sss<<endl;
  47. }
Success #stdin #stdout 0s 4352KB
stdin
aabbbbaaccc
stdout
0 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0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