UOJ Logo Universal Online Judge

UOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#579867#752. 【UNR #6】Border 的第五种求法Alex_Wei10062335ms536952kbC++ 175.6kb2022-08-26 22:09:532022-10-01 23:47:04

测评历史

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

  • [2022-10-01 23:47:04]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:62335ms
  • 内存:536952kb
  • [2022-09-21 04:20:00]
  • 系统更新:更新测评系统;移除 Java 7 和 Java 14;新增 Java 17;原 Java 7、Java 14 分别改用 Java 8、Java 17 测评
  • (https://vfleaking.blog.uoj.ac/blog/5450)
  • [2022-08-26 22:09:53]
  • 评测
  • 测评结果:100
  • 用时:63024ms
  • 内存:537008kb
  • [2022-08-26 22:09:53]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define fi first
#define se second
#define TIME 1e3 * clock() / CLOCKS_PER_SEC
bool Mbe;
constexpr int N = 1e6 + 5;
constexpr int K = 20;
constexpr int S = 26;
namespace SA {
  int n, lg[N], sa[N], rk[N], ork[N], buc[N], id[N], mi[K][N];
  bool cmp(int a, int b, int w) {return ork[a] == ork[b] && ork[a + w] == ork[b + w];}
  void build(int n, char *s) {
    SA::n = n;
    int m = 1 << 7, p = 0;
    for(int i = 1; i <= n; i++) buc[rk[i] = s[i]]++;
    for(int i = 1; i <= m; i++) buc[i] += buc[i - 1];
    for(int i = n; i; i--) sa[buc[rk[i]]--] = i;
    for(int w = 1; ; w <<= 1, m = p, p = 0) {
      for(int i = n - w + 1; i <= n; i++) id[++p] = i;
      for(int i = 1; i <= n; i++) if(sa[i] > w) id[++p] = sa[i] - w;
      memset(buc, 0, sizeof(buc));
      memcpy(ork, rk, sizeof(rk));
      p = 0;
      for(int i = 1; i <= n; i++) buc[rk[i]]++;
      for(int i = 1; i <= m; i++) buc[i] += buc[i - 1];
      for(int i = n; i; i--) sa[buc[rk[id[i]]]--] = id[i];
      for(int i = 1; i <= n; i++) rk[sa[i]] = cmp(sa[i - 1], sa[i], w) ? p : ++p;
      if(p == n) break;
    }
    for(int i = 2; i <= n; i++) lg[i] = lg[i >> 1] + 1;
    for(int i = 1, k = 0; i <= n; i++) {
      if(k) k--;
      while(s[i + k] == s[sa[rk[i] - 1] + k]) k++;
      mi[0][rk[i]] = k;
    }
    for(int i = 1; i <= lg[n]; i++)
      for(int j = 1; j + (1 << i) - 1 <= n; j++)
        mi[i][j] = min(mi[i - 1][j], mi[i - 1][j + (1 << i - 1)]);
  }
  int lcp(int x, int y) {
    if(x == y) return n - x + 1;
    if((x = rk[x]) > (y = rk[y])) swap(x, y);
    int d = lg[y - x++];
    return min(mi[d][x], mi[d][y - (1 << d) + 1]);
  }
  int lcp(int a, int b, int c, int d) {return min(min(b - a, d - c) + 1, lcp(a, c));}
}
namespace SAM {
  int cnt = 1, las = 1, s[N];
  int fa[N], len[N], son[N][S];
  int sz[N], lst[N], pos[N];
  void ins(int it) {
    int cur = ++cnt, p = las;
    las = cur;
    len[cur] = len[p] + 1;
    pos[len[cur]] = cur;
    sz[cur] = 1;
    s[len[cur]] = it;
    while(!son[p][it]) son[p][it] = cur, p = fa[p];
    if(!p) return fa[cur] = 1, void();
    int q = son[p][it];
    if(len[p] + 1 == len[q]) return fa[cur] = q, void();
    int cl = ++cnt;
    memcpy(son[cl], son[q], S << 2);
    fa[cl] = fa[q], fa[q] = fa[cur] = cl;
    len[cl] = len[p] + 1;
    while(son[p][it] == q) son[p][it] = cl, p = fa[p];
  }
  bool vis[N];
  ll f[N], g[N];
  vector<int> e[N], G[N], R[N];
  void calc(int id) {
    lst[id] = len[id];
    for(int it : e[id]) calc(it), sz[id] += sz[it], lst[id] = lst[it]; 
  }
  ll calcf(int id) {
    if(vis[id]) return f[id];
    vis[id] = f[id] = 1;
    for(int it : G[id]) f[id] += calcf(it);
    return f[id];
  }
  ll calcg(int id) {
    if(vis[id]) return g[id];
    vis[id] = g[id] = 1;
    for(int it : R[id]) g[id] += calcg(it);
    return g[id];
  }
  int to[N], tag[N];
  int dn, dfn[N], rev[N], top[N];
  int end[N], l[N], r[N];
  void dfs(int id, int tp) {
    rev[dfn[id] = ++dn] = id;
    top[id] = tp;
    end[id] = id;
    if(to[id]) dfs(to[id], tp), end[id] = end[to[id]];
    if(id == tp) r[id] = lst[end[id]], l[id] = r[id] - (dfn[end[id]] - dfn[id]) + 1;
    for(int it : G[id]) if(!dfn[it] && !tag[it]) dfs(it, it);
  }
  void build() {
    for(int i = 2; i <= cnt; i++) e[fa[i]].push_back(i);
    calc(1);
    for(int i = 1; i <= cnt; i++)
      for(int j = 0; j < S; j++)
        if(son[i][j]) {
          G[i].push_back(son[i][j]);
          R[son[i][j]].push_back(i);
        }
    for(int i = 1; i <= cnt; i++) calcf(i);
    memset(vis, 0, sizeof(vis));
    for(int i = 1; i <= cnt; i++) calcg(i);
    for(int i = 1; i <= cnt; i++) {
      for(int it : G[i])
        if(2 * f[it] > f[i] && 2 * g[i] > g[it])
          to[i] = it, tag[it] = 1;
    }
    dfs(1, 1);
  }
  vector<pii> get(int x, int y) {
    int p = 1;
    vector<pii> ret;
    while(1) {
      int L = l[top[p]], R = r[top[p]];
      L += dfn[p] - dfn[top[p]];
      if(L <= R) {
        int mat = SA::lcp(L, R, x, y);
        ret.push_back({dfn[p], dfn[p] + mat});
        x += mat, p = rev[dfn[p] + mat];
      }
      else ret.push_back({dfn[p], dfn[p]});
      if(x <= y) {
        if(to[p] == son[p][s[x]]) exit(0);
        p = son[p][s[x++]];
      }
      else break;
    }
    return ret;
  }
}
int n, q, f[N];
char s[N];
vector<pii> seq[N];
vector<int> buc[N];
ll ans[N];
struct BIT {
  ll c[N];
  void add(int x, int v) {while(x <= SAM::cnt) c[x] += v, x += x & -x;}
  ll query(int x) {ll s = 0; while(x) s += c[x], x -= x & -x; return s;}
  ll query(int l, int r) {return query(r) - query(l - 1);}
} tr;
void solve(int id) {
  if(id > 1) tr.add(SAM::dfn[id], f[SAM::sz[id]]);
  for(int it : buc[id]) for(pii I : seq[it]) ans[it] += tr.query(I.fi, I.se);
  for(int it : SAM::e[id]) solve(it);
  if(id > 1) tr.add(SAM::dfn[id], -f[SAM::sz[id]]);
}
bool Med;
int main() {
  fprintf(stderr, "%.3lf MB\n", (&Mbe - &Med) / 1048576.0);
  #ifdef ALEX_WEI
    FILE* IN = freopen("1.in", "r", stdin);
    FILE* OUT = freopen("1.out", "w", stdout);
  #endif
  ios::sync_with_stdio(0);
  cin >> n >> q >> s + 1;
  for(int i = 1; i <= n; i++) cin >> f[i];
  for(int i = 1; i <= n; i++) SAM::ins(s[i] - 'a');
  SA::build(n, s);
  SAM::build();
  for(int i = 1; i <= q; i++) {
    int l, r;
    cin >> l >> r;
    buc[SAM::pos[r]].push_back(i);
    seq[i] = SAM::get(l, r);
  }
  solve(1);
  for(int i = 1; i <= q; i++) cout << ans[i] << "\n";
  cerr << TIME << " ms\n";
  return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

小提示:点击横条可展开更详细的信息

Subtask #1:

score: 10
Accepted
total time: 263ms
memory: 133556kb

Test #1:

score: 10
Accepted
time: 23ms
memory: 133408kb

input:

5000 5000
eepeeeeeepeeeepeeeeeepeeeeeepeeeepeeeeeepeeeepeeeeeepeeeeeeeeepeeeeeepeeeepeeeeeepeeeeeepe...

output:

2131352162
2933078830
2136539150
2088734188
2638473445
943706199
1949949894
1339162016
2040731383
20...

result:

ok 5000 numbers

Test #2:

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

input:

5000 5000
xdxxxdxxdxxxdxeyrdlmrmxdxxxdxxdxxxdxxdxxxdxeyrdlmrmxdxxxdxxdxxxdxxdxxxdxeyrdlmrmxdxxxdxxdx...

output:

2804501064
259858766
1090684032
1225413636
1325696208
259858766
1418743052
2564305265
3186347863
297...

result:

ok 5000 numbers

Test #3:

score: 0
Accepted
time: 53ms
memory: 133360kb

input:

5000 5000
nuiowunnmiumrwvbnuiowunnnuiowunnsxesnuiowunnmiumrwvbnuiowunnnuiowunnnuiowunnmiumrwvbnuiowu...

output:

1617600194
1733192742
838223302
415138856
2081579293
1504720737
994893422
442936158
1795813208
13941...

result:

ok 5000 numbers

Test #4:

score: 0
Accepted
time: 36ms
memory: 133556kb

input:

5000 5000
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqsngoddknwxfdwgcoulbefejbpbrjeed...

output:

2658734832
6552380849
385540075
574293487
404015930
427090422
199934262
10262089609
1262238168
67598...

result:

ok 5000 numbers

Test #5:

score: 0
Accepted
time: 50ms
memory: 133416kb

input:

5000 5000
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc...

output:

57007361256
7402182222
369295301
1005405785
58567630210
48293349748
276809556
49710110705
1900412290...

result:

ok 5000 numbers

Test #6:

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

input:

5000 5000
ejejnuhptwyyrnpvwxtwbyjstbrynmysfikhlxmbdgjvrhbcbwghajgbxpejejejejgwijoegkxnhacjfwhochzgox...

output:

5405887
2368588381
1014424774
1210171290
1210171290
2069192327
240124803
875753959
1421905268
787177...

result:

ok 5000 numbers

Subtask #2:

score: 10
Accepted
total time: 10780ms
memory: 536952kb

Test #7:

score: 10
Accepted
time: 3618ms
memory: 536952kb

input:

500000 500000
abaaabbabbaaaabababaaaabaaabbbbbbababaabbabbbabbaabaabbbbbaaabbbabaaabbbbababababbaaaa...

output:

2404252631
3378394017
1466764793
2209720985
1673137105
379318126
855844855
757534595
991161415
15404...

result:

ok 500000 numbers

Test #8:

score: 0
Accepted
time: 3610ms
memory: 536636kb

input:

500000 500000
bbababaabbaaabbbbabaaababbbbaabbbbbaaabbaabaaababbababbaababbaabaaaababbbabaabababbbaa...

output:

1639393608
1554388406
1471956662
1471956662
1337916865
1569406083
1900880762
614285943
2017785385
10...

result:

ok 500000 numbers

Test #9:

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

input:

500000 500000
ababbbbaaaabbbaabbbbbaababbbbabbbbbaababaaaabbaaaaabaaabaaaabbbbbbbaaabaaababbaabbabbb...

output:

852121079
2660105798
698256529
575972987
1110688390
1078517109
1170557446
533639631
40332739
1016682...

result:

ok 500000 numbers

Subtask #3:

score: 25
Accepted
total time: 4758ms
memory: 208348kb

Test #10:

score: 25
Accepted
time: 311ms
memory: 205764kb

input:

100000 100000
aidtyuzrhyjyvosxpqwaaaidtyuzrhyjyvosxpqwaaaaidtyuzrhyjyvosxpqwaaaidtyuzrhyjyvosxpqwaaa...

output:

7
2
18663
16959
12463047
12487347
254
757
853
65434
209
8099
4434
87977
8425441
2122
5281
2
3651
117...

result:

ok 100000 numbers

Test #11:

score: 0
Accepted
time: 265ms
memory: 198296kb

input:

100000 100000
nhvwvsndnzqqczrkmexdnhvwvsndnzqqczrkmexdnhvwvsndnzqqczrkmexdnhvwvsndnzqqczrkmexdnhvwvs...

output:

2314
1022
252907
3080
1043
440122
456947
195268340
12
193753047
383553
7192
474969
148797
170507279
...

result:

ok 100000 numbers

Test #12:

score: 0
Accepted
time: 285ms
memory: 203452kb

input:

100000 100000
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj...

output:

370
54
459
21
497113
495231
3655618
4
7
505052
96
251
4764
1912709
284
2001617
4092
3
533
186
423998...

result:

ok 100000 numbers

Test #13:

score: 0
Accepted
time: 312ms
memory: 204344kb

input:

100000 100000
ffftffffftfffftfffftfffftffffffftffcamiftnrdmbfftffffftfffffffffffffffffffftffcamiftnr...

output:

6
24331
3
1303
2222
4
86
11685
102
45843387
16581
4
290
13
2700
175
301
427
83
16487
7496
3
12559
31...

result:

ok 100000 numbers

Test #14:

score: 0
Accepted
time: 309ms
memory: 204672kb

input:

100000 100000
vvvvfpjzvvvvfpjzjhnzddempvvvvvvvvfpjzjhnzddempvvvvvvvvfpjzvvvvfpjzvvvvfpjzvvvvfpjzvvvv...

output:

12848
2443
32975
137
176
11227
9
5
301
112324
3
26783
21007
1516
1460
863
61
6089
47779
15003
131
19...

result:

ok 100000 numbers

Test #15:

score: 0
Accepted
time: 326ms
memory: 205944kb

input:

100000 100000
hddzczdehddzczdhddzczdehddzczdhddzczdehddzczdhddzczdehddzczdhddzczdehddzczdhddzczdehdd...

output:

7247
26500
18887
1080
37084
12660
49299
20148
17475
48470
6781
21
12660
40049
11767
51820
18073
4180...

result:

ok 100000 numbers

Test #16:

score: 0
Accepted
time: 285ms
memory: 204116kb

input:

100000 100000
pppppppepppppppzecupppppppeppppppppppppppepppppppzecupppppppeppppppppppppppppppppepppp...

output:

343435
8900
421811
6710
342552
344257
2029
382356
227456
161009
83881
232485
5510
159699
339921
9323...

result:

ok 100000 numbers

Test #17:

score: 0
Accepted
time: 344ms
memory: 208348kb

input:

100000 100000
edvnqkcxedededvnqkcxedededvnqkcxededvnqkcxededvnqkcxedededvnqkcxededvnqkcxededvnqkcxed...

output:

8320
2059
14526
29405
8316
35512
50219
4186
25060
6
8317
9364
4
2
8320
8319
1
27115
8323
8439
8318
1...

result:

ok 100000 numbers

Test #18:

score: 0
Accepted
time: 196ms
memory: 178468kb

input:

100000 100000
zhmenzmsmszhmenzzhmenzmsmszhmenzzhmenzmsmszhmenzzhzhmenzmsmszhmenzzhmenzmsmszhmenzzhme...

output:

1600495
1918800
1684179
1779544
1744459
1623829
2028594
1916747
216747
75675
197440
1203520
2013569
...

result:

ok 100000 numbers

Test #19:

score: 0
Accepted
time: 200ms
memory: 178396kb

input:

100000 100000
stswststswststswststswststswststswststswststswstststswststswststswststswststswststswst...

output:

1517224
1399097
1250534
2058875
105472
933814
137938
2044739
1765848
1943743
1857728
1964493
1581890...

result:

ok 100000 numbers

Test #20:

score: 0
Accepted
time: 167ms
memory: 177212kb

input:

100000 100000
mekfqwmctfycdkqfagmekfqwmmekfqwmctfycdkqfagmekfqwmmekfqwmctfycdkqfagmekfqwmmekfqwmctfy...

output:

7895169
4359650
131439
3372639
7970625
7087425
7139359
7970505
3597939
7296922
7997994
7975634
70293...

result:

ok 100000 numbers

Test #21:

score: 0
Accepted
time: 225ms
memory: 198368kb

input:

100000 100000
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo...

output:

72419
34349
90525
85201
1989069
73245
67865
76449
77847
85272
65665
75240
77847
80149
79610
1958335
...

result:

ok 100000 numbers

Test #22:

score: 0
Accepted
time: 219ms
memory: 197112kb

input:

100000 100000
zzhicdodzzzzhicdodzzzzhicdodzzzzhicdodzzzzhicdodzzzzhicdodzzzzhicdodzzzzhicdodzzzzhicd...

output:

46460884
270674
339335
36504194
45530472
46766669
423865
397574
482847
496284
466347
427690
462372
3...

result:

ok 100000 numbers

Test #23:

score: 0
Accepted
time: 240ms
memory: 198788kb

input:

100000 100000
mmmmmmmmmmmmmmmmneetdboveerwymmmmmmmmmmmmmmmmryxajmdqhxmmmmmmmmmmmmmmmmneetdboveerwymm...

output:

91923
4554
19936496
4389
300
15897
3739
4209
4872
3070
4940
4840
3304
20797
26981
12724
4130
88152
2...

result:

ok 100000 numbers

Test #24:

score: 0
Accepted
time: 235ms
memory: 195532kb

input:

100000 100000
nnnnvfaxnnnnvmhpgxgfnmuwdhqwnnnnvfaxnnnnnrddvhrtnrmnrtwddginnnnnvfaxnnnnvmhpgxgfnmuwdh...

output:

18647
10309
14535
20859
18910
26609
31822
16414
20747
4169
10230
19404
27179
19270
19434
26789
16672...

result:

ok 100000 numbers

Test #25:

score: 0
Accepted
time: 267ms
memory: 195372kb

input:

100000 100000
fkcfuapbfkcfkruaefspkawfhaliltzvrskwkxfjssfswujhwuwndbeiamspqxhzltqjgggtwjdbzezisfiavl...

output:

6
230
19
233
236
5687
28
3642
7
4148
33
2
4195
142
160
9
3811
3
6111
93
29
4
143
93
7
3
6
142
3
12
9...

result:

ok 100000 numbers

Test #26:

score: 0
Accepted
time: 226ms
memory: 189884kb

input:

100000 100000
ghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghgh...

output:

49353293
270772938
15547899
72236047
18136341
22033472
272368986
110444997
227453325
180906932
63980...

result:

ok 100000 numbers

Test #27:

score: 0
Accepted
time: 150ms
memory: 176940kb

input:

100000 100000
ghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghgh...

output:

1210797347
1247105264
26112450
601034622
1080648997
1245565409
1228799130
1012023347
1236585480
8377...

result:

ok 100000 numbers

Test #28:

score: 0
Accepted
time: 196ms
memory: 196592kb

input:

100000 100000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

4047164954
4139421981
2526420192
3963756426
4194181511
2666191679
3733389102
3001181106
4194269037
4...

result:

ok 100000 numbers

Subtask #4:

score: 15
Accepted
total time: 4738ms
memory: 208528kb

Test #29:

score: 15
Accepted
time: 308ms
memory: 205812kb

input:

100000 100000
aidtyuzrhyjyvosxpqwaaaidtyuzrhyjyvosxpqwaaaaidtyuzrhyjyvosxpqwaaaidtyuzrhyjyvosxpqwaaa...

output:

611240532
1001276051
1742222942127
2478951336537
1414743008
1631786514
791493655
4052435444
28290424...

result:

ok 100000 numbers

Test #30:

score: 0
Accepted
time: 284ms
memory: 198384kb

input:

100000 100000
nhvwvsndnzqqczrkmexdnhvwvsndnzqqczrkmexdnhvwvsndnzqqczrkmexdnhvwvsndnzqqczrkmexdnhvwvs...

output:

16181333816
6835748056153
9375711040
381132833
1749900793
1723807976
31713052256
401454061
941634534...

result:

ok 100000 numbers

Test #31:

score: 0
Accepted
time: 262ms
memory: 203388kb

input:

100000 100000
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj...

output:

437479821920
7159186412
1048628411
2184056919
2300033373
923475983289
1112519145
2587126402
30035363...

result:

ok 100000 numbers

Test #32:

score: 0
Accepted
time: 310ms
memory: 204176kb

input:

100000 100000
ffftffffftfffftfffftfffftffffffftffcamiftnrdmbfftffffftfffffffffffffffffffftffcamiftnr...

output:

750463310
1660986151
1782124074
1416519544
1827748280
404730798
2267400298
2486269679319
1098821383
...

result:

ok 100000 numbers

Test #33:

score: 0
Accepted
time: 312ms
memory: 204820kb

input:

100000 100000
vvvvfpjzvvvvfpjzjhnzddempvvvvvvvvfpjzjhnzddempvvvvvvvvfpjzvvvvfpjzvvvvfpjzvvvvfpjzvvvv...

output:

18526401234
1058216816
40493635
1553156541
770715747
3074526852
8870794894
2047506656
1345414347
199...

result:

ok 100000 numbers

Test #34:

score: 0
Accepted
time: 312ms
memory: 205936kb

input:

100000 100000
hddzczdehddzczdhddzczdehddzczdhddzczdehddzczdhddzczdehddzczdhddzczdehddzczdhddzczdehdd...

output:

1271266435
1866114325
74725239
1920734164
906736335
1089571557
1811203318
626463197
2374891437
12187...

result:

ok 100000 numbers

Test #35:

score: 0
Accepted
time: 280ms
memory: 204220kb

input:

100000 100000
pppppppepppppppzecupppppppeppppppppppppppepppppppzecupppppppeppppppppppppppppppppepppp...

output:

1382199385
4489041410
5478328641
2698331934
2247289327
7806850533
5054414185
3587448032
3355538683
1...

result:

ok 100000 numbers

Test #36:

score: 0
Accepted
time: 357ms
memory: 208528kb

input:

100000 100000
edvnqkcxedededvnqkcxedededvnqkcxededvnqkcxededvnqkcxedededvnqkcxededvnqkcxededvnqkcxed...

output:

468384470
624130714
1916324725
3053113262
980608657
1631435316
1247079695
1086578239
358317339
79197...

result:

ok 100000 numbers

Test #37:

score: 0
Accepted
time: 197ms
memory: 178404kb

input:

100000 100000
zhmenzmsmszhmenzzhmenzmsmszhmenzzhmenzmsmszhmenzzhzhmenzmsmszhmenzzhmenzmsmszhmenzzhme...

output:

562980350216
989451200349
37388766341
446012577195
536072861364
652652806349
630925874768
8452727974...

result:

ok 100000 numbers

Test #38:

score: 0
Accepted
time: 191ms
memory: 178296kb

input:

100000 100000
stswststswststswststswststswststswststswststswstststswststswststswststswststswststswst...

output:

916925902850
926221053560
789617463269
997522631645
710654572717
475608207870
270869430336
404317098...

result:

ok 100000 numbers

Test #39:

score: 0
Accepted
time: 185ms
memory: 177276kb

input:

100000 100000
mekfqwmctfycdkqfagmekfqwmmekfqwmctfycdkqfagmekfqwmmekfqwmctfycdkqfagmekfqwmmekfqwmctfy...

output:

1104880716425
1688443287923
1315254063800
1887028913006
560199707994
626878194457
1190465881882
4510...

result:

ok 100000 numbers

Test #40:

score: 0
Accepted
time: 230ms
memory: 198188kb

input:

100000 100000
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo...

output:

118615814926
138609753135
848776960182
105140855575
17247880967
123801928862
160097846041
1100056821...

result:

ok 100000 numbers

Test #41:

score: 0
Accepted
time: 217ms
memory: 197152kb

input:

100000 100000
zzhicdodzzzzhicdodzzzzhicdodzzzzhicdodzzzzhicdodzzzzhicdodzzzzhicdodzzzzhicdodzzzzhicd...

output:

399297169146
220184954287
3287220054477
334145622556
3885034438134
1432302006128
337454382489
282927...

result:

ok 100000 numbers

Test #42:

score: 0
Accepted
time: 226ms
memory: 198764kb

input:

100000 100000
mmmmmmmmmmmmmmmmneetdboveerwymmmmmmmmmmmmmmmmryxajmdqhxmmmmmmmmmmmmmmmmneetdboveerwymm...

output:

37056683757
9277179343
48628052589
35663236845
40424627390
23513797135
39570973396
27254003126
22827...

result:

ok 100000 numbers

Test #43:

score: 0
Accepted
time: 225ms
memory: 195464kb

input:

100000 100000
nnnnvfaxnnnnvmhpgxgfnmuwdhqwnnnnvfaxnnnnnrddvhrtnrmnrtwddginnnnnvfaxnnnnvmhpgxgfnmuwdh...

output:

81082160664
91244212164
79382232161
78221002537
97020150415
82428718037
87254211756
39351135214
7801...

result:

ok 100000 numbers

Test #44:

score: 0
Accepted
time: 275ms
memory: 195096kb

input:

100000 100000
fkcfuapbfkcfkruaefspkawfhaliltzvrskwkxfjssfswujhwuwndbeiamspqxhzltqjgggtwjdbzezisfiavl...

output:

1693922570
2730572551
1854107655
480824432
1854107655
742665816
742665816
1371148024
2565610884
1909...

result:

ok 100000 numbers

Test #45:

score: 0
Accepted
time: 228ms
memory: 189884kb

input:

100000 100000
ghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghgh...

output:

4834961588065
7459850358138
6802500363716
3400377477319
3309596739152
796264577953
4930972298784
131...

result:

ok 100000 numbers

Test #46:

score: 0
Accepted
time: 170ms
memory: 176736kb

input:

100000 100000
ghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghgh...

output:

8481133065224
13066222376068
23284510048810
523047788434
8162147412520
14009225927466
6853722476403
...

result:

ok 100000 numbers

Test #47:

score: 0
Accepted
time: 169ms
memory: 196780kb

input:

100000 100000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

25234836819523
39112482895298
41629984611170
37187564229731
24639255591384
38007300422053
2381722169...

result:

ok 100000 numbers

Subtask #5:

score: 40
Accepted
total time: 41796ms
memory: 525584kb

Test #48:

score: 40
Accepted
time: 1748ms
memory: 483448kb

input:

500000 500000
gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg...

output:

2241717123
854827581
3673135
3673135
1321654170
2694130953
442094117
988290943
522853521
2331025812
...

result:

ok 500000 numbers

Test #49:

score: 0
Accepted
time: 1828ms
memory: 502264kb

input:

500000 500000
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc...

output:

2022439090
1308502707
781793037693
1523628022
1085932815
660540177
1360234932
1547620279935
57308113...

result:

ok 500000 numbers

Test #50:

score: 0
Accepted
time: 2107ms
memory: 514868kb

input:

500000 500000
iuslfoiuslfoiuslfoiuslfoiuslfoiuslfoiuiuslfoiuslfoiuslfoiuslfoiuslfoiuiuslfoiuiuslfoiu...

output:

1589405403
1709303546
1782286307
16808713443248
2278174828
553744629
1870504981
2648130141
252728882...

result:

ok 500000 numbers

Test #51:

score: 0
Accepted
time: 2274ms
memory: 525584kb

input:

500000 500000
vkpsvzvfzsolicqdavkpsvvkpsvzvfzsolicqdavkpsvvvkpsvvkpsvzvfzsolicqdavkpsvhilkbzvkpsvzvf...

output:

178964783
178964783
1020622179
1597859494
2770596510
1817193950
1507249751
877737313
900242997
19715...

result:

ok 500000 numbers

Test #52:

score: 0
Accepted
time: 2158ms
memory: 524756kb

input:

500000 500000
ovhnibyojiegzojzzfnovhnibyojiegzojzzfntddaeovhovhnibyojiegzojzzfntddaeovhovhnibyojiegz...

output:

2136101098
407177149
2941736788
2785474674
1281279273
798749469
2165162062
1923925182
956297299
9720...

result:

ok 500000 numbers

Test #53:

score: 0
Accepted
time: 1797ms
memory: 492228kb

input:

500000 500000
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

3833280490
15747818401
23010938651985
3525714117
16221284345227
246666571216
3721920593
1073882709
1...

result:

ok 500000 numbers

Test #54:

score: 0
Accepted
time: 1818ms
memory: 499128kb

input:

500000 500000
jorjojorjojjorjojorjojorjojbccjvmlbwzfsgahoknjorjojorjojorjojjorjojorjojorjojbccjvmlbw...

output:

765937655844
22500596523
1743979370
21258172186
23064327244
4852637682
13626911837
554628713
2399345...

result:

ok 500000 numbers

Test #55:

score: 0
Accepted
time: 1798ms
memory: 477268kb

input:

500000 500000
mamaokwjcpmmammamaokwjcpmmammamaokwjcpmmammamaokmamaokwjcpmmammamaokwjcpmmammamaokwjcp...

output:

1095319818
1189245998
201111888751
2340944203
2231043121
592682931
1952769460
1319720328
1189245998
...

result:

ok 500000 numbers

Test #56:

score: 0
Accepted
time: 1843ms
memory: 498740kb

input:

500000 500000
mmegupvogkblaksfqqvxqpxhpjoduyjhoqqtufjqbocroishtjtklunaffngwiboueljbpdrjdptswvoyqrijs...

output:

12872668124
929754603
5439785345
4964495368
7818511667
165232706076
672089891
2697113130
1202383141
...

result:

ok 500000 numbers

Test #57:

score: 0
Accepted
time: 1860ms
memory: 503576kb

input:

500000 500000
wwwwwwszwswmrrnawwwwwwwwwwwwszwswmrrnawwwwwwwwwwwwszwswmrrnawwwwwwwwwwwwszwswmrrnawwww...

output:

18977362
18108734716420
922299557
1068156244
2119494402
771814923
757412325
1347847209
4860250904
44...

result:

ok 500000 numbers

Test #58:

score: 0
Accepted
time: 2070ms
memory: 520500kb

input:

500000 500000
memelmelmelmmelmelmelmmelmelmelmmelmelmelmmelmelmelmmelmelmelmmelmelmelmmelmelmelmmelm...

output:

1180514007
3805628737
1516860184
1912832487
2910833666
1598984017
1671077374
886284963
1331318533
76...

result:

ok 500000 numbers

Test #59:

score: 0
Accepted
time: 1350ms
memory: 374036kb

input:

500000 500000
sssdodiarrwevwmcuaqkssbxczqhxmruuqvyjpgrejvybpaefjssssssdodiarrwevwmcuaqkssbxczqhxmruu...

output:

498022750299
277117685179
204934153788
8701153999
471482362300
416827454506
226594579287
40201177992...

result:

ok 500000 numbers

Test #60:

score: 0
Accepted
time: 1449ms
memory: 479928kb

input:

500000 500000
qqjtaefpbzcelbirsmdzhyxbksqvhudcaysicurmlnpsuzoxghcjwuycdtccnmiomyfofkfcxwfjuztxcgasto...

output:

22157015726
23415594642163
28171939789
24619154477310
42365893520
22152521579198
29668838221
1114238...

result:

ok 500000 numbers

Test #61:

score: 0
Accepted
time: 1613ms
memory: 490800kb

input:

500000 500000
rrrrrrrrrrrrrroufxduaybkdmxaxavybbhndhgdeqipmihhhhvgblytvwxkdibtocxlshksweljrxcnhffspo...

output:

4819118886
2346443391
21842423329
5350390220
2669105576
3579976962
2346968090928
4449558130
44495581...

result:

ok 500000 numbers

Test #62:

score: 0
Accepted
time: 1642ms
memory: 485952kb

input:

500000 500000
wayqwayqwhlpmzfqtibfwbqoordxabcjghnbuwayqwayqwwayqwayqwhlpmzfqtibfwbqoordxabcjghnbuway...

output:

2267531316
3582487869
1039587925
1880751626
1459185108
1039587925
1735538488
8014213442
932595660
19...

result:

ok 500000 numbers

Test #63:

score: 0
Accepted
time: 1468ms
memory: 490160kb

input:

500000 500000
cpcpcpcpccpcpcpcpccpcpcpcpccpcpcpmluvafqtatojjnzpemyjnghwlwqxgtbwaxcpcpcpcpccpcpcpcpcc...

output:

7883929069
19162836240
23592677165
22058317014
16829663152
407042470641
13353505845
17470040867
9140...

result:

ok 500000 numbers

Test #64:

score: 0
Accepted
time: 1692ms
memory: 482312kb

input:

500000 500000
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvktcwohrymomvcwdiazulipvvvvvvvvvvvvvvvvvvvvvvvvv...

output:

2822150288
972639824
1723343921
2709773082
4914681079
9807137572
1466162188
2017574852
1723343921
21...

result:

ok 500000 numbers

Test #65:

score: 0
Accepted
time: 1381ms
memory: 480424kb

input:

500000 500000
tttttttbttttttttttttttbttttttttttttttbttttttttttttttbttttttttttttttbttttttttttttttbttt...

output:

165918983959
227740675112
131245513310
98131441519
63210081981
213577964116
129573102148
24606570971...

result:

ok 500000 numbers

Test #66:

score: 0
Accepted
time: 1164ms
memory: 373256kb

input:

500000 500000
oopjnpmokoooopjnpmokoooopjnpmokoooopjnpmokoooopjnpoopjnpmokoooopjnpmokoooopjnpmokoooop...

output:

4396775142828
4434793838450
3957865882548
3816208543215
1373016630307
4185692627782
1799658349610
49...

result:

ok 500000 numbers

Test #67:

score: 0
Accepted
time: 1169ms
memory: 379016kb

input:

500000 500000
rrcrrrcrrrcrrrrcrrrcrrrcrrrrcrrrcrrrcrrrrcrrrcrrrcrrcrrrcrrrcrrrrcrrrcrrrcrrrrcrrrcrrr...

output:

2714359386047
2865167637192
1863710978229
2559641945614
165310103226
4330347698679
3863592236607
480...

result:

ok 500000 numbers

Test #68:

score: 0
Accepted
time: 1373ms
memory: 476460kb

input:

500000 500000
stvouzfjomlbwhhfjvstvouzfjomlbwhhfjvstvouzfjomlbwhstvouzfjomlbwhhfjvstvouzfjomlbwhhfjv...

output:

31653789256
487974790825
262059573284
300070406748
189093795274
359331527042
194371137875
890400856
...

result:

ok 500000 numbers

Test #69:

score: 0
Accepted
time: 1341ms
memory: 483064kb

input:

500000 500000
ldqepomyimruwyhiozhyzclysxmxmozpxifkxpsldqepomyimrldqepomyimruwyhiozhyzclysxmxmozpxifk...

output:

32411462594
23076955892
46804773221
37582418543
2123378347332
8679331325
5995320535
25403977896
3531...

result:

ok 500000 numbers

Test #70:

score: 0
Accepted
time: 1515ms
memory: 485568kb

input:

500000 500000
dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd...

output:

1294472967
3258551475
5002790844
6301975849
5346668198
6134082508
1640299099
13910251253
8347508213
...

result:

ok 500000 numbers

Test #71:

score: 0
Accepted
time: 802ms
memory: 364012kb

input:

500000 500000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

198846592498622
3170694489049
92106893615064
132591403949593
163120532051281
116986728037358
4463249...

result:

ok 500000 numbers

Test #72:

score: 0
Accepted
time: 1254ms
memory: 472708kb

input:

500000 500000
ghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghgh...

output:

2560280087981
46125847577872
58826275775962
833897892742
50589063836814
19167260664632
6070285646350...

result:

ok 500000 numbers

Test #73:

score: 0
Accepted
time: 1282ms
memory: 488808kb

input:

500000 500000
ghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghgh...

output:

493136609929
241372655049
455836634517
655123942425
1166819586535
2332165897442
3657187491649
386546...

result:

ok 500000 numbers

Extra Test:

score: 0
Extra Test Passed