593A - 2Char - CodeForces Solution


brute force implementation *1200

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
using namespace std;
//  Savani004  //
#define ll long long int
#define float long double
#define fon for(ll i=0;i<n;i++)
#define f(i,x,n) for(ll i=x;i<n;i++)
#define rf(i, x, n) for (ll i = x; i >= n; i--)
#define fr(i,m) for(auto &i:m)
#define vl vector<ll>
#define mll map<ll,ll>
#define mcl map<char,ll>
#define vpl vector<pair<ll,ll>>
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rtn return
#define fi first
#define se second
#define M 1000000007
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#ifndef ONLINE_JUDGE
#include "debug.hpp"
#else
#define debug(...) 42
#endif
ll gcd(ll a,ll b){if(b==0){return a;}return gcd(b,a%b);}
ll lcm(ll a,ll b){return (a/gcd(a,b))*b;}
const ll N = 1e6;vector<bool> is_prime(N, 1);vl prime;void PRIME(){for (ll i = 2; i <= N; i++){if (is_prime[i]){prime.pb(i);for (ll j = i * 2; j <= N; j += i)is_prime[j] = 0;}}}
ll powerM(ll x,ll y){ll dd=1;x=x%M;if(x==0){return 0;} while(y>0){if(y&1)dd=(dd*x)%M;y=y>>1;x=(x*x)%M;}return dd;}
ll powerr(ll n,ll a){ ll res=1; while(a){ if(a%2){ res*=n,a--;}else{n*=n,a/=2;}} return res;}
ll fastprime(ll a){if(a==2){return 1;}if (a%2==0 || a<=1) return 0;int bo = (int)floor(sqrt(a)); for(int i = 3; i <= bo; i += 2) if(a % i == 0) return 0; return 1;}

ll n,m,i,j,p,q,r,a,b,x,y,sum,cnt,ans,res,k,d,dd,ddd,mx,mn,flg,low,mid,high,tmp,temp;

void solve(){
    cin>>n;
    vector<string> v(n);
    fon{
      cin>>v[i];
    }
    ans=0;
    for(char i='a';i<='z';i++){
      for(char j='a';j<='z';j++){
        cnt=0;
        f(k,0,n){
          flg=0;
          f(l,0,v[k].length()){
            if(v[k][l]!=i && v[k][l]!=j){flg=1;break;}
          }
          if(flg==0)cnt+=v[k].length();
        }
        ans=max(ans,cnt);
      }
    }
    cout<<ans<<endl;
}

int main()
{
  fast;
  //int t;cin>>t;while(t--)
    solve();
  return 0;
}
	 	  		    		   			  			  	 	 	


Comments

Submit
0 Comments
More Questions

742A - Arpa’s hard exam and Mehrdad’s naive cheat
1492A - Three swimmers
1360E - Polygon
1517D - Explorer Space
1230B - Ania and Minimizing
1201A - Important Exam
676A - Nicholas and Permutation
431A - Black Square
474B - Worms
987B - High School Become Human
1223A - CME
1658B - Marin and Anti-coprime Permutation
14B - Young Photographer
143A - Help Vasilisa the Wise 2
320A - Magic Numbers
1658A - Marin and Photoshoot
514A - Chewbaсca and Number
382A - Ksenia and Pan Scales
734B - Anton and Digits
1080A - Petya and Origami
1642D - Repetitions Decoding
1440A - Buy the String
1658F - Juju and Binary String
478A - Initial Bet
981A - Antipalindrome
365A - Good Number
1204B - Mislove Has Lost an Array
1409D - Decrease the Sum of Digits
1476E - Pattern Matching
1107A - Digits Sequence Dividing