QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#784010 | #9639. 字符串 | Arghariza | 100 ✓ | 924ms | 188052kb | C++14 | 3.5kb | 2024-11-26 12:39:15 | 2024-11-26 12:39:16 |
Judging History
answer
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define R(i, x, y) for (int i = (x); i >= (y); i--)
#define FIO(FILE) freopen(FILE".in", "r", stdin), freopen(FILE".out", "w", stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
bool Mbe;
const int N = 5e5 + 5;
const int M = 20;
int n, m, ans[N];
char s[N];
struct SA {
int len;
int sa[N], id[N], rk[N], ct[N], ht[N], f[N][M];
void rst() {
memset(ct, 0, sizeof(int) * (len + 1));
F (i, 1, n) {
ct[rk[i]]++;
}
F (i, 1, len) {
ct[i] += ct[i - 1];
}
R (i, n, 1) {
sa[ct[rk[id[i]]]--] = id[i];
}
}
void init() {
len = 30;
F (i, 1, n) {
id[i] = i;
rk[i] = s[i] - 'a' + 1;
}
rst();
for (int w = 1, p = 0; w <= n && p != n; w <<= 1, len = p) {
p = 0;
F (i, n - w + 1, n) {
id[++p] = i;
}
F (i, 1, n) {
if (sa[i] > w) {
id[++p] = sa[i] - w;
}
}
rst();
swap(rk, id);
rk[sa[1]] = p = 1;
F (i, 2, n) {
rk[sa[i]] = (id[sa[i]] == id[sa[i - 1]] && id[sa[i] + w] == id[sa[i - 1] + w]) ? p : ++p;
}
}
int j = 0;
F (i, 1, n) {
if (j) {
j--;
}
while (s[i + j] == s[sa[rk[i] - 1] + j]) {
j++;
}
ht[rk[i]] = j;
}
F (i, 1, n) {
f[i][0] = ht[i];
}
F (j, 1, __lg(n)) {
F (i, 1, n - (1 << j) + 1) {
f[i][j] = min(f[i][j - 1], f[i + (1 << (j - 1))][j - 1]);
}
}
}
int lcp(int l, int r) {
if (l == r) {
return n - l + 1;
}
int _l = rk[l], _r = rk[r];
l = min(_l, _r) + 1, r = max(_l, _r);
int len = __lg(r - l + 1);
return min(f[l][len], f[r - (1 << len) + 1][len]);
}
} A, B;
struct Q {
int x, o, i;
Q () { }
Q (int _x, int _o, int _i) : x(_x), o(_o), i(_i) { }
};
struct BIT {
int t[N];
int lb(int x) {
return x & -x;
}
void u(int x, int y, int o) {
for (int i = x; i && i <= n; i += o * lb(i)) {
t[i] += y;
}
}
int q(int x, int o) {
int res = 0;
for (int i = x; i && i <= n; i += o * lb(i)) {
res += t[i];
}
return res;
}
} T1, T2;
vector<Q> up[N];
vector<Q> qa[N], qb[N];
void solve() {
cin >> n >> n >> m >> (s + 1);
A.init(), reverse(s + 1, s + n + 1);
B.init();
F (i, 1, m) {
int l, r;
cin >> l >> r;
qa[l + 1].eb(Q(A.rk[l], 1, i));
qa[l + r + 1].eb(Q(A.rk[l], -1, i));
qb[l].eb(Q(r, 1, i));
}
R (i, n, 1) {
T1.u(A.rk[i], 1, -1);
for (Q j : qa[i]) {
int x = j.x, o = j.o, id = j.i;
ans[id] += o * T1.q(x, 1);
}
}
F (d, 1, n >> 1) {
for (int i = d, j = 2 * d; j <= n; i += d, j += d) {
int lcp = min(A.lcp(i, j), d);
int lcs = min(B.lcp(n - i + 2, n - j + 2), d - 1);
if (lcp + lcs >= d) {
int l = i - lcs, r = i + lcp - d;
if (A.rk[l] >= A.rk[l + d]) {
continue;
}
up[l].eb(Q(d, 1, 0));
up[r + 1].eb(Q(d, -1, 0));
}
}
}
F (i, 1, n) {
for (Q j : up[i]) {
int x = j.x, o = j.o;
// assert(x <= n && x >= 1);
T2.u(x, o, 1);
}
for (Q j : qb[i]) {
int x = j.x, id = j.i;
// assert(x <= n && x >= 1);
ans[id] -= T2.q(x, -1);
}
}
F (i, 1, m) {
cout << ans[i] << '\n';
}
}
bool Med;
int main() {
// FIO("");
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cerr << (&Mbe - &Med) / 1048576.0 << " MB\n";
int T = 1;
// cin >> T;
while (T--) solve();
cerr << (int)(1e3 * clock() / CLOCKS_PER_SEC) << " ms\n";
return 0;
}
詳細信息
Subtask #1:
score: 20
Accepted
Test #1:
score: 20
Accepted
time: 17ms
memory: 69896kb
input:
1 5000 5000 babbbabbbaabbaaabaaababbbaaabbabbbaabbabbabbbaaaabbaaabbbbbaabbbaababbaaaabaababbabbbbbbababaaaaabaabbaabbabaaababbbbaaababaabbbababbbbaaaaaabbaaaaaabaabbbbaabbbbbbabbabbbaabbabbbabbabbabababbaabbaabbababbaaaaabbabaaabbbabbbabaabbabbabaaaaaabbaababbbababbabbaababaababbbbbabbbbaabaabbaabb...
output:
943 901 504 8 1599 40 650 268 32 324 1010 686 10 225 71 40 48 306 260 498 1487 969 107 20 57 14 200 167 10 108 506 126 440 69 171 52 59 271 13 429 83 415 911 101 694 893 1099 457 585 129 295 54 43 516 405 1200 292 729 253 7 25 927 11 245 23 528 54 469 245 79 6 46 403 105 76 735 0 0 320 48 559 1272 1...
result:
ok 5000 lines
Test #2:
score: 20
Accepted
time: 8ms
memory: 71824kb
input:
1 5000 5000 babbbabbbaabbaaabaaababbbaaabbabbbaabbabbabbbaaaabbaaabbbbbaabbbaababbaaaabaababbabbbbbbababaaaaabaabbaabbabaaababbbbaaababaabbbababbbbaaaaaabbaaaaaabaabbbbaabbbbbbabbabbbaabbabbbabbabbabababbaabbaabbababbaaaaabbabaaabbbabbbabaabbabbabaaaaaabbaababbbababbabbaababaababbbbbabbbbaabaabbaabb...
output:
943 901 504 8 1599 40 650 268 32 324 1010 686 10 225 71 40 48 306 260 498 1487 969 107 20 57 14 200 167 10 108 506 126 440 69 171 52 59 271 13 429 83 415 911 101 694 893 1099 457 585 129 295 54 43 516 405 1200 292 729 253 7 25 927 11 245 23 528 54 469 245 79 6 46 403 105 76 735 0 0 320 48 559 1272 1...
result:
ok 5000 lines
Test #3:
score: 20
Accepted
time: 17ms
memory: 68944kb
input:
1 5000 5000 babbbabbbaabbaaabaaababbbaaabbabbbaabbabbabbbaaaabbaaabbbbbaabbbaababbaaaabaababbabbbbbbababaaaaabaabbaabbabaaababbbbaaababaabbbababbbbaaaaaabbaaaaaabaabbbbaabbbbbbabbabbbaabbabbbabbabbabababbaabbaabbababbaaaaabbabaaabbbabbbabaabbabbabaaaaaabbaababbbababbabbaababaababbbbbabbbbaabaabbaabb...
output:
943 901 504 8 1599 40 650 268 32 324 1010 686 10 225 71 40 48 306 260 498 1487 969 107 20 57 14 200 167 10 108 506 126 440 69 171 52 59 271 13 429 83 415 911 101 694 893 1099 457 585 129 295 54 43 516 405 1200 292 729 253 7 25 927 11 245 23 528 54 469 245 79 6 46 403 105 76 735 0 0 320 48 559 1272 1...
result:
ok 5000 lines
Test #4:
score: 20
Accepted
time: 15ms
memory: 69808kb
input:
1 5000 5000 babbbabbbaabbaaabaaababbbaaabbabbbaabbabbabbbaaaabbaaabbbbbaabbbaababbaaaabaababbabbbbbbababaaaaabaabbaabbabaaababbbbaaababaabbbababbbbaaaaaabbaaaaaabaabbbbaabbbbbbabbabbbaabbabbbabbabbabababbaabbaabbababbaaaaabbabaaabbbabbbabaabbabbabaaaaaabbaababbbababbabbaababaababbbbbabbbbaabaabbaabb...
output:
943 901 504 8 1599 40 650 268 32 324 1010 686 10 225 71 40 48 306 260 498 1487 969 107 20 57 14 200 167 10 108 506 126 440 69 171 52 59 271 13 429 83 415 911 101 694 893 1099 457 585 129 295 54 43 516 405 1200 292 729 253 7 25 927 11 245 23 528 54 469 245 79 6 46 403 105 76 735 0 0 320 48 559 1272 1...
result:
ok 5000 lines
Test #5:
score: 20
Accepted
time: 11ms
memory: 67988kb
input:
1 5000 5000 aababaababbbbabbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabaababaab...
output:
1 9 558 232 344 137 258 39 21 98 25 997 127 132 1017 11 34 360 24 103 26 98 65 23 254 27 752 1124 164 89 8 365 103 108 19 58 1 272 626 20 70 94 14 275 1072 103 254 29 1 89 14 1 217 267 490 355 590 88 216 403 103 812 1160 32 504 104 371 618 89 1562 92 186 186 535 2046 519 43 263 346 154 72 885 397 38...
result:
ok 5000 lines
Subtask #2:
score: 10
Accepted
Test #6:
score: 10
Accepted
time: 87ms
memory: 92404kb
input:
2 100000 100000 aabaababababbabbbbaaaaabbabaaaaabaaaabbbbaaaaaabbabbaaabaababaaaaaaabaabbbabbaabaabaababbbbbbaaabbabbaabaabbaaabbbaaaabaabbaababbaaabbabbababaaababaababbabbbababbaaaaababbaaaabbaaabbbbabaaabbbbaaaabbabbabbaaaaaabbabbbaaaabbaabbbaaabaabaabbbaaabaababaabaaabbaaabbbaaababaabbbabaabbaaab...
output:
336 1019 15080 9970 20317 696 8784 3375 387 772 780 1661 35 2789 21136 204 18031 196 5786 225 250 10232 467 8783 9732 9644 981 272 3123 9848 980 39088 859 219 1255 15559 2887 3832 5515 12622 286 4643 86 8618 1911 2013 1404 10970 10377 219 2011 116 363 14044 12832 14673 1194 9829 13505 14448 12333 11...
result:
ok 100000 lines
Test #7:
score: 10
Accepted
time: 108ms
memory: 92860kb
input:
2 100000 100000 aabaababababbabbbbaaaaabbabaaaaabaaaabbbbaaaaaabbabbaaabaababaaaaaaabaabbbabbaabaabaababbbbbbaaabbabbaabaabbaaabbbaaaabaabbaababbaaabbabbababaaababaababbabbbababbaaaaababbaaaabbaaabbbbabaaabbbbaaaabbabbabbaaaaaabbabbbaaaabbaabbbaaabaabaabbbaaabaababaabaaabbaaabbbaaababaabbbabaabbaaab...
output:
336 1019 15080 9970 20317 696 8784 3375 387 772 780 1661 35 2789 21136 204 18031 196 5786 225 250 10232 467 8783 9732 9644 981 272 3123 9848 980 39088 859 219 1255 15559 2887 3832 5515 12622 286 4643 86 8618 1911 2013 1404 10970 10377 219 2011 116 363 14044 12832 14673 1194 9829 13505 14448 12333 11...
result:
ok 100000 lines
Test #8:
score: 10
Accepted
time: 89ms
memory: 92732kb
input:
2 100000 100000 aaaababaabaaabbaaabbaaaabbaababbaaaabaabbbbbbbbabbbabbbbabbabaaaaabaabaaabaaababbbaaabbbaabbaaabbaabbbbaaaaababaabaaaabababaabbaaabaabbbbbaaaaabbaabaaaaaaaaababababaabbabbbabbbbbaabbbbbabbaababbbbbbababbaababbabaabbbbaaaaabaabbaaabbbbbbbaabbbaaabaaaabaabaaaaabbbbbbbbaabaabababbbbbaba...
output:
11772 1819 14389 905 105 1917 1858 666 11413 1863 993 3113 280 9852 752 2232 2806 3126 14696 2857 17489 11291 1523 1629 745 2920 5884 4070 24943 1551 3576 2062 101 1045 138 8859 8389 2154 2118 2507 2 614 8468 12229 3499 19139 14 2222 8612 0 10253 25661 2822 6752 4 6314 1645 2632 6014 429 5539 2903 2...
result:
ok 100000 lines
Test #9:
score: 10
Accepted
time: 101ms
memory: 89120kb
input:
2 100000 100000 aaaababaabaaabbaaabbaaaabbaababbaaaabaabbbbbbbbabbbabbbbabbabaaaaabaabaaabaaababbbaaabbbaabbaaabbaabbbbaaaaababaabaaaabababaabbaaabaabbbbbaaaaabbaabaaaaaaaaababababaabbabbbabbbbbaabbbbbabbaababbbbbbababbaababbabaabbbbaaaaabaabbaaabbbbbbbaabbbaaabaaaabaabaaaaabbbbbbbbaabaabababbbbbaba...
output:
11772 1819 14389 905 105 1917 1858 666 11413 1863 993 3113 280 9852 752 2232 2806 3126 14696 2857 17489 11291 1523 1629 745 2920 5884 4070 24943 1551 3576 2062 101 1045 138 8859 8389 2154 2118 2507 2 614 8468 12229 3499 19139 14 2222 8612 0 10253 25661 2822 6752 4 6314 1645 2632 6014 429 5539 2903 2...
result:
ok 100000 lines
Test #10:
score: 10
Accepted
time: 98ms
memory: 91104kb
input:
2 100000 100000 baaabaababbbbababaabababaaaabbaabaaabbaababaabbababaababbbbabaababaabbbbbbbabbbabbbbaabaaaababbbabbbbabaaaaabbbbbbaabbabaabaaaaaababaabbababbaaaabbabbbaaaabbbaababbbbabababababbabababbbbbaaabaabaaaabbbbabbaaababbabaaaaaabaabaabaaabaaaababaabbbaaaabababbaababaabbbaababaaaabbbbabbabbba...
output:
13912 6871 396 11429 5191 21624 3028 11883 12 1081 7279 1326 2162 21687 1775 9790 6245 365 805 25 15887 3030 6427 266 11962 662 4066 244 1037 1358 2787 27389 4225 13 4580 732 2181 5733 15532 3364 4709 5599 1058 2650 2078 8716 2506 12220 2568 7882 3940 13505 2877 465 5402 6654 2363 2925 439 228 646 7...
result:
ok 100000 lines
Subtask #3:
score: 20
Accepted
Dependency #1:
100%
Accepted
Test #11:
score: 20
Accepted
time: 117ms
memory: 91756kb
input:
3 100000 100000 aababaababbbbabbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabaaba...
output:
15634 7997 23631 523 322 8807 727 1658 198 6346 3354 4266 281 10007 4656 2198 3519 3337 1584 1618 7646 3886 7250 11029 813 753 8 4134 1172 6052 30867 6520 2515 657 14358 6005 1025 4432 1217 9380 2281 6890 108 2642 7208 238 940 13150 6217 1037 268 163 582 2887 2439 102 98 2502 6469 3738 966 17297 768...
result:
ok 100000 lines
Test #12:
score: 20
Accepted
time: 122ms
memory: 93212kb
input:
3 100000 100000 aababbbbccabbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccabbccaaababbbbccaaababbbbccabbcc...
output:
6735 5554 4932 6897 1706 18283 15155 2355 1511 3098 10347 521 267 9513 21 3655 3359 1356 192 93 19422 2072 26942 3223 7272 5534 7539 4153 7000 11434 4760 676 8655 85 10 2515 1390 47 3182 401 5917 514 4780 9234 2298 2150 1911 3182 12865 14841 2849 956 4624 4246 1419 266 852 12934 63 267 29359 3921 33...
result:
ok 100000 lines
Test #13:
score: 20
Accepted
time: 81ms
memory: 88792kb
input:
3 100000 100000 ghbaahxvveloseywqeuokpraqgyscdcimfioohjjnwyhdyftczjorapjhncjqetfjetxnfidbgkeesajrjxkkmutayescxxndtmryuubdgijyisstqefcayeycxccwpfpdypautdbbmblfvexakzakgzpfdrdtytyzkytfdwgqarxvyuvivysbzhgcakxbfwarwvxaufsuzprxjnhenbimlqoncmojkqbgoaiifaegpvdakmhxoplzfamkodtatwghwprerxkhtqhfcofqfqrnsgxgjs...
output:
6291 1292 2790 2079 133 4509 451 555 5305 435 15144 2701 8544 16797 4460 1891 526 16938 4753 8881 27 4775 3227 164 1511 14286 751 1071 2848 5141 9515 2339 7586 778 2651 13216 154 15420 3178 13033 5770 5891 5347 146 45 5184 409 2084 4105 8608 12128 7267 342 3514 13802 754 11528 7547 12211 1570 10008 ...
result:
ok 100000 lines
Test #14:
score: 20
Accepted
time: 115ms
memory: 90640kb
input:
3 100000 100000 pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 100000 lines
Test #15:
score: 20
Accepted
time: 106ms
memory: 92648kb
input:
3 100000 100000 aababaababbbbabbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabaaba...
output:
3046 5650 394 5764 2987 13467 11480 275 5719 3499 10592 13695 13657 14050 7130 129 6853 1712 2986 2009 11408 6009 1303 11714 2163 9699 5439 3567 5984 24867 8352 1944 10664 800 14750 5646 1181 667 22 2772 7613 1679 2002 3481 5836 22660 108 3326 54 808 2759 5247 1016 4390 1519 4999 19160 21745 1155 11...
result:
ok 100000 lines
Subtask #4:
score: 20
Accepted
Dependency #1:
100%
Accepted
Dependency #3:
100%
Accepted
Test #16:
score: 20
Accepted
time: 438ms
memory: 141132kb
input:
4 300000 300000 babaababaababbbbabbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabbbabaababaababbbbaba...
output:
2127 17628 11541 14729 2054 49773 14238 911 18758 84206 19471 59591 124 45510 3234 17188 3632 20561 5997 17371 6432 46510 7140 11771 9403 59 12453 201 2197 10207 10739 18259 11655 523 36622 10838 190 10929 3343 20748 46234 50831 12051 8562 32727 33481 45892 50476 59553 1445 22781 4553 59 4009 6868 1...
result:
ok 300000 lines
Test #17:
score: 20
Accepted
time: 439ms
memory: 140664kb
input:
4 300000 300000 bbbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbc...
output:
16550 7982 1799 18514 20159 295 20356 410 7584 2046 9198 5576 10356 20360 2777 4696 48509 839 19660 39715 56 128 15924 956 9487 16050 957 763 972 1645 8257 69650 57161 929 34540 583 21312 15344 13453 1525 345 302 35316 11776 2612 10012 15980 694 2436 11149 2270 1437 2644 58861 23578 85930 1400 40744...
result:
ok 300000 lines
Test #18:
score: 20
Accepted
time: 329ms
memory: 132664kb
input:
4 300000 300000 hpdtaorltsivwlbqykwotvvbydvnnxyupdqprjanckiavlquynkrkhvklsxaqxvfbnuuwwhaircedtabikusupefiefabcherbzozgqhatnfongwacquswbcaiecllgcofsnolwqgkvwzdszfkvzgwbhhhlusrygzrvpeuhmgciffchkmckubndixocpiawjttaznhlvltbqvkcjmogpejzbabqkeovzkvzzemvpgyhdijpwavoegnhirzsvqpuamvbqiwhqwovgakfchtiqgpaxqtug...
output:
48782 18911 1037 60895 14064 1750 17959 13154 2530 2808 6488 68863 2750 1977 12479 4094 1803 47027 3073 4712 7513 41256 24992 87936 101680 1097 9217 25999 13342 30741 24190 65219 334 18849 2740 2369 1712 49 74162 102866 23094 11117 2716 16603 50709 33378 47896 3491 15696 10177 9875 522 5235 9608 523...
result:
ok 300000 lines
Test #19:
score: 20
Accepted
time: 368ms
memory: 132460kb
input:
4 300000 300000 pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 300000 lines
Test #20:
score: 20
Accepted
time: 443ms
memory: 144720kb
input:
4 300000 300000 ababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccabbcca...
output:
34478 21636 63153 7070 5075 58660 4710 18698 24818 42188 41996 48057 5124 2015 5514 15605 12923 27550 23297 3364 5 3119 38606 12171 11422 20251 768 17625 2331 3205 16303 29386 2831 65531 10142 3180 6 11952 25059 2201 49385 2012 35389 1821 38904 143 80110 2602 874 11171 12399 507 20392 357 17768 2930...
result:
ok 300000 lines
Subtask #5:
score: 30
Accepted
Dependency #1:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
100%
Accepted
Test #21:
score: 30
Accepted
time: 924ms
memory: 185532kb
input:
5 500000 500000 babbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababb...
output:
45676 114315 1373 5470 58733 541 58335 76940 12171 1289 1296 5981 46695 60474 5998 6354 17365 1598 47943 738 52953 437 670 12273 3148 2914 124917 20950 65156 8542 12460 1040 441 32021 128532 33762 1025 79163 6102 6450 70058 3973 74663 1235 6167 3904 11080 32073 59 25326 6334 90624 40639 20111 66336 ...
result:
ok 500000 lines
Test #22:
score: 30
Accepted
time: 858ms
memory: 188052kb
input:
5 500000 500000 aababbbbccabbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccabbccaaababbbbccaaababbbbccabbccaaababbbbccabbccaaababbbbccaaababbbbccabbcc...
output:
3035 8094 49867 64879 21516 41407 7401 1010 1934 1038 16997 255 2691 32729 39342 9664 74201 23020 21273 11422 2059 160983 85041 21862 646 3479 70389 85729 81026 5840 388 89763 12747 75217 72787 89910 10232 166 144054 33602 11280 70147 150496 82 15453 4186 1602 92023 7118 12301 66564 17871 5935 13786...
result:
ok 500000 lines
Test #23:
score: 30
Accepted
time: 698ms
memory: 174144kb
input:
5 500000 500000 pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 500000 lines
Test #24:
score: 30
Accepted
time: 680ms
memory: 174124kb
input:
5 500000 500000 pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 500000 lines
Test #25:
score: 30
Accepted
time: 852ms
memory: 185532kb
input:
5 500000 500000 babbbbabaababaababbbbabbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabaababaababbbbabbbabaababaababbbbabbbabaababaababb...
output:
3813 22449 40874 28936 2873 15071 71086 57461 38081 13917 55914 12050 73696 3188 41751 31930 7822 36947 276 1785 29201 5083 12097 1922 32999 6102 24512 107193 81504 3676 7039 32037 28339 107479 73196 89293 117847 26567 5529 2705 64024 1008 4589 148395 108627 578 7946 871 21915 4453 22591 112894 33 8...
result:
ok 500000 lines