QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#197873#3513. Assessing Genomesbeshoyhany#AC ✓12ms3708kbC++205.0kb2023-10-02 21:08:222023-10-02 21:08:22

Judging History

你现在查看的是最新测评结果

  • [2023-10-02 21:08:22]
  • 评测
  • 测评结果:AC
  • 用时:12ms
  • 内存:3708kb
  • [2023-10-02 21:08:22]
  • 提交

answer

#include<bits/stdc++.h>

#define ll long long
#define pp push_back
#define endl '\n'
#define all(x) x.begin(),x.end()
#define ld long double
#define PI acos(-1)
#define sin(a) sin((a)*PI/180)
#define cos(a) cos((a)*PI/180)
#define ones(x) __builtin_popcountll(x)
//#define int ll

using namespace std;

void Drakon() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef Clion
    freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif
}

unsigned long long inf = 1e10;
const double EPS = 1e-6;
const int MOD = 1000000007, N = 200005, LOG = 25;

ll gcd(ll x, ll y) {
    return y ? gcd(y, x % y) : x;
}

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

ll mul(const ll &a, const ll &b) {
    return (a % MOD + MOD) * (b % MOD + MOD) % MOD;
}

ll add(const ll &a, const ll &b) {
    return (a + b + 2 * MOD) % MOD;
}

ll pw(ll x, ll y) {
    ll ret = 1;
    while (y > 0) {
        if (y % 2 == 0) {
            x = mul(x, x);
            y = y / 2;
        } else {
            ret = mul(ret, x);
            y = y - 1;
        }
    }
    return ret;
}

struct Edge {
    int to;
    int cost;
    int cap, flow, backEdge;
};

struct MCMF
{

    const int inf = 1000000010;
    int n;
    vector<vector<Edge>> g;

    MCMF(int _n) {
        n = _n + 1;
        g.resize(n);
    }

    void addEdge(int u, int v, int cap, int cost) {
        Edge e1 = {v, cost, cap, 0, (int) g[v].size()};
        Edge e2 = {u, -cost, 0, 0, (int) g[u].size()};
        g[u].push_back(e1);
        g[v].push_back(e2);
    }

    pair<int, int> minCostMaxFlow(int s, int t) {
        int flow = 0;
        int cost = 0;
        vector<int> state(n), from(n), from_edge(n);
        vector<int> d(n);
        deque<int> q;
        while (true) {
            for (int i = 0; i < n; i++)
                state[i] = 2, d[i] = inf, from[i] = -1;
            state[s] = 1;
            q.clear();
            q.push_back(s);
            d[s] = 0;
            while (!q.empty()) {
                int v = q.front();
                q.pop_front();
                state[v] = 0;
                for (int i = 0; i < (int) g[v].size(); i++) {
                    Edge e = g[v][i];
                    if (e.flow >= e.cap || (d[e.to] <= d[v] + e.cost))
                        continue;
                    int to = e.to;
                    d[to] = d[v] + e.cost;
                    from[to] = v;
                    from_edge[to] = i;
                    if (state[to] == 1) continue;
                    if (!state[to] || (!q.empty() && d[q.front()] > d[to]))
                        q.push_front(to);
                    else q.push_back(to);
                    state[to] = 1;
                }
            }
            if (d[t] == inf) break;
            int it = t, addflow = inf;
            while (it != s) {
                addflow = min(addflow,
                              g[from[it]][from_edge[it]].cap
                              - g[from[it]][from_edge[it]].flow);
                it = from[it];
            }
            it = t;
            while (it != s) {
                g[from[it]][from_edge[it]].flow += addflow;
                g[it][g[from[it]][from_edge[it]].backEdge].flow -= addflow;
                cost += g[from[it]][from_edge[it]].cost * addflow;
                it = from[it];
            }
            flow += addflow;
        }
        return {cost, flow};
    }
};

void solve() {
    int n;
    cin >> n;
    vector<int>a(n), b(n);
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < s.size(); ++j) {
            bool flag = true;
            for (int k = 0; k < s.size(); ++k) {
                if(s[k % (j + 1)] != s[k]){
                    flag = false;
                    break;
                }
            }
            if(flag && s.size() % (j + 1) == 0){
                a[i] = j + 1;
                break;
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < s.size(); ++j) {
            bool flag = true;
            for (int k = 0; k < s.size(); ++k) {
                if(s[k % (j + 1)] != s[k]){
                    flag = false;
                    break;
                }
            }
            if(flag && s.size() % (j + 1) == 0){
                b[i] = j + 1;
                break;
            }
        }
    }

    int s = 2 * n, e = 2 * n + 1;
    MCMF flw(e + 5);

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            flw.addEdge(i, j + n, 1, (a[i] - b[j]) * (a[i] - b[j]));
        }
    }
    for (int i = 0; i < n; ++i) {
        flw.addEdge(s, i, 1, 0);
        flw.addEdge(i + n, e, 1, 0);
    }

    cout << flw.minCostMaxFlow(s, e).first;
}

signed main() {
    Drakon();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3444kb

input:

2
TTTTTT
TATG
TATATA
AAAGAAAG

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3512kb

input:

3
abcdef
aaa
bab
AbAb
xyzxyz
X

output:

10

result:

ok single line: '10'

Test #3:

score: 0
Accepted
time: 12ms
memory: 3636kb

input:

50
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

50
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3704kb

input:

50
abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab
bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc...

output:

0

result:

ok single line: '0'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3428kb

input:

1
aba
x

output:

4

result:

ok single line: '4'

Test #7:

score: 0
Accepted
time: 3ms
memory: 3604kb

input:

50
hbvhlbwfpdwmwxijsbbfjbcakhbvhlbwfpdwmwxijsbbfjbcakhbvhlbwfpdwmwxijsbbfjbcakhbvhlbwfpdwmwxijsbbfjbcakhbvhlbwfpdwmwxijsbbfjbcakhbvhlbwfpdwmwxijsbbfjbcakhbvhlbwfpdwmwxijsbbfjbcakhbvhlbwfpdwmwxijsbbfjbcakhbvhlbwfpdwmwxijsbbfjbcakhbvhlbwfpdwmwxijsbbfjbcak
xkhktuzqejivxjyqdgxwgxfptugwdjsxmsfecelafxgtrv...

output:

17425

result:

ok single line: '17425'

Test #8:

score: 0
Accepted
time: 3ms
memory: 3704kb

input:

50
jyownbbxucekrpmqvygmvnhvcboaysqqqygfblgorlngnoxidywmvmzdlyekraxsoaupzzhnroadarirkjlkleahfbvdzyerfahcwwxyuudvprecjrtqpkpouvbimtydmkwkgoesntizfaqxunkrrkpopbvhbzrlkpqafgdqiprvtjwwcjgbcjesvauiphdpxezwofmuuctlqknbnwbggawjnroesrqnjxrfdckrbhxgwtcjvkdxcedaai
kdutukdutukdutukdutukdutukdutukdutukdutukdutuk...

output:

72150

result:

ok single line: '72150'

Test #9:

score: 0
Accepted
time: 4ms
memory: 3648kb

input:

50
wajcsgssmwpbzljnvqjnbpuzfkqiviftgmsnnyaodckukayihynxsshefxtchgjwsmhjfuqsqpjcaacfphfxnjhlnmywtbuadvynxnqiaxyxxodgqjigepqxhzqhvvshyoozvvxipftmcufbzqqeyjbgpqncqfefsrqdclpypbkqnnqungmdmhxsgxdeqdcxorvmtypsljamiposypjfkbdnypnjsaazcmpttudyojekendpxqnwnhnkto
aQzTNvYddoPOBqxGlWWAxmovmaQzTNvYddoPOBqxGlWWAx...

output:

50025

result:

ok single line: '50025'

Test #10:

score: 0
Accepted
time: 4ms
memory: 3604kb

input:

50
ZNVWEBXZTBFFCUMYVLAEVAHCOLSVERPRHDQLECQLIXKTDHNJNCNUBMAXVXFAELLXOXICMCGZESVBVZHFVIPKGGGXHAOJTDXTCPYZKSDWBASFQFMMMXTVNHSRKTHLRDVCUSSTPQRHRTAVRBIPHGWKDJWSKAEEGHWFTPDHTATFLXSAXDTDCCWSYSTQHIBWNQRPZWUMGXCEVHYSQKKPFSQLBAZUZFOQFYEDHSZDXJKOPSAONWOKHLDHTDOGGX
ornijzqqwdkqwnpokecffotwwilggslmxfhfjtgnwblimm...

output:

175875

result:

ok single line: '175875'

Test #11:

score: 0
Accepted
time: 3ms
memory: 3700kb

input:

50
egftescorktaaqihwjavbrwguynrluxfhsuiabezawrfsmammhapeebzvvmooxusvkzrqfmvstrgkuojxjiszlahgkakjyreaymhhmtakwengrqhekvfczfyvwmrulmkwkzfmtewjrvuwjjtmjsutgyofrtkgwyvjbnrcuxozhfgddgyozsafswmlihhsjmfxvyjwbfjmjrevjpjrqekysrdffryqdwxljjtivgymroobmqwujhbxwoasc
pufvwgqtizcvpzcagbvhhvkcezrhgxoknpolhghmkoimmm...

output:

76075

result:

ok single line: '76075'

Test #12:

score: 0
Accepted
time: 4ms
memory: 3648kb

input:

50
DIWYKNELNHZDZMXMSNXGUROBAPAKEPWBKACAYXGBTVQJSZYBHBMXLIZLSDHSZBAYXXNDUYQOGKZWOWLVENJXYNIHKQWFKZIHWLVWMADESAIHXLHKIJFKOFVBQXWCYQIYSBGKCVOJWVIMXAHFEHEEETIQDVRSKMQJIWKXJTNDPRGPOSYPLOTFIKRNWCJPNEREGMQWJCLPJPYAEUCPXESALXMWBYCPLNPHCCPIDPGWSZOMFGTYRJOYPBDCXG
NQTLOQRJZGSEBFKQROFDZDKVQNQTLOQRJZGSEBFKQROFDZ...

output:

142700

result:

ok single line: '142700'

Test #13:

score: 0
Accepted
time: 3ms
memory: 3708kb

input:

50
AIJKDSFASGTOXKJPZANETQWNTAIJKDSFASGTOXKJPZANETQWNTAIJKDSFASGTOXKJPZANETQWNTAIJKDSFASGTOXKJPZANETQWNTAIJKDSFASGTOXKJPZANETQWNTAIJKDSFASGTOXKJPZANETQWNTAIJKDSFASGTOXKJPZANETQWNTAIJKDSFASGTOXKJPZANETQWNTAIJKDSFASGTOXKJPZANETQWNTAIJKDSFASGTOXKJPZANETQWNT
rfzpprfzpprfzpprfzpprfzpprfzpprfzpprfzpprfzppr...

output:

171100

result:

ok single line: '171100'

Test #14:

score: 0
Accepted
time: 3ms
memory: 3636kb

input:

50
MAUDPQDGLAPKTHPTXLMKTCQRJXFANZLYSYCPWVHEFORTNEWFSTVJDAPDIEOCUFCDLIJZHYPAPGFUJAGDECXBJNWCDPLAXLEHEXNHHSISXLXHWUMLFETSTLRSUNCCNWLAOTDKBITFMUMKMDRJAJJRDSFTNJKIBNRYYWEEMZELJRACBRYPKDFKQAXLBZCXSDWYISZIYBPYJTEAFGVJZYEGKPDWZOGSIXJHIHWITOQMFYJGGDQZRXSPRXQKUK
YHVNEKOHMRYMNFHNKSLQKCMWCYHVNEKOHMRYMNFHNKSLQK...

output:

241850

result:

ok single line: '241850'

Test #15:

score: 0
Accepted
time: 3ms
memory: 3580kb

input:

50
sDGRVCYifmZAqmOYpnWTLqfnRizJIMwSQchxDpObNtcmVSRKJEiEeZudZboihNcjFdWaICUzDzTmvaKKEBwDuYOWzfiFRikQZMXSWduEqOkLLRZZhWhrjGShJWqGxizpwjTAiexTOiaOzcwJwNFzUlnhzESfTyiRagvkinDZsvCZByLjkNkCpCkhqiKNFBRoHxxQSCExZoCInHXZrHBHmArdILZrFRVyWKbRYgLvdfGhLVcKtNiTCiDhUk
yelwoozwcgtawcdhxipacbcutbtmkjptrzbemgfzrysrqm...

output:

95200

result:

ok single line: '95200'

Test #16:

score: 0
Accepted
time: 3ms
memory: 3668kb

input:

50
ztFGcSRTgkxsJqEGMVrPOILGVfvZUlYmSMCaCyiHTbTfwERjApztFGcSRTgkxsJqEGMVrPOILGVfvZUlYmSMCaCyiHTbTfwERjApztFGcSRTgkxsJqEGMVrPOILGVfvZUlYmSMCaCyiHTbTfwERjApztFGcSRTgkxsJqEGMVrPOILGVfvZUlYmSMCaCyiHTbTfwERjApztFGcSRTgkxsJqEGMVrPOILGVfvZUlYmSMCaCyiHTbTfwERjAp
ennxgtMGiGyxBequmMabNsOYKpiKkhVIsikhsllQlYjzKo...

output:

33350

result:

ok single line: '33350'

Test #17:

score: 0
Accepted
time: 1ms
memory: 3472kb

input:

21
EFAHMEFAHMEFAHMEFAHMEFAHMEFAHMEFAHMEFAHMEFAHMEFAHM
uifuujeenafixjqlmkbgoezciuifuujeenafixjqlmkbgoezci
AbbXNCiVLKPTEKvylrjiZxrfvjKCsfGgCNNstAWfhRIFWETkyQ
QSJYVQSJYVQSJYVQSJYVQSJYVQSJYVQSJYVQSJYVQSJYVQSJYV
GWKJFJBWBRSYBTAAVSEKJZJEDBZGIAADRDBKUMVIJHBPOLOBFS
VqHMNAFkcgVSVhCvpGEgTjxpiUBBXCNXtnvXKvKgbB...

output:

2825

result:

ok single line: '2825'

Test #18:

score: 0
Accepted
time: 1ms
memory: 3480kb

input:

21
JXXOGJXXOGJXXOGJXXOGJXXOGJXXOGJXXOGJXXOGJXXOGJXXOG
mgpsgjkqxuzhpwazpvotwnqylwunakrrkgbochohwzwlhrebzk
UBLVRUBLVRUBLVRUBLVRUBLVRUBLVRUBLVRUBLVRUBLVRUBLVR
DVITHDVITHDVITHDVITHDVITHDVITHDVITHDVITHDVITHDVITH
opghkabkuepopprkmjausdrquoqlmrsguzcpfnavylporfhbwo
JXWQMGWKZSNBOYCIVXFEDXFZUKTQLBXCMKTKHTCBJB...

output:

1825

result:

ok single line: '1825'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

26
UpNSLUpNSLUpNSLUpNSLUpNSLUpNSLUpNSLUpNSLUpNSLUpNSL
KkzaskQqpfKkzaskQqpfKkzaskQqpfKkzaskQqpfKkzaskQqpf
JHYHKWYVYAJHYHKWYVYAJHYHKWYVYAJHYHKWYVYAJHYHKWYVYA
ewjohlvjvlyrojtzvqomydqzoewjohlvjvlyrojtzvqomydqzo
BDHOJBDHOJBDHOJBDHOJBDHOJBDHOJBDHOJBDHOJBDHOJBDHOJ
wijkheipmeoecqazlyphryisbggzvchrguoyasbkae...

output:

1775

result:

ok single line: '1775'

Test #20:

score: 0
Accepted
time: 1ms
memory: 3568kb

input:

27
ZVRLPZVRLPZVRLPZVRLPZVRLPZVRLPZVRLPZVRLPZVRLPZVRLP
YbFxmGnjseibvMFCksGYgVzHiYbFxmGnjseibvMFCksGYgVzHi
cCpdJcCpdJcCpdJcCpdJcCpdJcCpdJcCpdJcCpdJcCpdJcCpdJ
lmmnklejxbiwtfxqzidtwwyqxsnzewkkqyoaqlxfxiavyrjxxo
LIuNFmWnQbOaNoAzJURsdkGTkUeWubapxfdIYnAvySyUQIijIo
UQSXADLZHXUQSXADLZHXUQSXADLZHXUQSXADLZHXUQ...

output:

3950

result:

ok single line: '3950'

Test #21:

score: 0
Accepted
time: 1ms
memory: 3560kb

input:

27
xjbfcuzfjgxjbfcuzfjgxjbfcuzfjgxjbfcuzfjgxjbfcuzfjg
EGQSHEGQSHEGQSHEGQSHEGQSHEGQSHEGQSHEGQSHEGQSHEGQSH
fykmustwzvssdvudaknjtypsqrofxdlwzgqrsbxerirwyhlbxo
IXSJNIETHETXAVEPCOSRUMZFXWCBLFOILVAASPNUZVBNVCISQN
yxfehiqgpgyxfehiqgpgyxfehiqgpgyxfehiqgpgyxfehiqgpg
EkSfRVjjDcFnJNlAkAzGPsueZkkeDCewOXvYlICrKi...

output:

11100

result:

ok single line: '11100'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

20
IKGCJPKNNAJLMDWTPIXVFIZRFIKGCJPKNNAJLMDWTPIXVFIZRF
swuuccaljyswuuccaljyswuuccaljyswuuccaljyswuuccaljy
pjxObFjPvtjMywWOddJXYOTEidcJfeUmqsuzsUiUMcQljTrMPl
IOCHWhTlbErDAFymEJNfBLUKJPHpKxctjAXtDNCtifSgwkSBYh
EfBBxdoVScEfBBxdoVScEfBBxdoVScEfBBxdoVScEfBBxdoVSc
oGAyqeIoTOIAnTDuXyVKNvxqvjdtNnJXEoZXWNrbtX...

output:

1325

result:

ok single line: '1325'

Test #23:

score: 0
Accepted
time: 1ms
memory: 3596kb

input:

26
PMCWLPMCWLPMCWLPMCWLPMCWLPMCWLPMCWLPMCWLPMCWLPMCWL
AYZKROKQKHAYZKROKQKHAYZKROKQKHAYZKROKQKHAYZKROKQKH
HOJUVSLAKUIMONKLUAVRSEKNWRBHDXAUVBIVMPYFBJGNHNSZIU
whjazwhjazwhjazwhjazwhjazwhjazwhjazwhjazwhjazwhjaz
ynkzfgwublufenpllzbjqcfwtkpqdmlcthxjmzldfderxaffcg
XNQBTXNQBTXNQBTXNQBTXNQBTXNQBTXNQBTXNQBTXN...

output:

2375

result:

ok single line: '2375'

Test #24:

score: 0
Accepted
time: 1ms
memory: 3600kb

input:

29
qquytemvannvipiuejkkxaisdqquytemvannvipiuejkkxaisd
isjrhvdeudkmadpbpcxiatopiushonpczhrpkfspunfheyvrrj
RSCIDVTVOFDIYQJRYFGNNWMPLRSCIDVTVOFDIYQJRYFGNNWMPL
avxbuavxbuavxbuavxbuavxbuavxbuavxbuavxbuavxbuavxbu
hotichahvhhotichahvhhotichahvhhotichahvhhotichahvh
AUQEJOABAIDSRJJAPWTHXWKWEAGMMHTGVUQBAQAGTD...

output:

1325

result:

ok single line: '1325'

Test #25:

score: 0
Accepted
time: 1ms
memory: 3476kb

input:

25
jmrabxwkpcjmrabxwkpcjmrabxwkpcjmrabxwkpcjmrabxwkpc
oqevowwniwjeksywxwbvjqffzoqevowwniwjeksywxwbvjqffz
MRUDdMRUDdMRUDdMRUDdMRUDdMRUDdMRUDdMRUDdMRUDdMRUDd
SGZMCKNHCFTHGLXDUPNLHJJNBSGZMCKNHCFTHGLXDUPNLHJJNB
XAALJXAALJXAALJXAALJXAALJXAALJXAALJXAALJXAALJXAALJ
hkrfnhkrfnhkrfnhkrfnhkrfnhkrfnhkrfnhkrfnhk...

output:

2650

result:

ok single line: '2650'

Test #26:

score: 0
Accepted
time: 0ms
memory: 3472kb

input:

23
qawwoyukanccimgcogzcbgdalqawwoyukanccimgcogzcbgdal
GCNEWEODIGGCNEWEODIGGCNEWEODIGGCNEWEODIGGCNEWEODIG
BDFMXBDFMXBDFMXBDFMXBDFMXBDFMXBDFMXBDFMXBDFMXBDFMX
emltsfveboemltsfveboemltsfveboemltsfveboemltsfvebo
efxpthxxudnjedltuanbnsbdjzlsbifpyjmfrayjlpseqessxv
UGJILJGYEGUGJILJGYEGUGJILJGYEGUGJILJGYEGUG...

output:

1525

result:

ok single line: '1525'

Test #27:

score: 0
Accepted
time: 1ms
memory: 3436kb

input:

8
ACQACQ
TUOQCG
SMSBSMSB
CKGHCKGH
nhfunhfu
TXBPOw
eapedeaped
svtvcs
mwlmwl
nHDyGnHDyG
plmblzxq
TCTTCT
nmptti
BNVBNV
HOWmvnEd
XVQdXVQd

output:

10

result:

ok single line: '10'

Test #28:

score: 0
Accepted
time: 1ms
memory: 3488kb

input:

7
ECXXIECXXI
wdmfyvkgda
nYqYlyXzfs
DMTOCX
yrmqyrmq
gtwqnggi
UIINEUIINE
SnvtmSnvtm
EFNVADIS
sBhHGsBhHG
TDDPEUOB
dnOAdnOA
LwbnuCzM
WSXXWSXX

output:

10

result:

ok single line: '10'

Test #29:

score: 0
Accepted
time: 0ms
memory: 3448kb

input:

7
HMQHMQ
JEBPURLC
VVYFDL
MTXMTX
qdlxihgn
MyZbMMyZbM
kvikvi
EXSEXS
fEiKhWasQy
sTirQsTirQ
USEUSE
eatleatl
zxnfzxnf
cvwlcvwl

output:

19

result:

ok single line: '19'

Test #30:

score: 0
Accepted
time: 0ms
memory: 3480kb

input:

7
FPYNNS
padjgpadjg
ngSooSVAUi
ZOBLDV
WpHWpH
mkwymkwy
wnpdkxha
ipCreipCre
TSbKJTSbKJ
DBFKDBFK
oftoxoftox
AXPNAXPN
akudakud
arfuarfu

output:

41

result:

ok single line: '41'

Test #31:

score: 0
Accepted
time: 0ms
memory: 3440kb

input:

9
qcXRld
JBaDiV
CWGLCWGL
eyWeyW
psvepsve
UCndzUCndz
VcBeVcBe
LCiLCi
FnBGFnBG
wlymzt
FWPNQFWPNQ
NKEodR
ZVZMKZVZMK
iihyuiihyu
jUSMijUSMi
ZMTSFPFQ
HDOHDO
ttliyttliy

output:

13

result:

ok single line: '13'