QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#317453#8176. Next TTPC 3hos_lyricAC ✓104ms23472kbC++143.1kb2024-01-29 00:55:422024-01-29 00:55:42

Judging History

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

  • [2024-01-29 00:55:42]
  • 评测
  • 测评结果:AC
  • 用时:104ms
  • 内存:23472kb
  • [2024-01-29 00:55:42]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")


char buf[1010];

vector<int> rd(char c) {
  scanf("%s", buf);
  const int M = strlen(buf);
  vector<int> A(M);
  for (int i = 0; i < M; ++i) {
    A[i] = (buf[i] == c) ? 1 : 0;
  }
  return A;
}

vector<int> mul(const vector<int> &A0, const vector<int> &A1) {
  const int M0 = A0.size();
  const int M1 = A1.size();
  const int M = M0 / __gcd(M0, M1) * M1;
  vector<int> B(M);
  for (int i = 0; i < M; ++i) {
    B[i] = A0[i % M0] & A1[i % M1];
  }
  return B;
}

int main() {
  int K;
  for (; ~scanf("%d", &K); ) {
    const auto A0 = rd('T');
    const auto A1 = rd('T');
    const auto A2 = rd('P');
    const auto A3 = rd('C');
    const auto B0 = mul(A0, A1);
    const auto B1 = mul(A2, A3);
    const int M0 = B0.size();
    const int M1 = B1.size();
    const int G = __gcd(M0, M1);
// cerr<<"M0 = "<<M0<<", M1 = "<<M1<<endl;
// cerr<<B0<<endl<<B1<<endl;
    
    vector<Int> nxt(M1, M1);
    for (int i = 0; i < M1; ++i) if (B1[i]) {
      nxt[i] = 0;
    }
    for (int r = 0; r < G; ++r) {
      int cnt = 0;
      for (int i = r; ; ) {
        int j = (i - M0) % M1;
        if (j < 0) j += M1;
        chmin(nxt[j], 1 + nxt[i]);
        if (r == j) if (++cnt == 2) break;
        i = j;
      }
    }
// cerr<<"nxt = "<<nxt<<endl;
    
    priority_queue<Int, vector<Int>, greater<Int>> que;
    for (int i = 0; i < M0; ++i) if (B0[i]) {
      const Int q = nxt[i % M1];
      if (q < M1) {
        que.push(i + M0 * q);
      }
    }
    
    Int ans = -1;
    for (int k = 0; k < K; ++k) {
      if (!que.size()) {
        ans = -2;
        break;
      }
      ans = que.top();
      que.pop();
      const Int q = nxt[(ans + M0) % M1];
// if(K<=100)cerr<<ans<<": "<<ans%M0<<" "<<ans%M1<<"; "<<q<<endl;
      if (q < M1) {
        que.push(ans + M0 + M0 * q);
      }
    }
    printf("%lld\n", ans + 1);
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3824kb

input:

3
TTPC
TLE
P
AC

output:

34

result:

ok "34"

Test #2:

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

input:

670055
TF
OITFKONTO
GFPPNPWTZP
CCZFB

output:

-1

result:

ok "-1"

Test #3:

score: 0
Accepted
time: 10ms
memory: 3824kb

input:

910359
TOKYO
TECH
PROGRAMMING
CONTEST

output:

1401951321

result:

ok "1401951321"

Test #4:

score: 0
Accepted
time: 28ms
memory: 4908kb

input:

518530
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...

output:

518530

result:

ok "518530"

Test #5:

score: 0
Accepted
time: 22ms
memory: 9096kb

input:

252288
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...

output:

252288

result:

ok "252288"

Test #6:

score: 0
Accepted
time: 6ms
memory: 6352kb

input:

1000000
TTJLTTPNTTQNTTBJTTHZTTJSTTRUTTVWTTJXTTMGTTZHTTRWTTNHTTDWTTMGTTIDTTSYTTPPTTGQTTXYTTOETTYMTTZATTAOTTJNTTHHTTYLTTJBTTLLTTNNTTCITTCBTTDOTTNGTTPZTTUETTFHTTODTTCETTKXTTGUTTZSTTECTTFSTTHOTTESTTNQTTHJTTDPTTFKTTCMTTNMTTGRTTYPTTKQTTYCTTUITTYCTTWWTTZDTTCPTTRSTTLFTTPKTTEXTTUPTTXWTTDATTVUTTLCTTEGTTOLTTRI...

output:

-1

result:

ok "-1"

Test #7:

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

input:

359869
TTXTTTYTTTITTTHTTTRTTTOTTTETTTKTTTZTTTYTTTBTTTUTTTBTTTJTTTDTTTYTTTJTTTKTTTYTTTLTTTATTTLTTTITTTHTTTUTTTMTTTDTTTITTTPTTTITTTCTTTCTTTRTTTZTTTVTTTETTTGTTTNTTTUTTTGTTTYTTTJTTTKTTTQTTTSTTTPTTTWTTTPTTTZTTTETTTJTTTVTTTGTTTUTTTBTTTCTTTCTTTXTTTWTTTETTTFTTTGTTTDTTTATTTCTTTITTTWTTTWTTTITTTSTTTRTTTYTTTETT...

output:

-1

result:

ok "-1"

Test #8:

score: 0
Accepted
time: 5ms
memory: 6236kb

input:

856943
QNTJMTFRTNDTXOTJRTNNTCXTZNTQMTSBTMRTDMTMOTEATOXTHWTOJTQQTLITKRTNSTNITSMTRVTLLTKBTSATYVTHXTEZTRXTPNTEQTQDTVZTMOTJVTESTRQTBBTAXTMNTUBTULTFPTXQTIBTCMTXXTMZTOWTYVTPVTDSTMWTZDTGQTVMTRFTKDTQITKSTCQTOPTSRTJWTFCTEFTCKTISTELTWGTHOTODTQHTLETRCTSHTJITQGTSUTFDTFZTFYTBJTKNTMHTHWTOZTARTZGTQETRITMSTXVTZATKJ...

output:

-1

result:

ok "-1"

Test #9:

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

input:

12
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...

output:

-1

result:

ok "-1"

Test #10:

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

input:

1000000
WTTTNTTTLTTTZTTTWTTTKTTTDTTTATTTNTTTMTTTZTTTHTTTVTTTVTTTITTTSTTTNTTTSTTTPTTTVTTTWTTTJTTTRTTTQTTTFTTTQTTTMTTTMTTTYTTTWTTTLTTTMTTTNTTTCTTTWTTTSTTTVTTTDTTTUTTTLTTTCTTTCTTTZTTTQTTTQTTTWTTTDTTTQTTTZTTTUTTTQTTTITTTYTTTATTTATTTGTTTITTTWTTTYTTTYTTTFTTTHTTTPTTTDTTTWTTTRTTTLTTTNTTTFTTTNTTTNTTTCTTTBTTT...

output:

-1

result:

ok "-1"

Test #11:

score: 0
Accepted
time: 6ms
memory: 6368kb

input:

506084
TPTGTATITNTJTPTBTZTDTRTVTJTVTSTFTWTNTATYTKTJTCTBTPTPTJTSTQTGTPTKTYTBTMTXTVTMTUTFTPTRTYTVTFTATCTLTITVTUTNTATCTJTYTOTOTMTKTBTMTMTKTQTWTBTHTITATUTYTNTETRTYTWTDTLTCTPTGTKTMTETGTCTWTMTNTKTMTATDTQTWTWTPTMTRTYTQTMTJTCTGTXTDTUTSTBTYTFTKTGTYTHTNTOTOTXTQTITITSTGTUTMTNTPTETJTDTJTRTBTKTXTCTSTRTZTSTWTUTJT...

output:

-1

result:

ok "-1"

Test #12:

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

input:

95378
JTTGTTYTTMTTFTTSTTUTTBTTNTTSTTVTTKTTYTTUTTITTFTTYTTKTTSTTSTTATTMTTQTTMTTLTTRTTWTTQTTLTTWTTPTTYTTGTTPTTNTTUTTRTTKTTWTTHTTVTTGTTMTTQTTUTTXTTCTTZTTUTTBTTDTTPTTJTTETTZTTNTTOTTKTTITTOTTGTTSTTQTTVTTZTTATTBTTATTOTTYTTZTTZTTZTTDTTPTTHTTMTTDTTLTTNTTNTTITTETTRTTYTTOTTWTTZTTGTTGTTRTTXTTKTTGTTVTTDTTSTTWTT...

output:

27097032

result:

ok "27097032"

Test #13:

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

input:

12
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...

output:

10636

result:

ok "10636"

Test #14:

score: 0
Accepted
time: 94ms
memory: 7524kb

input:

1000000
LTTTWTTTLTTTWTTTITTTQTTTWTTTKTTTSTTTGTTTLTTTHTTTXTTTFTTTYTTTPTTTBTTTFTTTYTTTBTTTZTTTYTTTHTTTNTTTVTTTKTTTMTTTITTTQTTTYTTTYTTTZTTTGTTTBTTTLTTTMTTTJTTTYTTTVTTTITTTYTTTRTTTCTTTHTTTRTTTUTTTWTTTQTTTITTTVTTTWTTTMTTTRTTTFTTTITTTYTTTETTTFTTTHTTTOTTTYTTTOTTTXTTTFTTTLTTTRTTTFTTTGTTTETTTBTTTVTTTETTTWTTT...

output:

907999396

result:

ok "907999396"

Test #15:

score: 0
Accepted
time: 64ms
memory: 7352kb

input:

713716
BTTCTTOTTZTTWTTOTTHTTITTITTITTWTTGTTFTTJTTMTTWTTRTTGTTFTTLTTJTTDTTWTTITTRTTMTTQTTDTTJTTWTTHTTKTTRTTQTTSTTETTKTTYTTRTTSTTGTTQTTYTTOTTCTTLTTSTTOTTETTUTTRTTETTLTTQTTYTTYTTITTUTTXTTZTTXTTJTTQTTWTTWTTMTTRTTATTNTTSTTJTTKTTGTTHTTVTTSTTRTTXTTMTTUTTNTTPTTQTTHTTJTTHTTETTQTTGTTGTTATTITTATTBTTQTTWTTHTTWT...

output:

563121569

result:

ok "563121569"

Test #16:

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

input:

11522
TXTTTHTTTVTTTOTTTFTTTZTTTKTTTZTTTJTTTDTTTPTTTRTTTHTTTOTTTXTTTCTTTWTTTNTTTDTTTSTTTWTTTCTTTHTTTXTTTFTTTSTTTOTTTHTTTCTTTWTTTUTTTXTTTSTTTZTTTXTTTLTTTETTTKTTTLTTTXTTTLTTTVTTTATTTLTTTHTTTDTTTITTTQTTTLTTTKTTTETTTATTTHTTTYTTTOTTTDTTTSTTTCTTTVTTTRTTTITTTITTTMTTTPTTTNTTTJTTTXTTTKTTTXTTTGTTTCTTTUTTTCTTTW...

output:

11152921

result:

ok "11152921"

Test #17:

score: 0
Accepted
time: 7ms
memory: 6864kb

input:

1000000
YHTTKJTTFNTTMITTNWTTOETTWJTTCFTTIRTTVJTTJMTTHOTTBITTLXTTRLTTVLTTOFTTMYTTOGTTAYTTVLTTCRTTENTTLKTTKETTXPTTSFTTCZTTGLTTJZTTGFTTOYTTSFTTLHTTNMTTANTTSGTTKKTTXETTABTTSBTTLLTTQOTTNDTTWATTERTTAUTTMWTTISTTASTTZJTTPXTTONTTVGTTEATTVBTTXGTTSITTPNTTLITTLQTTHVTTKOTTQGTTVLTTDQTTLHTTJETTWFTTDFTTIQTTIETTKHTT...

output:

-1

result:

ok "-1"

Test #18:

score: 0
Accepted
time: 6ms
memory: 6388kb

input:

1000000
TTXZTTYMTTVYTTASTTUPTTABTTLRTTEPTTQPTTMKTTCOTTPKTTPGTTSITTDRTTQSTTCPTTXWTTXBTTJDTTZNTTIPTTIOTTKJTTQITTEJTTJRTTAQTTIBTTAETTUOTTUETTDRTTNFTTPZTTYHTTMZTTQDTTCDTTVDTTHNTTXKTTUPTTFPTTYFTTIUTTUBTTJATTYFTTJWTTGUTTPXTTIPTTHSTTVATTHWTTWZTTMSTTJRTTYWTTSRTTUPTTDQTTKJTTIUTTVBTTNOTTBGTTINTTAMTTRNTTAXTTDW...

output:

-1

result:

ok "-1"

Test #19:

score: 0
Accepted
time: 6ms
memory: 6652kb

input:

367325
TSITTGUTTPJTTVDTTSSTTIJTTZATTKGTTPATTCKTTBWTTYKTTRUTTMOTTUQTTEDTTFLTTYOTTRITTYVTTGXTTVJTTWPTTVDTTAFTTSOTTJZTTDKTTBUTTSPTTFSTTHXTTKDTTVJTTCUTTALTTRHTTAJTTZHTTZDTTAOTTJVTTLKTTSXTTFITTDPTTGSTTXRTTEITTOQTTEPTTVCTTSITTJUTTPXTTZWTTPKTTUZTTLWTTYBTTFETTJYTTLDTTGSTTIITTKFTTKHTTUGTTVPTTXNTTFCTTLZTTYXTT...

output:

-1

result:

ok "-1"

Test #20:

score: 0
Accepted
time: 7ms
memory: 7084kb

input:

1000000
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...

output:

-1

result:

ok "-1"

Test #21:

score: 0
Accepted
time: 7ms
memory: 7288kb

input:

1000000
NTTNWTTJFTTLMTTSATTRWTTEXTTBETTPBTTEBTTXPTTUDTTWVTTWMTTWZTTCATTSBTTKBTTEKTTNHTTPBTTCATTVITTPJTTCYTTAPTTVLTTDHTTVQTTJUTTCFTTLXTTODTTFMTTXRTTRLTTNPTTVNTTYMTTOXTTDUTTVZTTSDTTMPTTYCTTLKTTFATTCETTUFTTGDTTKVTTGYTTVATTYZTTQRTTWQTTMGTTFXTTLDTTXRTTGFTTPLTTQQTTOVTTEOTTJSTTXSTTQKTTRVTTWZTTKXTTRBTTRRTTM...

output:

-1

result:

ok "-1"

Test #22:

score: 0
Accepted
time: 104ms
memory: 6948kb

input:

1000000
DTTTATTTBTTTUTTTUTTTNTTTDTTTITTTATTTRTTTFTTTJTTTZTTTDTTTRTTTETTTWTTTCTTTHTTTFTTTBTTTJTTTUTTTWTTTJTTTCTTTETTTYTTTHTTTWTTTETTTWTTTCTTTZTTTWTTTYTTTKTTTRTTTLTTTVTTTETTTOTTTDTTTPTTTLTTTMTTTWTTTCTTTXTTTDTTTPTTTVTTTFTTTATTTKTTTWTTTOTTTUTTTPTTTZTTTMTTTETTTWTTTRTTTPTTTRTTTHTTTFTTTYTTTRTTTKTTTJTTTETTT...

output:

452272320

result:

ok "452272320"

Test #23:

score: 0
Accepted
time: 38ms
memory: 7296kb

input:

1000000
CTITITNTHTTTBTZTNTMTFTCTZTJTRTBTUTPTWTWTNTUTMTUTETITITATKTMTRTPTVTXTPTHTNTGTSTMTUTWTKTWTITBTCTHTFTWTDTHTWTBTSTNTNTCTGTVTVTVTMTVTITWTJTRTYTETMTKTFTGTPTXTHTGTXTVTPTHTKTSTMTUTMTLTCTDTHTGTUTVTPTYTQTOTBTMTZTZTWTOTFTGTATBTFTQTNTPTGTLTYTKTPTCTFTATSTDTQTBTXTATVTRTGTITSTITDTKTPTNTKTKTBTATWTKTRTBTMTDT...

output:

975999035

result:

ok "975999035"

Test #24:

score: 0
Accepted
time: 8ms
memory: 10052kb

input:

11
WHLKKWTICHLBXNJKGGFGQLTLEHQUIYKLQZVWFFAVIDVCVJHUSJTYQTIJECJNQCLEJNZPKMPVBPKZHENYFXCSXZEUVJAFLMWIZPDWQDNRPBIGBTMNQKQOGJFEQYDHQYIBZXHBMWTJZJJWYWCQLEDVCUVCDMPEWOXGRADJQGRANTLNMTMHALLKTZYLFZPOPTOGKSTJBGJEGKBONVGJUSQDPBTECDEDGHAZCZOMZBMXVVTNMLPPLBVHLZXASGFRAIBAULIYDEHASZNGQDUBZCRTZYIXBDYWAGOIGCOAAPPON...

output:

6385324

result:

ok "6385324"

Test #25:

score: 0
Accepted
time: 11ms
memory: 12144kb

input:

14
UCBNFDDWTZCYVRYRQCEWBIVBQADDGNHJDJIPZMHCDWLAJDEJXIJIQTUOSNEUONNQIMOCRLSQXBPHDPQYBJLRQMANSCKNMCORGLIGAVBZQWQJKZFYDARHAZWYQOWYBKTWYESJAXNWDEEITRMCAPWAVVQQCCKQBSIPEGYZQXHYLWFOIYQBFESGUABSXJTOLACYNAUGFXJIBICEDPFLCUGQPDVZVGXRBKSHIDMFGEAAAPVCEBZJIZJQJTXQEPLZXFUQYWWPBQIDQDAXCGSBJNMBVOQTPWMTVVIZZTZZNOLBN...

output:

3768074

result:

ok "3768074"

Test #26:

score: 0
Accepted
time: 46ms
memory: 10168kb

input:

621991
PHSWLBLHWDNEUDLSMTKUPSYGZVVTXZVDFLIJERLKFTKBCPATGFTPXCYHAHBCPCFDBHHJMGDDIHSCNHNJMDPGMXXBSVCQMWALQNVOVWESQDBUTDPUMOUFTIHPQPYFUSWARGPFZFVUNNRUBOTHERYQVKCODQOMKXOAKSQEOVEXDNCHYNIVKEJJVJSZSSCQKXDWVMSWEXXKOYMQZSGCLTFQIRZMVVXXPJSGDZWRZYIJOLGGZCAHKUGSMEOHLJZKYZGIEHQDAIGBAPTJQIXUCMZDTDPAWACGFJWUWPRVS...

output:

285656877012

result:

ok "285656877012"

Test #27:

score: 0
Accepted
time: 57ms
memory: 14880kb

input:

681065
BPEIWKXAPGASDFYOVYWFZIFZJCTSZOHAXWADMHJQZAVYZDMYUEBGJMPIFDQIHSWKJZKXDJGLUMRGBSVFLDRWGSDWDXBBNMQFDJLVGSEHCFWYINVJGCGIOXIFVVQWYPVHSMOTSCJLYFNHBWNZHHYBGZKRZBPAYJFRZOICJOOBOVXGEIUXMGEUVYSFUPITQGHGFUPHCPJLBRRXUBLQRQVDSFHCYODJXQJZJKDZWEHLQRJIONJGGDJHXJUTJSXYKXHCAXRLXVRQZNXNZWMUCVXQLUPCIILGAXCDZMQHV...

output:

640624135227

result:

ok "640624135227"

Test #28:

score: 0
Accepted
time: 9ms
memory: 10692kb

input:

36576
IRMNJPGAQZMFDZACMEVLGQSDJLXFAZDQRXSIDMSYFRDHZVQRDZBVXMMMGAPYFJBSHVDQVASDYGLCWKADPAEFHBAXIZWXSMNJYEKSKKNAKESFUQEDOLDZYOIPVSEXKVJPHMZGXOYLWDNJBPRIISSWDYPGICCCERHMHCRYNZFPMYXXUPMAWPUIVGKHCJIQBQPPEDZDXZNUFQOCKZRSRAKCMVMSCBVFAJXUAVFZVUFERGHDXFMHUBOLXCJCNSHIEHNBWJYKOEUTXMKBPGQKWQZRLXYDFTCWLBBIYBFTYS...

output:

1631600024900756

result:

ok "1631600024900756"

Test #29:

score: 0
Accepted
time: 15ms
memory: 10768kb

input:

870492
ADNCVEKYFEDDSBIFJBFNAIHWGFWXLWYGROVNMWHJPTPCHMMFBYAXZFOUBOOCXQLEHLQCHJVJVGSMNPFNHHWOJBMDEASWBBALXBSFXXFVLIBEUMXGSNSKLEKOQGYHRLENMRRKNIURCFVQSXLNJJJNAYYSPFCILXCGCRFCBZDQAHKACQNFDSNKBFYDROLJPDKWZVLAJCUVIFXEHVGKXXKDKOOXFHKSARJMVWXGUYWUCDZOXNFHMYPJOECWNOXQBBWDOSSYUMCMZWSNSXMCBXNZHISVKLDJXABDKOVQH...

output:

2249019642670992

result:

ok "2249019642670992"

Test #30:

score: 0
Accepted
time: 17ms
memory: 9912kb

input:

699084
DMSSXMPXNYSUSGIHNSJDADZYKFGERGBHUVBJQLNZPBQSVFKZNAEGQJCGBAQVBMCFOWAZEJOEPIYSAKEEIDKVBMHVZGUWIGWGHDWMRCXDVAAWHSVMBCVCFLBMMKEJMMUSGWKXZXLKRQVDLUGLKBXCKOQLUOAOXMKUCIMNYVITJYFQPYCAISGUXPPXJJXBWRHCUQSBOXFMZDHUOMIRODDJVQIINHHSDKLDZLZOAOQXVJGCIYWVFLNLRQYLKSDZJVQNNRILUZISWYYKYGESNBPIWDRQKAFVZMUJZKJAC...

output:

2238903359576856

result:

ok "2238903359576856"

Test #31:

score: 0
Accepted
time: 18ms
memory: 16480kb

input:

1
YBBQHUMUHPCOXASQLWBRXUPEORMGCOFIVNDFSNGFJRWRYPACZSVJGKMMLJRUVOVXDVPAFCFXOAXMDGNPCXLZCHGBFCVYYOBEEOIFSNGFRINXEXUGSWOIZUJFFBVOEXPRSOIONPWYRQDKAHUKOVUJKXZCSLVIBWISZLDMXXICKVSEUALMNDLHNHMFBGXSSXJPBEPRBLJXBUIUGEZGUEHNEQAMENIDVJJYHZCPRFUKLRYFGPVYRDIQSEKKEZFZGQUFPSHQLZFMQVQXOMHDRXFMFOFVLWBMNJPIAFYWMFSQDQ...

output:

42737103431

result:

ok "42737103431"

Test #32:

score: 0
Accepted
time: 18ms
memory: 9448kb

input:

1000000
MJIRPODODXHXEGOQKDVQXFKONESHJFWAKFOURAPYCPHRCLUDISEFAOAWWMINVAMUFUWJEWCWYZJDPAVQJPULSSKPNLFHXLNXCYDYCJAYBIHSEHVCWBFXPFQVVRDGMCLPQQSRXDMEOGXPYNXHFIXDVXZRCYOEHUVSEIURMHSPILBWKCZFEYVGZGJAPUMIJIUGQJHESQMLXYKPHHQNGYMVOLJUGLLIWBNPYJMKVLUSLNFWAHFMENNLIDDELSWTKPWRSDXQDSDPAPQSWQLKXODALELSLZSELOQLXKEW...

output:

3392859102435868

result:

ok "3392859102435868"

Test #33:

score: 0
Accepted
time: 39ms
memory: 10856kb

input:

350208
TLTHTUTTTIECTJTTTTNTTTTDTZTHJXSZTVTTTATTJHTKTVDTTXTTTTTTBATTTTTTXTTKTTTTKTTDTTTTNTLYXTTTTTTTFJTTVTTTCTOTZNWKTRPTKTEKETTTTVRTVWCUTTTKDZWVPVMMTTTISJTTTQTTTETTTTTMTTTTRTTITTTLTTMVTTMTTKQTTTWTTTBTWTIGTCTZTTTTTTNVTYUTTTTTTIOVTTHITTSTNZTTTOTTRHTTTTDHTTTUVPWTTTTTUTTTHMLFWNTQTTTFHTPTTRFITNDFTJNCKESTI...

output:

1248723

result:

ok "1248723"

Test #34:

score: 0
Accepted
time: 57ms
memory: 23472kb

input:

343585
TRTTTTTRTETTTTQTTTTAOTTTTWTTSTHTXSTLTTSITTTDTTTHTGTTTTTTTTTBTTTTTTCTVTTTTNTTTZTTTTTNTTTUTZTMTVJTTFTDTTTTTTTYLTTTTNXTTTETMTTTTTOTTTTTTTTBTPTTTTXVWTTLTITINTTTTTZTTTATTTPUTTTTTTTOTTTTTTTTTSHTLTTTTTTTTTTTTTTTTTPXTTTTYFTTAYTPZETTTFTHTAOTTTTTTTTTTTRTTOTTTTTKTTTTTTTTATTTTXTTSTTTTTTTTTTOTTTRTTTTTLTTL...

output:

1468088

result:

ok "1468088"

Test #35:

score: 0
Accepted
time: 23ms
memory: 15968kb

input:

1
TTTTTTTTTTTTTTTTTTTTTTTTTTTQTTTTSTTTTTTOTTTTTTTTTTTTTTUTTITBTTTTTTTSTTTTTTGTTTTTTQTTTTTTTTTTTTTTTTITTTTTTTTTTTTTTRTTTTTTTTTTTFTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTMTTTTTTTTTTTMTTYTTTTTSTETTTTTTTTTSTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTETTTKTTTTTTTTTTTTSTTTTTTTOTTTTTTTT...

output:

1

result:

ok "1"

Test #36:

score: 0
Accepted
time: 79ms
memory: 13668kb

input:

1000000
IHTTXXQVDVKETTPPWTTLLTYATTBCETCLTSEIXTTGTTJTTXBTXTTVTTTTIFYTASPDBTWVHTMVBTLTHTTQWTTTZAIATTDTTTTHGJTSTEZVTYPTTXTTTOLWTEFTEIHUATPTTQWTBVYTTCTVXZTDZTTTZZTMULPUSATTTITTEWFXTZNPTETDTLTUTNTDCTPLITDTYMWCTJTHZTTFTHJNATMBSDJTQTZTYDWFTTQAJTOKTTQKTTCUVTTAVXXUTRTULOTTTUUUZMRMITTTXHTTGTTTOBUTKTMTBPHTTTTT...

output:

4223102

result:

ok "4223102"

Test #37:

score: 0
Accepted
time: 14ms
memory: 10708kb

input:

345046
YHNYBBTUCRWJTYITEQDYYTEHAGBWBETO
KT
JNFETZVTCUHLGMPNGVMWZZFIXNFGUVSSEBSKMZUJSCFVCDTWPCPBPSPYTKLDOAOLRJJLESLGLOVQLDJMHYSQACKIMABZVTMLCPCAQEXDTJFBLNYCNJWJDDSAXEEICBXVYQGYBPXVNFCHIIXKUMMQXOEMNDYBGNGEJJCQIHHLYFUIZNJHUGSRKVXFRRTEYTCLVWTOSBNFBLZPSSPUFGMMLVYTADJGUGJYGKQCHOCNIZCPDNFLFVNBAHTGJAFKGPJLL...

output:

3140057680

result:

ok "3140057680"

Test #38:

score: 0
Accepted
time: 14ms
memory: 7528kb

input:

990105
T
T
FTBLKZUGHSNFTKEUEFRULGLILYCTYPKXZJGPQTUUYNZEOVXWTHZDKUMINCMNMZVQDLVVFLKBBFAWUQRFJLHKBRZFNKDOBNVKWQEKCBFXCUJGEGTUPKJHGQEDFEVXTNVUTJEMIIYWJMHVXDABJPUAXZLHXFRMKFMOFUPKTNELPOGHIABOSMCKQPQHEWKCKGGXTAXMAGXSCKXBMHSVMORIDRLLXWCUCYTUIROUNUNBIDNAXBQSDYWNVTYKRPWEJDWJRIIACNIUPXJUKAMPAVULCAKXGVEAXYTDT...

output:

866652802

result:

ok "866652802"

Test #39:

score: 0
Accepted
time: 49ms
memory: 6120kb

input:

749386
DUGGXTKUUHOZRLDPEVBNGEZUQPUDQFGHYQNMPMJRMPSFVFLECMGXNFDPQZIQCIUDUBNVIRAMTDMDDQRMJZEMKVEDQWTJIUUQOMHGEQETZUWIIOXPRUMAYLEGQDNRATLWXLYSYWMNOCBPITAKFYBMXDPOSHNZIEOWXCWDUNBSPNVONUBUPANOITVOIRJNEXUIWWLJJNJAMIMHLFMVHISWXDXNAYGTTKXRNEYTLKBKDULTHDBMSLTRHTAYRCGCCTPZEYHLYEWOFNQXOOIOGSHANWZGGEZJPVNJDFJVS...

output:

5798101706

result:

ok "5798101706"

Test #40:

score: 0
Accepted
time: 49ms
memory: 4968kb

input:

866202
UXTLRNTHESMXDHIJJQMRBZTFUVPADFGJWOEYLEDDHYCBJXXCHWTUWBDSKUDMFBHOQEFTPECMBFTSJKAPNTJLWSJCTHDKPLEKAZGZBXFZBNURENZXPJDSGMCTLAJNWKPZRWNDNJUAEOBZLYWFUSDCEVVADQZMVZVMFWNBBMSGOTDHGVOPBFLEYIQEKHOMADATVMIKFJUSNUCMZKFTTLQDNGCFNXYVMHEEFQUVPCCGKPXBXDPUVHWPYVGMOBAQDANKOWKTDATEPPINMNRQLRWPIJPHMJEMRINZZDDQI...

output:

23920713675

result:

ok "23920713675"

Test #41:

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

input:

610175
LMSBGVAMNSLAUVFWKDZOQFMBUDYXLKPRYOKNBWNPNNGNOMHAJZKXKIURGJQYZFOAKUAAMOENJFADLHXRLAXCXZEMUFRJAFDOGNIYZIQLPFKJGRJZUHSWECQRVACLYXDBRZAJRANHCFCRWPXRVNJSYCXBBMSXFSIRSBNBVGNAQCPQNLZMUIHYKJYWCDHHKANZUXWWCAVPSVSLEJSCCUAUEORRMADXIAIXUSLEUQRUDGHXIPDVPEZRADAXXVENMHGSOXPKKZGKNNCVSKGCKSZLZWVJIHMLAZXFVRUQH...

output:

-1

result:

ok "-1"

Test #42:

score: 0
Accepted
time: 7ms
memory: 10972kb

input:

756402
XSCBCBAPCCEYMGHJSUVDLMSSKUWBEQWFBWGEORUIKDAEKLGMAZRZJSARWQJNJGADAUVAJCMJJLHUWUCRDXSLBIGARBXRBONWZYPFXLNLUCLIIJMWVLAVXPBSJHCBXAPHGGIQDSGKOXJCALHCALARIKDNYPSHCKIESGSMULRBRJSAMFPOYVZOPNAYPCGBHVVWDDMNOUXWAFDVXORXMAYPYZAYUCDFLGKJERDJZZZDAVBDQPBOXEWUBNECAPJJXWKHHRIQVQRJVQOPJDAUYLNLPZDMYKRFGFLIMGYNO...

output:

-1

result:

ok "-1"

Test #43:

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

input:

919744
USJEGOJVYQVJIGPJCGEIMWJIPVBISYGBFEQXUFEIICJUNOLOKGNFJODMSRFRRKJXLJWQBPFFVJIHAWXZEWUJDXUHYEJHODCQFHUHZGIRKBJDPHDZARJZZZXULFVUJCWAKDEHWQIZDGKXEWIOIXXDRSAYJPVFVEDSFDVGHNWYRFLWHBWDDYBCRYDWWWQGCPOXLCQEUYXGNLOMXWPYQAZCMFGDZYZNKUKGWCMPDGZKQDQPNBOLRDPQUWMFOCNRRLXUDESUCDHQSPLXCGXHRXVFWQCPCLXDPJDIXQASG...

output:

-1

result:

ok "-1"

Test #44:

score: 0
Accepted
time: 7ms
memory: 4716kb

input:

178094
HZWHPASQGCMRKYNSKGRXRJSSNSOLLIGZEENWSGMGLOTSKUELOFMOEHRAOSOOMPTEYRNLCOKTZGMOORBSCTKEPBRSMMVCSIYDCLHYRNRBMNIZWAPEBXANQGFDCIUWYXXMSOTGLBYBUWPOZJMSRSBVYMUKJECRZOZPSILNUOTXNISNQYCGQVYIEHNLLLKLEWONDQLRTGQNTFIPEJNYTKFCOZNCCQBGXTABPJWFJGGUUFRJKDMUBXQWWIMOZMNMMURSTVIKZFNSTJFUJVUVGJVOWCZDNJQQIDCDZXFOY...

output:

101851007373

result:

ok "101851007373"

Test #45:

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

input:

39543
AQPXLJNTTQLCKBXEYORIHKWPLZLRDSIOGTQLDQRLOZKCNFOAJSVRSWQZRJPKLJPUNGYTUWNRXBMDONTILKYKYLGNKGBFTTOKQWYDDULORMCAEEIDPJLBHKHLULTTRQLOPONMWUFZWSRFHHHNVKUVMRNALCTKSJUPC
SLUDMGAUPMFSUYJLEATOTPVLJIRRVFXXUVPKYUINMHEUXHLHCSAAFCJUSMPLUOABQUCZPUIDIDDSCDDOGALBXTVHZONATVYSYOIQWAIZFGPBLCBUAMAXTRQQGGMJAGETSVBM...

output:

10428475413

result:

ok "10428475413"

Test #46:

score: 0
Accepted
time: 29ms
memory: 5584kb

input:

513749
FTFAAVVEXZFCJHJLRTXHZBMFWRZZJFGCAFKJCRLJGXNCGNWTHEIMSNFDNREGTRKBYPBQFOGHIIXXQHALXTQFKQUVQJDUSNQFEUENDGMMHKTRFHQTYCAOWJWVNCVYIBKHXMAGDXXIOARCQZZFMRKPRYYPOVFSPCRCBNEPIVSFLMCRAFFXTAVBLQDFXWCFIFSMPOHRZPVAWZFXKSMQNXDIDCVBKKATUEJFUIENPGRCLJMBUJADEUAYAZPACDTKUUMUKMXKEAKJMFDBQWMKZSDEPZIPWRKKOJQONPKCZ...

output:

297904535175

result:

ok "297904535175"

Test #47:

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

input:

323568
HPCBEXJKHBICZDFYOPUZNIQSKEYEYGWNWNOUBKXZMPPYMIGWASAESQDCQELHRDQZHDNVBJVAOPSRCBQIYPLSQJXMFZXSYESFHXPXIABQLIKDZZKTFXEOIFWLJXHPKXUJGGUQLMRAOBQDQRKHQFMOUAVFBCIDFHCMRREKMXDJRYBFJNDDQCZAJRLVMZFEMFVYKOSIWAXUHSKEHKONJGSOUBLAAEAMBOGYVIDHBTPDPGJKWMBNNOEUCPWLEBHSHLISZMLSNKQQPIMJKMWIGINMCXBNJHWIJKFQAJPYQ...

output:

195139073323688

result:

ok "195139073323688"

Test #48:

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

input:

999097
JMLDZBUFHJCMCBZYSICXVXSAMWHRXBKGLRINYIVJFMREUNGWXGJHXJCRIBDPCCYBPSNUAGERMXJHRVPLHVGFGBZBXEDZZXYVXNQRLDNOLJMHALPKLOWTZVTYVDAVSJXGDAQNSGHHMNEAXBKBVCVUMAPUUJKLUQIYVMIZDGOCWOAFXNRQNSJNCHLHMJGBQBFCQMHFNKUABXPNEINEZMWCG
XKZOCCLIDPCRBKZUZVWNYHEKNEOUEJMSRFYCLLKPBPSSCXXZIXQQQOGYVDYXJOGPPIROKXONZLBKUJR...

output:

-1

result:

ok "-1"

Test #49:

score: 0
Accepted
time: 8ms
memory: 6828kb

input:

655651
CIXDKABYGNOFBFJPZMQHEVRRUGCIVXAADZKVXLGXRKWSOKESCXMGJYRHAVKRHGNWRQIUWRHHQMYKULBFOEVUDSIGGNVABJFXWQOTDUSRDEYQZOHNPKJEZCIOJIBLSYKOXCSYRBPNKWZZBIRZLRBVKJXFXQUQRPCQKGMOKOBTYYQWKJILUCZQLIYLLWDOLRZEQUEDYHQLXSXCBWRFMZHPUWPRMSHIROBBEVXRSFCWOUULSZWRGHJKSKWMIISEIGYMXQHKKBCKGIVWJOHWQPVUFGNJQUYJXHCKYSYCW...

output:

2634424714338390

result:

ok "2634424714338390"

Test #50:

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

input:

622657
BOEINRYGECRHNYPWZVYUZBIHUFQESGGOBLRUGOIDJEJZFSANFJRXLCKZPVBJCARZEZBXVEFSBPIJSJWXEMWDXOXPPHDLVQKKJDDKCSKNNHFASMSBOHOMABBBNZKSYIASGIUEWLMLVOXDFOFSIVOGWFYFMDEXJANBURYSWVBXZHRIYQLVPDMNKJQKNJRXCSMSOOIXELGDLKHSPVVLDHJIZKYAQRXHVJBDUNBUCIPPBSXXZLIVJRLSIPFGRYJOSEXQJIAYWAAJDPQISAVYBZFKAPWJFBGJXVQVVIMSW...

output:

-1

result:

ok "-1"

Test #51:

score: 0
Accepted
time: 46ms
memory: 4120kb

input:

1000000
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTT
PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

output:

1000000

result:

ok "1000000"

Test #52:

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

input:

1000000
GTTTQTTTNTTTXTTTQTTTLTTTZTTTBTTTKTTTBTTTDTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
PERYPSRBPGFUPTIAPBWNPVLLPJCYPGTHPSHL
CCCCCCCCCCCCCCCCCCCCCCCCCCCC

output:

-1

result:

ok "-1"

Test #53:

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

input:

929626
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
ATILTXVTOBTSXTNVTHUTUSTCWTBGTKSTWMTOJTVPTS
PWPPAPPKPPQPPVP
CCCCCCCCCCCCCCCCCCCCCCCCCCC

output:

-1

result:

ok "-1"

Test #54:

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

input:

1000000
TTTTTTTTTTTTTTTTTTTT
MTTMOTTULTTOITTWJTTAOTTGMTTBXTTB
PFUPPKTPPOWPPLZPPNOPPKGPPLIPPGBPPQGP
CCCCCCCCCCCCCCCCCCCCCCCCCCCC

output:

-1

result:

ok "-1"

Test #55:

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

input:

5633
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TULTWITPZTXJTXQTGFTPDTHVTKB
XPPIPPTPPVPPOPPIPPAPPLPPPPPTPPWPPMPPEPPKPPHPP
CCCCCCCCCCCCCCCCCCCCC

output:

253465

result:

ok "253465"

Test #56:

score: 0
Accepted
time: 11ms
memory: 4124kb

input:

1000000
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TQYFTPAZTCWHTSHRTWKVTTBCTVTJTNVU
PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
BCCCXCCCXCCCWCCCPCCC

output:

15999995

result:

ok "15999995"

Test #57:

score: 0
Accepted
time: 11ms
memory: 3924kb

input:

1000000
ZBXHCHSZMLVPLQGGTJDROEZBFDEQ
DKDOKMUWXYLODPABTHGCFRYICACVVDMICSOHBUBPHUWOI
CIBJMYEHQHLLWFYSPJJCGTDAYNNWUAISUYUZEDOGRCD
ANOJKQAXPJTNDGSHCQSDSAFBXWDDKRVHEQROPZKZS

output:

2221377778637

result:

ok "2221377778637"

Test #58:

score: 0
Accepted
time: 11ms
memory: 4128kb

input:

1000000
WZENZHGEFMTHAZKSMODUCBNFDDWZCYVRYRQCEWBIV
BQADDGNHJDJIPZMHCDWLAJDEJXIJIQUTSNEUONNQIMOCRLSQXB
HDQYBJLRQMANSCKNMCORGLIGPVBZQWQ
JKZFCDARHAZWYQOWY

output:

1080349150532

result:

ok "1080349150532"

Test #59:

score: 0
Accepted
time: 11ms
memory: 3856kb

input:

999931
YZQXHYLTFOIYQBFESGUABSXJOLACYNAUGFXJIBICE
DPFLCUGQPDVZVGXRBKSHIDMFGEAAAPTCEBZJIZJQJXQEPLZXFU
QYWWBQIDQDAXCGSBJNPBVOQTWMTVVIZZTZZNOLBNUVDGDBHAL
SEAMROELTNSNJHCSUONPLHIWTILGSKZZSKZEBVS

output:

3917276603931

result:

ok "3917276603931"

Test #60:

score: 0
Accepted
time: 8ms
memory: 3840kb

input:

1000000
BIHBPVPHYTWZXITHWCEXISNZDNTCZEBTNHZFWIOAEPZCOBUNWL
OLIBUOONULIOXSTJTQGSUQDIQEJFOTOTIDKIWZRAP
ENGELUGMJLBACDRYPHEKPPVPXQIURFGOYOMUOVEKYLQUIMWF
APRFKDFOUVYYOAAMCTYWCHFITGVIMCCEQUZDPJR

output:

13324982182

result:

ok "13324982182"

Test #61:

score: 0
Accepted
time: 17ms
memory: 4100kb

input:

757219
SWEXJTINTTWDVHGIRGRWKBXJLSEHPLHTHTDUDSR
KEHMUTHUGBTTACTTG
EEYLFRCHPVUCUPTNKCEIYJWCKRCFLJDPPBPXTIJI
AIETPYGASHCOOXKHCCRPXCJFKDFIYXC

output:

996058294

result:

ok "996058294"

Test #62:

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

input:

629201
TT
VTTTT
PUTLPFRQRP
C

output:

3146005

result:

ok "3146005"

Test #63:

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

input:

147204
T
TTTTTTTTT
PGFQGLP
ZKLCQ

output:

2576064

result:

ok "2576064"

Test #64:

score: 0
Accepted
time: 6ms
memory: 3836kb

input:

805507
TTTTDCVT
TTT
PPPPPJNPP
CZCPVKPCB

output:

3866419

result:

ok "3866419"

Test #65:

score: 0
Accepted
time: 30ms
memory: 3864kb

input:

524954
TPBTKTTGTZTYPTJTTZOTTSFGLTTLKTTTTTTTTTOJ
TTTTTTTTTTTTTTVTTTTTTTTTLTPTTTTTTTTTTTTTTTBTTTTTT
PAPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
ZDOCSCCBCLWUCJCFCEMCANCKCCCSUCC

output:

2352475

result:

ok "2352475"

Test #66:

score: 0
Accepted
time: 6ms
memory: 3844kb

input:

127002
NCBTQETTQTLTTTTXT
TTTTTTTTTTTTTTTTTTTTTTT
PPGPPPPPPPPPPPPPPPPPPPPPGPPPP
GICCBDGADCCTCCJXNCMMCJFCCGLRJXCZCZANYCCFSAXPWEFGC

output:

841691

result:

ok "841691"

Test #67:

score: 0
Accepted
time: 51ms
memory: 3844kb

input:

1000000
KTTFJIMTODIDGTDJDTPTKMDTTIPBUTTGWGSPRXNJUKT
TTTTTUSTTTWTTTBTTTMCTTCTTTTVGDJTTWTYTTTTTTFPTT
PSPPGWPPSPNAQPYPFUPPPEPPPPPXPRPXJPYPHPU
ECCCACLCZCCCCWCAXCYUCGCAHVYJSFCMD

output:

26472458

result:

ok "26472458"

Test #68:

score: 0
Accepted
time: 6ms
memory: 3836kb

input:

936720
TTCTOGTB
TTSVEZEWXWTQYRTOTNAZGZLNNOCXTHTTMQN
BHOIRHPUNP
OQGMCHXRC

output:

147533297

result:

ok "147533297"

Test #69:

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

input:

1000000
TTTDYJTTT
FIZTUUTTTTTTVITTDNTTHOITXTTYTFTKTFTDTBHXTK
PLPPPPPPPPPPVPPPPZPPP
J

output:

-1

result:

ok "-1"

Extra Test:

score: 0
Extra Test Passed