/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 10ms 540.0 KiB
#3 Accepted 13ms 844.0 KiB
#4 Accepted 10ms 672.0 KiB
#5 Accepted 10ms 796.0 KiB
#6 Accepted 10ms 676.0 KiB
#7 Accepted 14ms 748.0 KiB
#8 Accepted 10ms 540.0 KiB
#9 Accepted 10ms 664.0 KiB
#10 Accepted 10ms 852.0 KiB
#11 Accepted 13ms 540.0 KiB
#12 Accepted 10ms 848.0 KiB
#13 Accepted 10ms 540.0 KiB
#14 Accepted 10ms 540.0 KiB
#15 Accepted 10ms 540.0 KiB
#16 Accepted 10ms 668.0 KiB
#17 Accepted 10ms 540.0 KiB
#18 Accepted 10ms 592.0 KiB
#19 Accepted 10ms 540.0 KiB
#20 Accepted 10ms 660.0 KiB
#21 Accepted 10ms 864.0 KiB
#22 Accepted 12ms 1.387 MiB
#23 Accepted 10ms 1.406 MiB
#24 Accepted 12ms 1.52 MiB
#25 Accepted 10ms 1.52 MiB
#26 Accepted 13ms 1.562 MiB
#27 Accepted 12ms 1.598 MiB
#28 Accepted 10ms 1.277 MiB
#29 Accepted 11ms 1.594 MiB
#30 Accepted 11ms 1.527 MiB
#31 Accepted 11ms 1.52 MiB
#32 Accepted 10ms 540.0 KiB
#33 Accepted 10ms 588.0 KiB
#34 Accepted 11ms 796.0 KiB
#35 Accepted 10ms 772.0 KiB
#36 Accepted 10ms 540.0 KiB
#37 Accepted 28ms 1.02 MiB
#38 Accepted 28ms 924.0 KiB
#39 Accepted 27ms 796.0 KiB
#40 Accepted 27ms 796.0 KiB
#41 Accepted 29ms 796.0 KiB
#42 Accepted 10ms 2.305 MiB
#43 Accepted 10ms 2.316 MiB
#44 Accepted 10ms 2.277 MiB
#45 Accepted 10ms 2.32 MiB
#46 Accepted 10ms 2.527 MiB
#47 Accepted 12ms 2.328 MiB
#48 Accepted 10ms 2.324 MiB
#49 Accepted 12ms 2.277 MiB
#50 Accepted 15ms 2.289 MiB

Code

//! In The Name Of Allah

/*********************************************************************\
*!          |       *        |       | ___  | @                       |
*!          |      * *       |       |  |   |  @                      |
*!          |     *   *      |       |  |   |   @                     |
*!          |    *******     |-------|  |   |    @                    |
*! |*       |   *       *    |       |  |   |   @                     |
*! |        |  *         *   |       |  |   |  @                      |
*! |________| *           *  |       | ___  | @                       |
*!                                                                    |
*!  codeforces = __Jahid__Noob__                                      |
*!  mail =  [email protected]                                       |
*!  IIT,Jahangirnagar University(41)                                  |
*!                                                                    |
**********************************************************************/

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'
#define pb push_back
#define pob pop_back
#define make M
#define F first
#define S second
#define all(s) (s).begin(), (s).end()
#define rall(s) s.rbegin(), s.rend()
#define sz(x) (int)x.size()
#define mem(a, b) memset(a, b, sizeof(a))
#define log2(x) 31 - __builtin_clz(x)
#define getbit(n, i) (((n) & (1LL << (i))) != 0)
#define msb(x) 31 - __builtin_clz(x)
#define TxtIO                         \
    freopen("sample.in", "r", stdin); \
    freopen("sample.out", "w", stdout);
#define Fokinnir_moto_kaj_koris_na \
    ios_base::sync_with_stdio(0);  \
    cin.tie(0);                    \
    cout.tie(0);
#define py cout << "YES" << endl
#define pn cout << "NO" << endl
#define PI acos(-1)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef tuple<int,int,int> tu;

 #define DEBUG
#define TEM template <class... T>
TEM istream& operator>>(istream& in, pair<T...>& p) { return in >> p.first >> p.second; }
TEM ostream& operator<<(ostream& out, const pair<T...>& p) { return out << '(' << p.first << ", " << p.second << ')'; }
#define def_in(cont) TEM istream& operator>>(istream& in, cont<T...>& A) { for (auto& a : A) in >> a; return in; }
#define def_out(cont) TEM ostream& operator<<(ostream& out, const cont<T...>& A) { int i = 0; auto it = A.begin(); while (it != A.end()) out << &" "[!i++] << *it++; return out; }
def_in(vector) def_in(deque) def_out(vector) def_out(deque) def_out(set) def_out(map) def_out(multiset)

TEM void c_in(T&... args) { ((cin >> args), ...); }
TEM void c_out(const T&... args) { int i = 0; ((cout << &" "[!i++] << args), ...) << '\n'; }
void c_out(bool b) { c_out(b ? "YES" : "NO"); }

#ifdef DEBUG
TEM void c_err(const T&... args) { int i = 0; ((cerr << &" "[!i++] << args), ...) << '\n'; }
#else
#define c_err(...)
#endif
#define dbg(args...) c_err(#args, '=', args)

ll gcd(ll a, ll b) { return __gcd(a, b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

/*
int p = 237,mod = 1000000289;
auto Goriber_function = [&] (int m) -> int{

};
*/
const ll oo = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 123;

void Goriber_solve()
{
    int n,m;
    cin >> n >> m;
    string s[n];
    for(int i = 0; i < n; i++)cin >> s[i];
    int ans = 0;
    int ar[n+1][m+1] = {0};
    for(int i = 0; i < m; i++){
        vi cnt(26,0),suf(26,0),la(n+1,0);
        int mx = 0;
        for(int j = n - 1; j >= 0; j--){
            cnt[s[j][i] - 'a']++;
            int pp = 0;
            for(int x = 0; x < 26; x++){
                pp = max(pp,cnt[x]);
            }
            la[j] = pp;
        }
        for(int j = 0; j < n; j++){
            suf[s[j][i] - 'a']++;
            int pp = 0;
            for(int x = 0; x < 26; x++){
                pp = max(pp,suf[x]);
            }
            int ase = pp + la[j+1];
            ar[j][i] = ase;
        }
    }
    for(int i = 0; i < n; i++){
        int mx = 0;
        for(int j = 0; j < m; j++){
            mx += ar[i][j];
        }
        ans = max(ans,mx);
    }
    cout << ans << endl;
}
signed main()
{

    Fokinnir_moto_kaj_koris_na
    int _ = 1,tc = 0;
    cin >> _;
    while (_--)
    {
        //cout<<"Case "<<++tc<<": ";
        Goriber_solve();
    }
}

Information

Submit By
Type
Submission
Problem
P1164 Simple character matching game
Contest
Brain Booster #8
Language
C++17 (G++ 13.2.0)
Submit At
2025-02-17 15:20:42
Judged At
2025-02-17 15:20:42
Judged By
Score
100
Total Time
29ms
Peak Memory
2.527 MiB