QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#534216#7748. Karshilov's Matching Problem IIucup-team956WA 66ms14232kbC++203.9kb2024-08-26 22:01:582024-08-26 22:01:58

Judging History

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

  • [2024-08-26 22:01:58]
  • 评测
  • 测评结果:WA
  • 用时:66ms
  • 内存:14232kb
  • [2024-08-26 22:01:58]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define SZ(x) ((int)((x).size()))
#define lb(x) ((x) & (-(x)))
#define bp(x) __builtin_popcount(x)
#define bpll(x) __builtin_popcountll(x)
#define mkp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

struct Exkmp {
    int n, m;
    string s, t;    // string (Index from 1)
    vector<int> z, zt;
    /*
    - z  : s 与自己的每个后缀的 lcp 长度
    - zt : s 与 t 的每个后缀的 lcp 长度
    */
    Exkmp(string s): n(SZ(s)), s(" " + s) {    
        z.resize(n + 1, 0);
        zwork();
    }
    Exkmp(string s, string t): n(SZ(s)), m(SZ(t)), s(" " + s), t(" " + t) {
        z.resize(n + 1, 0);
        zt.resize(m + 1, 0);
        zwork();
        ztwork();
    }
    void zwork() {
        z[1] = n;
        int l = 0, r = 0;
        for (int i = 2; i <= n; i++) {
            if (i <= r) {
                z[i] = min(z[i - l + 1], r - i + 1);
            }
            while (i + z[i] <= n && s[z[i] + 1] == s[i + z[i]]) {
                z[i]++;
            }
            if (i + z[i] - 1 > r) {
                l = i; 
                r = i + z[i] - 1;
            }
        }
    }
    void ztwork() { 
        int l = 0, r = 0;
        for (int i = 1; i <= m; i++) {
            if (i <= r) {
                zt[i] = min(z[i - l + 1], r - i + 1);
            }
            while (i + zt[i] <= m && zt[i] + 1 <= n && s[zt[i] + 1] == t[i + zt[i]]) {
                zt[i]++;
            }
            if (i + zt[i] - 1 > r) {
                l = i;
                r = i + zt[i] - 1;
            }
        }
    }
};

void solve() {
    int n, q;
    string s, t;
    cin >> n >> q >> s >> t;
    Exkmp exp(s, t);

    vector w(n + 1, 0);
    vector pre(n + 1, 0ll);
    for (int i = 1; i <= n; i++) {
        cin >> w[i];
        pre[i] = pre[i - 1] + w[i];
    }

    vector val(n + 1, 0ll);
    for (int i = 1; i <= n; i++) {
        val[i] = pre[i];
    }
    ll tot = 0;
    for (int i = 2, r = 2; i <= n; i++) {
        while (r <= n && r + exp.z[r] - 1 < i) {
            tot += pre[exp.z[r]];
            r++;
        }
        val[i] += tot + val[i - r + 1];
    }
    // cout << "gao : " << val[2] << '\n';

    vector qseg(q + 1, pair<pii, int>());
    for (int i = 1; i <= q; i++) {
        int l, r;
        cin >> l >> r;
        qseg[i] = {{l, r}, i};
    }
    sort(qseg.begin() + 1, qseg.begin() + q + 1);

    vector sum(n + 1, 0ll);
    for (int i = 1; i <= n; i++) {
        sum[i] = sum[i - 1] + pre[exp.zt[i]];
    }

    vector ans(q + 1, 0ll);
    priority_queue<pii, vector<pii>, greater<pii>> pq;
    for (int i = 1, j = 1; i <= n; i++) {
        while (j <= q && qseg[j].fi.fi <= i) {
            pq.push({qseg[j].fi.se, j});
            j++;
        }

        while (!pq.empty()) {
            int id = pq.top().se;
            if (qseg[id].fi.se > i + exp.zt[i] - 1) {
                break;
            }
            pq.pop();

            // cout << "i = " << i << '\n';
            // cout << "qujian : " << qseg[id].fi.fi << " " << qseg[id].fi.se << '\n';

            if (qseg[id].fi.se < i) {
                // cout << "nitian" << '\n';
                ans[qseg[id].se] = sum[qseg[id].fi.se] - sum[qseg[id].fi.fi - 1];
            } else {
                // cout << "666" << '\n';
                ans[qseg[id].se] = sum[i - 1] - sum[qseg[id].fi.fi - 1] + val[qseg[id].fi.se - i + 1];
            }
        }
    }
    
    for (int i = 1; i <= q; i++) {
        cout << ans[i] << '\n';
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    while (T--) solve();
    return 0;
}

詳細信息

Test #1:

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

input:

8 5
abbabaab
aababbab
1 2 4 8 16 32 64 128
1 1
2 3
3 5
4 7
1 8

output:

1
3
3
16
38

result:

ok 5 lines

Test #2:

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

input:

15 4
heheheheehhejie
heheheheheheheh
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9
2 3
4 8
2 6
1 15

output:

3
13
13
174

result:

ok 4 lines

Test #3:

score: 0
Accepted
time: 55ms
memory: 12988kb

input:

150000 150000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

108147037823514
221878585246974
455339807727642
440286198422821
148115747906237
88695249853257
351159618462315
58850354020997
65824434822005
270158033672354
197732558443069
298193894693053
239511187032650
28139154231325
408380171835227
268053430937402
32417121185965
104813548228675
44074926058619
78...

result:

ok 150000 lines

Test #4:

score: 0
Accepted
time: 58ms
memory: 13020kb

input:

150000 150000
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

528900815691571
112638556022185
514229554849356
2216206133639915
295388515578381
1658587138269057
652142121207636
166322478628783
490195029871161
1191292846892788
1468501126902703
487990867773908
55994169916421
568966315599642
2522992078581539
2339888502167342
2881203249819745
154700081279584
152537...

result:

ok 150000 lines

Test #5:

score: 0
Accepted
time: 62ms
memory: 12940kb

input:

150000 150000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

386150762496368
2769669390423140
1025785181073675
1707930121656247
332135612349048
113937878332307
1128519694119799
476402941643931
980441978140407
1004994648999517
676169371268202
2607965889355671
273766796671958
711480908011402
71754482763611
400453994282744
975387094872830
810536618300388
2229061...

result:

ok 150000 lines

Test #6:

score: 0
Accepted
time: 66ms
memory: 13020kb

input:

150000 150000
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

25254725752128652
23497896664383313
15195391464047263
41143572895791434
7513384536045842
8871310939247699
17423823866879881
14601201534396958
6203483865940624
24953281161800570
24776576029495768
1687640411226
31563282955464371
29947970968962218
1149303801639767
5806503923049299
11201332188941891
116...

result:

ok 150000 lines

Test #7:

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

input:

150000 150000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

4570597927951323
11761063519994765
289982253793476
15684854914181269
19579321543184889
459972639580770
15246459216963247
1833393949769247
22425556248999709
11209560100586843
2883954996867615
14371655418173335
29207399108721
5943079608253242
1664456073054861
27405606916506455
23082758946788297
381175...

result:

ok 150000 lines

Test #8:

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

input:

150000 150000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

5697498028074951
21822720964918437
11237472002329727
84315407720465773
32198634509153899
40728716039967676
5913555967331675
10487781019914529
270012821917938205
239347797488036653
216168445985667902
67452321725546144
457298584810665039
187789940805492303
46241700003064393
242312618101113
42260337439...

result:

ok 150000 lines

Test #9:

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

input:

150000 150000
abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaabab...

output:

20591954951726
12208904434175
7662625006262
27638144315127
14991794671504
12693360208820
11037771157715
4373484191175
19325903476164
26048068499431
5723213500221
37836285761904
44407448222078
17672607641771
18226179013226
25664535060427
6571081196245
7364255499121
31338586400498
6963750199271
362906...

result:

ok 150000 lines

Test #10:

score: 0
Accepted
time: 56ms
memory: 12968kb

input:

150000 150000
abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaabab...

output:

26679397939583
14744203186201
5444732298002
2682795720153
8097594477750
11849141088914
4460923379501
213037786838
16105345264171
9432794502217
7341906921155
175129395650
26090540252644
7939835388186
1974417753321
13404114384225
3350016113286
11461223687633
11253459438574
10536087601821
410458842950
...

result:

ok 150000 lines

Test #11:

score: 0
Accepted
time: 44ms
memory: 7276kb

input:

1000 150000
abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababba...

output:

14533294687
36404448099
4898807521
8311487449
101191999742
73649429237
64160767440
94533233142
11330483415
11891445585
32475987658
20881014384
19725249244
46562700910
8954411927
15493987162
95870286230
21115698529
2452671987
14439012748
11977731306
12229300727
74351907054
22843320780
40597085949
512...

result:

ok 150000 lines

Test #12:

score: 0
Accepted
time: 48ms
memory: 7184kb

input:

1000 150000
abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababba...

output:

54399359946
51977853051
49357792746
110019851897
69572597913
15709337251
55079579625
23693208641
171669911
1351037076
76795212797
40916790174
98891460109
3646721871
18505243674
61205775419
75138278275
44089408535
5074434752
50936710571
136345768092
19271144823
46362641831
62317616153
37671155153
162...

result:

ok 150000 lines

Test #13:

score: 0
Accepted
time: 56ms
memory: 14232kb

input:

150000 150000
abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaabab...

output:

38772069365927
38538545381556
38743522830612
38518262255568
38627306791107
38755103769862
38514395190995
38435548368667
38617960233472
38622898369466
38889725443048
38186753347601
38497568337263
38450570197606
38842403793276
38762153954801
38493442696613
38782127536129
38449780600849
38538849423248
...

result:

ok 150000 lines

Test #14:

score: 0
Accepted
time: 43ms
memory: 7336kb

input:

1000 150000
aabaabcaabaabcdaabaabcaabaabcdeaabaabcaabaabcdaabaabcaabaabcdefaabaabcaabaabcdaabaabcaabaabcdeaabaabcaabaabcdaabaabcaabaabcdefgaabaabcaabaabcdaabaabcaabaabcdeaabaabcaabaabcdaabaabcaabaabcdefaabaabcaabaabcdaabaabcaabaabcdeaabaabcaabaabcdaabaabcaabaabcdefghaabaabcaabaabcdaabaabcaabaabcdeaa...

output:

58046174517
12715251464
5723988017
161223697602
137002400916
30563623878
98934054385
59077629445
113925111785
28840565698
156244390553
77320878352
59683981982
127942734209
121145579565
87520380292
55236806101
2117874653
80900981342
31724248103
50230142282
711792462
83498404152
29926218182
8820224616...

result:

ok 150000 lines

Test #15:

score: 0
Accepted
time: 47ms
memory: 6792kb

input:

1000 150000
aabaabaabcaabaabaabcaabaabaabcaabaabaabcdaabaabaabcaabaabaabcaabaabaabcaabaabaabcdaabaabaabcaabaabaabcaabaabaabcaabaabaabcdaabaabaabcaabaabaabcaabaabaabcaabaabaabcdaabaabaabcaabaabaabcaabaabaabcaabaabaabcdeaabaabaabcaabaabaabcaabaabaabcaabaabaabcdaabaabaabcaabaabaabcaabaabaabcaabaabaabcd...

output:

43966954106
63457970792
261177599185
84416298978
32467601340
158024435898
129927481955
29905035826
1663395309
262974056170
126552502741
3977985830
6794527980
134076085617
153168175752
20202212393
20413397242
263088231784
188742026136
2338731931
31903630853
144258078247
11137714967
22338312083
194691...

result:

ok 150000 lines

Test #16:

score: 0
Accepted
time: 52ms
memory: 13016kb

input:

150000 150000
aabaabcaabaabcdaabaabcaabaabcdeaabaabcaabaabcdaabaabcaabaabcdefaabaabcaabaabcdaabaabcaabaabcdeaabaabcaabaabcdaabaabcaabaabcdefgaabaabcaabaabcdaabaabcaabaabcdeaabaabcaabaabcdaabaabcaabaabcdefaabaabcaabaabcdaabaabcaabaabcdeaabaabcaabaabcdaabaabcaabaabcdefghaabaabcaabaabcdaabaabcaabaabcde...

output:

29914293876821
29388248888943
5520238628990
6509772252533
11376377552909
901817826019
13219593022192
23330308156488
33721084055601
10522195135985
1748546656146
1553205391001
15793344985123
33174193324692
26957558511532
8590975656478
7024857425105
14444339872596
2023167053405
5779413699241
2334817520...

result:

ok 150000 lines

Test #17:

score: 0
Accepted
time: 55ms
memory: 13004kb

input:

150000 150000
aabaabaabcaabaabaabcdaabaabaabcaabaabaabcdaabaabaabcaabaabaabcdeaabaabaabcaabaabaabcdaabaabaabcaabaabaabcdaabaabaabcaabaabaabcdefaabaabaabcaabaabaabcdaabaabaabcaabaabaabcdaabaabaabcaabaabaabcdeaabaabaabcaabaabaabcdaabaabaabcaabaabaabcdaabaabaabcaabaabaabcdefaabaabaabcaabaabaabcdaabaaba...

output:

51654672077087
18128065265954
10648077478275
24096372633749
33921372063966
52844542543234
19475889095501
49998404687384
30981572147127
53639263941544
7723904914977
3305784882722
36334815617245
36978590959883
39392351303785
33813693293258
7380058627592
17560621637115
9885403408272
14150106810987
2507...

result:

ok 150000 lines

Test #18:

score: 0
Accepted
time: 52ms
memory: 13128kb

input:

150000 150000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

813092418312696
1317798689473715
1315665465011076
2405711931597
356128071216857
204530268744615
796004029533782
2524560020845716
2142315805349726
1000649874336585
3110164476348575
2074236435764977
869887553468426
135346186547404
2107116066259453
1409642986095650
923200979353524
376619890608622
17975...

result:

ok 150000 lines

Test #19:

score: 0
Accepted
time: 56ms
memory: 12940kb

input:

150000 150000
aabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaab...

output:

891232692268242
180239781074503
762986955623910
2182769025630738
892305971824847
911080210251582
1273751943749997
1612958343425903
839270032556736
1812514937518138
2753082659282112
1273772162515030
1359136888087723
2843461425942221
1848164748961046
601261559736813
12298394517162
882181981558879
2969...

result:

ok 150000 lines

Test #20:

score: 0
Accepted
time: 58ms
memory: 13020kb

input:

150000 150000
aabaabcaabaabcaabaabcdaabaabcaabaabcaabaabcdeaabaabcaabaabcaabaabcdaabaabcaabaabcaabaabcdefaabaabcaabaabcaabaabcdaabaabcaabaabcaabaabcdeaabaabcaabaabcaabaabcdaabaabcaabaabcaabaabcdefaabaabcaabaabcaabaabcdaabaabcaabaabcaabaabcdeaabaabcaabaabcaabaabcdaabaabcaabaabcaabaabcdefaabaabcaabaab...

output:

1194619495572
795884372512504
1175435646771188
2302482629192344
582273726204212
2236317824765870
119988076211482
678581408764964
2101023153383665
888572706609489
186359125426424
1397048595862182
1317852784077245
190253063244
865232742049445
1491695395427100
640644116246476
1446530862350308
170011517...

result:

ok 150000 lines

Test #21:

score: 0
Accepted
time: 60ms
memory: 12940kb

input:

150000 150000
aabaabcaabaabcaabaabcdaabaabcaabaabcaabaabcdeaabaabcaabaabcaabaabcdaabaabcaabaabcaabaabcdefaabaabcaabaabcaabaabcdaabaabcaabaabcaabaabcdeaabaabcaabaabcaabaabcdaabaabcaabaabcaabaabcdefaabaabcaabaabcaabaabcdaabaabcaabaabcaabaabcdeaabaabcaabaabcaabaabcdaabaabcaabaabcaabaabcdefaabaabcaabaab...

output:

432981642389138
369819684910697
674517425239465
595536647891124
177569847795803
934205515438256
182914252110569
3453242346130
379689140841865
472465468653933
551405636497734
924788388701343
387440477848840
403148807711424
118166293104989
231069344260660
455187760837014
654856703426747
14126165707025...

result:

ok 150000 lines

Test #22:

score: 0
Accepted
time: 61ms
memory: 12964kb

input:

150000 150000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

139092615923852
319712839391046
39921108996632
236395672026301
709843083668671
541581333895491
670629605184988
359722149795181
1434679507168815
427767149417380
103440733252864
162815973876064
5616565642136
213571238193114
473655044673898
1319021925607968
176177858522467
1094307268000496
789182609618...

result:

ok 150000 lines

Test #23:

score: 0
Accepted
time: 55ms
memory: 12732kb

input:

150000 150000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

176449221404353
857960219930710
842692900572808
32011407408076
36679450185285
77449627797994
773227897058900
242672941287399
112572896349484
1084073090765193
935389071307684
242262854116272
965264314963252
374225801426478
148690698579830
245286364056781
147691073049337
81763003844687
414872147677601...

result:

ok 150000 lines

Test #24:

score: 0
Accepted
time: 58ms
memory: 13172kb

input:

150000 150000
aabaabaabcaabaabaabcaabaabaabcaabaabaabcdaabaabaabcaabaabaabcaabaabaabcaabaabaabcdaabaabaabcaabaabaabcaabaabaabcaabaabaabcdaabaabaabcaabaabaabcaabaabaabcaabaabaabcdaabaabaabcaabaabaabcaabaabaabcaabaabaabcdeaabaabaabcaabaabaabcaabaabaabcaabaabaabcdaabaabaabcaabaabaabcaabaabaabcaabaabaab...

output:

75013838237868
17352127196790
18435593123029
59453124031842
69320849384091
17191835150296
10989209368636
11277496094302
49325334063534
82744384056372
50402212769634
77714097271276
24123534251919
1019327991978
9791176811923
45077398495657
16921358697596
46140159436459
87938135723225
51608242695868
31...

result:

ok 150000 lines

Test #25:

score: 0
Accepted
time: 55ms
memory: 14004kb

input:

150000 150000
aabaabcaabaabcdaabaabcaabaabcdeaabaabcaabaabcdaabaabcaabaabcdefaabaabcaabaabcdaabaabcaabaabcdeaabaabcaabaabcdaabaabcaabaabcdefgaabaabcaabaabcdaabaabcaabaabcdeaabaabcaabaabcdaabaabcaabaabcdefaabaabcaabaabcdaabaabcaabaabcdeaabaabcaabaabcdaabaabcaabaabcdefghaabaabcaabaabcdaabaabcaabaabcde...

output:

51790349532872
51552703284865
51639707133662
51628954389848
51326994357282
51147387034925
51562168321876
51361004657199
51615987780988
51345690787679
51558502009159
51512388090741
51446130081472
51424934077872
51530952726784
51279069272495
51541846195039
51394309708021
51769796479739
51763888860806
...

result:

ok 150000 lines

Test #26:

score: 0
Accepted
time: 56ms
memory: 14100kb

input:

150000 150000
aabaabaabcaabaabaabcdaabaabaabcaabaabaabcdaabaabaabcaabaabaabcdeaabaabaabcaabaabaabcdaabaabaabcaabaabaabcdaabaabaabcaabaabaabcdefaabaabaabcaabaabaabcdaabaabaabcaabaabaabcdaabaabaabcaabaabaabcdeaabaabaabcaabaabaabcdaabaabaabcaabaabaabcdaabaabaabcaabaabaabcdefaabaabaabcaabaabaabcdaabaaba...

output:

62738378528854
63240671067048
63109049690268
62930670790665
63128608767817
63154802293548
62903396261226
62691791732034
63072061751599
62678124397165
62854013020354
62810678615003
62432901249359
63266969650539
62868527107508
62984054065050
63323413497572
62820153495436
63041526771718
63072294192161
...

result:

ok 150000 lines

Test #27:

score: 0
Accepted
time: 61ms
memory: 13988kb

input:

150000 150000
aabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaabcaabaab...

output:

3685101344356853
3731861367894955
3751688492773431
3669019277489784
3728136168414795
3700443850676449
3692047336864334
3726615337010498
3732580406955496
3725834831382755
3756946026212108
3694602003701867
3711037467753390
3728247898408812
3756521839127576
3719104067223059
3695348388710118
37078393026...

result:

ok 150000 lines

Test #28:

score: -100
Wrong Answer
time: 66ms
memory: 12728kb

input:

140000 150000
fxyviddixxstasofjeupbirusknnatlsgfekhgstmobjultzbnwmjewbqbkytmhchesjazdroxqmttlkpqokolalnpsptkxmuzytkimsnlnestfrmhtpkbwaznvkzlkwrnffhnucjdgmqnyefpsphxuqyebnczbtvtuwlcarbwlgnyzwmzjfvqrmhxoksqkxjutlrpdlaoseppwtmdnyepfqfygmwidklhpmkmhfytnuryjpztgcdrnzuzpfghnkhfscdlilfhheqwfuvpvbbusgwkkfcj...

output:

149487386057
113862413777
134923719940
23972844956
47659718599
139322041316
103615068534
18033539404
123080750859
32686113656
5606831184
57587094874
140892925172
186120371655
43492728874
76110450160
33616517940
11400279908
24389732424
24320716400
13997903903
45968029724
169420809364
81943765124
1018...

result:

wrong answer 45255th lines differ - expected: '5216825478', found: '0'