QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#422119#4882. String Strange SumzhaohaikunTL 1717ms299304kbC++206.8kb2024-05-26 19:56:312024-05-26 19:56:31

Judging History

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

  • [2024-05-26 19:56:31]
  • 评测
  • 测评结果:TL
  • 用时:1717ms
  • 内存:299304kb
  • [2024-05-26 19:56:31]
  • 提交

answer

// MagicDark
#include <bits/stdc++.h>
#include <bits/extc++.h>
#define link fdskjfhsdkjhfkjdshfkjdxhbgjkfdbgjkshdbgjh
#define debug cerr << "\033[32m[" << __LINE__ << "]\033[0m "
#define SZ(x) ((int) x.size() - 1)
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> T& chkmax(T &x, T y) {return x = max(x, y);}
template <typename T> T& chkmin(T &x, T y) {return x = min(x, y);}
const int N = 4e5 + 10;
int n, tot, son[N][26], link[N], len[N], endpos[N], last;
ll ans;
string st;
vector <int> v[N];
void init() {
	while (tot) v[tot].clear(), endpos[tot] = 0, ms(son[tot--], 0);
	last = tot = 1;
}
int extend(int c) {
	int nw = ++tot, p = last;
	len[nw] = len[p] + 1;
	while (p && !son[p][c]) {
		son[p][c] = nw;
		p = link[p];
	}
	if (!p) link[nw] = 1;
	else {
		int q = son[p][c];
		if (len[p] + 1 == len[q]) link[nw] = q;
		else {
			int cl = ++tot;
			F(i, 0, 25) son[cl][i] = son[q][i];
			len[cl] = len[p] + 1;
			link[cl] = link[q];
			while (p && son[p][c] == q) {
				son[p][c] = cl;
				p = link[p];
			}
			link[nw] = link[q] = cl;
		}
	}
	return last = nw;
}
int sz[N], mxson[N];
void dfs(int x) {
	// debug << x << " " << endpos[x] << " " << len[x] << endl;
	sz[x] = !!endpos[x];
	mxson[x] = 0;
	for (int i: v[x]) {
		// debug << x << " -> " << i << endl;
		dfs(i);
		sz[x] += sz[i];
		if (sz[i] >= sz[mxson[x]]) mxson[x] = i;
	}
}
template <typename _Tp> class Q {
    __gnu_pbds ::priority_queue <_Tp, greater <_Tp>> _Val, _Del; bool _Op; size_t _Siz;
    void flush() {
        while(!_Del.empty() && !_Val.empty() && _Del.top() == _Val.top()) _Val.pop(), _Del.pop(); _Op = 0;
    }
    public:
    Q() : _Op(0), _Siz(0) {}
    size_t size() {return _Siz;}
    void push(const _Tp &x) {_Siz++; _Val.push(x);}
    _Tp top() {
        assert(_Siz); if(_Op) flush(); assert(!_Val.empty()); return _Val.top();
    }
    void pop() {
        assert(_Siz); _Siz--;
        if(_Op) flush(); _Op = (!_Del.empty());
        assert(!_Val.empty()); _Val.pop();
    }
    bool empty() {return _Siz == 0;}
    void erase(const _Tp &x) {
        assert(_Siz); _Siz--;
        if(_Op) flush(); assert(!_Val.empty());
        if(x == _Val.top()) {
            _Val.pop(); _Op = 1; return;
        }
        assert(x > _Val.top()); _Del.push(x);
    }
    void clear() {
        _Op = _Siz = 0; priority_queue<_Tp> _Tx, _Ty;
        swap(_Val, _Tx), swap(_Del, _Ty);
    }
	void jj(Q& x) {
		_Siz += x.size();
		// x._Siz = 0;
		_Val.join(x._Val);
		_Del.join(x._Del);
		_Op = 1;
	}
};
vector <pair <int, int>> w;
struct DS {
	int tot;
	// map <int, int> id;
	vector <Q <int>> h;
	set <pair <int, int>> s;
	priority_queue <pair <int, int>, vector <pair <int, int>>, greater <pair <int, int>>> q;
	ll cur;
	void build() {
		tot = cur = 0;
		h.clear(), s.clear();
		while (q.size()) q.pop();
		sort(all(w));
		for (int i = 0, j; i <= SZ(w); i = j + 1) {
			j = i;
			int mx = w[i].second;
			while (j < SZ(w) && w[j + 1].first <= mx) chkmax(mx, w[++j].second);
			{
				Q <int> t;
				h.push_back(t);
			}
			F(k, i, j) h.back().push(w[k].first);
			cur += (ll) (j - i + 1) * mx;
			if (s.size()) q.emplace(w[j].first - s.rbegin() -> first, mx);
			s.emplace(mx, tot);
			tot++;
		}
		// debug << tot << " " << h.size() << " " << s.size() << " " << q.size() << endl;
	}
	void del(int x) {
		// debug << x << endl;
		// for (auto [a, b]: s) debug << a << " " << b << endl;
		auto it = s.lower_bound(make_pair(x, 0));
		assert(it != s.end());
		// auto g = h[it -> second];
		// debug << it -> second << " " << h[it -> second].size() << endl;
		// while (g.size()) {
		// 	cout << g.top() << " ";
		// 	g.pop();
		// }
		// debug << endl;
		// debug << "! " << x << endl;
		cur -= it -> first;
		h[it -> second].erase(x);
		if (h[it -> second].empty()) {
			it = s.erase(it);
			if (it != s.end() && it != s.begin()) q.emplace(h[it -> second].top() - (prev(it) -> first), it -> first);
		} else if (it != s.begin()) q.emplace(h[it -> second].top() - (prev(it) -> first), it -> first);
	}
	void merge(int x, int y) {
		if (h[x].size() > h[y].size()) swap(h[x], h[y]);
		while (h[x].size()) {
			h[y].push(h[x].top());
			h[x].pop();
		}
	}
	int query(int x) {
		auto it = s.lower_bound(make_pair(x, 0));
		assert(it != s.end());
		return it -> first;
	}
	void dot(int l, int r) {
		// debug << " ) " << cur << endl;
		int lst = l;
		while (q.size() && q.top().first <= r) {
			auto [x, y] = q.top(); q.pop();
			auto it = s.lower_bound(make_pair(y, 0));
			if (it == s.end()) continue;
			// assert(it != s.end());
			if (it == s.begin()) continue;
			auto [a, b] = * it;
			it--;
			auto [c, d] = * it;
			if (h[b].top() - c != x) continue;
			ans += (ll) cur * (x - lst);
			lst = x;
			cur += (ll) h[d].size() * (a - c);
			merge(d, b);
			h[b].jj(h[d]);
			// {
			// 	Q <int> x;
			// 	swap(x, h[b]);
			// }
			s.erase(it);
			// {
			// 	auto w = h[d];
			// 	cout << "~ " << w.size() << endl;
			// 	while (w.size()) {
			// 		cout << w.top() << endl;
			// 		w.pop();
			// 	}
			// }
			// cout << d << " " << b << " " << h[d].size() << " " << h[b].size() << endl;
		}
		ans += (ll) (r - lst + 1) * cur;
	}
} ds[N];
void dfs3(int a, int x) {
	if (endpos[x]) {
		// debug << "~ " << a << " " << x << " " << ds[a].query(endpos[x]) << endl;
		w.emplace_back(endpos[x], ds[a].query(endpos[x]));
		ds[a].del(endpos[x]);
	}
	for (int i: v[x]) dfs3(a, i);
}
void dfs2(int x) {
	ds[x].dot(len[link[x]] + 1, len[x]);
	if (endpos[x]) {
		// debug << x << " " << endpos[x] << " " << ds[x].s.size() << endl;
		ds[x].del(endpos[x]);
	}
	// debug << x << " : " << ds[x].cur << " " << len[link[x]] + 1 << " " << len[x] << ' ' << ans << endl;
	for (int i: v[x])
		if (i != mxson[x]) {
			w.clear();
			dfs3(x, i);
			// debug << x << endl;
			// for (auto [a, b]: w) debug << a << " " << b << endl;
			ds[i].build();
			dfs2(i);
		}
	if (mxson[x]) {
		swap(ds[x], ds[mxson[x]]);
		dfs2(mxson[x]);
	}
}
void zhk() {
	ans = 0;
	init();
	cin >> st;
	reverse(all(st));
	// debug << tot << endl;
	n = st.size(); st = ' ' + st;
	F(i, 1, n) endpos[extend(st[i] - 'a')] = i, ans -= (ll) (n - i + 1) * (i + n) / 2;
	// debug << tot << endl;
	F(i, 2, tot) v[link[i]].push_back(i);//, debug << link[i] << " " << i << endl;
	dfs(1);
	w.clear();
	F(i, 1, n) w.emplace_back(i, i);
	ds[1].build();
	dfs2(1);
	cout << ans << '\n';
}
signed main() {
	// cin.tie(0) -> sync_with_stdio(0); // don't use puts
	int _ = 1;
	cin >> _;
	while (_--) zhk();
	return 0;
}
/* why?
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

8
aa
ab
ababa
abaaba
abacaba
abaaababaab
aababcabcbc
abcdabcabaabcd

output:

1
0
6
7
0
74
51
20

result:

ok 8 numbers

Test #2:

score: 0
Accepted
time: 78ms
memory: 55084kb

input:

100000
ff
ki
wb
vc
bb
cq
tt
gl
xb
tt
ll
it
bb
yy
dd
yg
tt
vq
gg
ua
ff
nn
aa
yq
ee
ae
sj
yy
cd
qk
vk
ts
tt
cm
rr
yk
sh
fv
vm
rr
tl
vv
bb
rl
jx
pv
tx
ib
dp
oo
lx
jo
bb
dl
sj
sn
db
kk
oo
rk
yy
gz
ff
ha
ja
ax
hn
ww
ms
yy
kf
zz
ss
ii
km
uv
mn
si
ng
hh
yq
lq
bq
ed
bb
bw
jj
pp
ss
xg
ff
gm
ee
cc
fn
vv
rc
nn...

output:

1
0
0
0
1
0
1
0
0
1
1
0
1
1
1
0
1
0
1
0
1
1
1
0
1
0
0
1
0
0
0
0
1
0
1
0
0
0
0
1
0
1
1
0
0
0
0
0
0
1
0
0
1
0
0
0
0
1
1
0
1
0
1
0
0
0
0
1
0
1
0
1
1
1
0
0
0
0
0
1
0
0
0
0
1
0
1
1
1
0
1
0
1
1
0
1
0
1
0
0
1
1
1
0
0
0
1
1
0
0
1
1
1
0
1
1
1
1
1
0
0
1
0
0
0
1
1
1
0
0
1
0
1
1
1
1
1
1
0
0
0
0
0
1
0
1
0
0
0
1
...

result:

ok 100000 numbers

Test #3:

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

input:

40000
nbbnn
tttuu
rfeer
omhom
qqcmq
yyiyi
tlttt
jhjtj
ixiyx
bnnon
iwpiw
uzluz
ffqfj
dyddl
szkss
dauud
dddiy
gggtt
ebbee
uboob
nnnnv
rrjrj
cjccj
xnnyy
mwmjw
wyyyq
vvuvp
vyzyv
sssss
vvsvs
rhxxr
pkkpk
xsxss
ngncn
wzwjz
khkth
jjjjj
vvvbb
unnxn
aqlqq
mmgmg
iiiji
lyllv
luuuu
itizt
fsffs
xggii
jqqtj
mummd
...

output:

4
11
2
0
4
7
4
0
0
3
0
0
4
2
1
2
10
11
4
2
16
7
4
4
0
7
4
0
20
7
2
3
5
0
0
0
20
11
3
1
7
10
2
10
0
4
4
3
2
3
4
6
1
4
10
3
6
10
10
16
7
7
0
10
5
0
2
16
0
6
1
0
1
2
5
2
5
6
20
10
0
8
10
3
16
7
0
8
4
3
0
1
7
0
2
4
4
5
3
7
2
4
16
4
1
8
10
7
4
3
4
4
6
2
2
4
6
2
4
5
4
3
10
5
0
4
16
2
3
0
3
4
1
1
4
4
11
2
...

result:

ok 40000 numbers

Test #4:

score: 0
Accepted
time: 85ms
memory: 54788kb

input:

20000
iijjijiijj
fxffxfffxx
kkiiiiiiii
oppopopppo
iiooiioooi
gggxxxxggg
oxxoxxxoox
puuuppupuu
ppssspspps
eefffeefff
xxtxxxttxt
yyppypyppp
kkwwkkwwkk
bvvvbvbbbv
attataaaat
boooobbobo
hhhhfhhhff
nnhhhnhhhh
cdccccdccd
axxxaxaxxa
qqnnnnnqnq
eeexxeeeex
ppkkkkkkkp
uusussusss
iwiwiiwiii
gglgllgggg
wwwrrrwr...

output:

40
58
93
52
52
57
56
34
44
46
52
46
57
47
41
47
87
48
56
52
65
47
86
56
61
50
51
34
58
41
52
47
60
92
61
56
64
55
65
48
56
77
80
62
55
57
41
58
44
93
63
49
54
59
50
55
111
58
52
52
39
35
63
50
111
84
140
75
78
40
99
56
49
40
68
45
87
54
47
59
52
59
50
86
82
54
48
59
33
121
84
44
33
40
62
55
46
121
6...

result:

ok 20000 numbers

Test #5:

score: 0
Accepted
time: 131ms
memory: 55756kb

input:

10000
jlljjjlllljjjjljllll
uooooouuouoouoooouuo
utttutuuttuuuutttutu
xccxxxccxxccccxcxxxc
sjjsjjsjjssjjsssjjjs
fgffffgfgggfgfgfffgf
ddaaadaadadddadadaaa
tbbbbttttttbtttbtbtt
eeeeeekkkekeeeekeeke
dddddmdmmmmdddmmddmm
yykkkkykkykykkkkyykk
ededeedddededeedddee
kktttkktktkktkkkttkk
fcfcfcffffcffcccccfc
...

output:

339
332
348
341
662
367
363
432
395
371
452
460
353
472
416
420
464
365
589
476
516
407
446
376
501
364
354
424
366
438
330
590
553
491
662
317
467
374
422
406
492
484
405
328
396
654
300
410
447
404
389
487
534
688
489
370
396
474
396
467
364
424
380
236
480
506
506
339
297
316
457
626
338
349
351
...

result:

ok 10000 numbers

Test #6:

score: 0
Accepted
time: 206ms
memory: 54268kb

input:

4000
urrrrrrrrururrruruuuuuuuuruurruuruuuurrruurruurruu
hthtthttthhhtttthhhhthhhhthhhttthtthhtthhtttttthhh
ttssssssttsststttsttttssstsssstsstssttssststttstst
iiniiiiiniinnniiniiiiniiiinnniiinniiininniinnnnnni
dddpdpddpdpdppppdpdppdpdpddppppddddpdpdddppppdppdp
mmmsmmmmsmmmmmmsmmmmsmmmmsssmmssmssmsmsm...

output:

5599
5287
4294
4818
5746
7893
3623
3453
5390
5812
5608
5541
6069
5655
3743
3847
4866
5059
3876
3925
5018
4379
5016
5747
5333
5271
3890
5894
5141
3773
4196
4880
5111
5510
4334
3825
6188
5960
4893
5359
4720
4167
4042
4051
5011
6457
3807
3837
4612
4859
5044
6861
4330
5967
5001
4857
4340
3957
4152
4230
...

result:

ok 4000 numbers

Test #7:

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

input:

2000
ffffccfcfcfcfccffcccfcccfcfccfcccccfcfcccfccfcccccffffcccfcccffffffcffffccccffffffccffffcccfcccfcfff
enneeenneneennnnneeeeeenenneeennnnneneneneenneenneennnnnnnnenennennnneneneneeenennnneennnenneennnnne
mzmzmmzzmzzmzzmmzmmmzzmmmzzzzmmmzmmzzmzzmmmzzmzmzmmzzmmmmzmmmmmmzzmmmzmmmmzmmzmzmmzzmzmmmmmzm...

output:

32329
22810
31196
27570
28177
29004
24676
27293
26336
28196
28972
25095
34989
26711
26498
29643
24727
22723
31605
30180
43766
27097
25766
26819
28516
28122
34935
27399
33153
32281
26033
24708
41701
21704
24011
27481
26913
23270
31778
27676
25970
38135
25776
23316
44300
29424
24305
23476
29598
24423
...

result:

ok 2000 numbers

Test #8:

score: 0
Accepted
time: 323ms
memory: 62916kb

input:

1000
udduuddduududddudduuduuuduuududdduuduuduudududdduuddddduuuuddduuuuudduddduuddddududduuduuuuuduuduudduuuuuuuddduuduuduuuudududduuuuududuudduduuduuduududddudududdududuududuudududdduddduuuuuuuuuuuddduduu
kykykkykyykkykkkkkkyykkyyyyyykyyykkkyykkyykyyyykkykykkkykkykkkyyykyyyyykkkyyykykykkkkyyykkyyyy...

output:

153694
145776
132786
133300
133959
177645
148786
132135
169466
159430
133110
171068
168822
120233
160090
125272
130139
138522
163688
161504
146208
170689
149990
147133
129161
146576
129200
138709
133553
154659
136204
167106
167771
151156
129986
137285
131065
131582
159289
158241
141081
128564
167348...

result:

ok 1000 numbers

Test #9:

score: 0
Accepted
time: 499ms
memory: 90936kb

input:

200
zzzzzzzzzzzzzzzazzzazzzzzzzaazzaaaazaazzaazzazaazazazazzzazazaazzazzaazaaaazaaazzzzzazzzazzaaazzazzazazaazzzazaaaaaazzzaazzzazaazzzzzaaaazazazazzzzaaaaazaazzzzazzzazazaaazazzzaazaazazazzzzazaazaazaaaazzzzzazzazzzazzzzzzazzaazzzazzzzazzzzaaazzzaaazzzzzazzaazzzzazaazzaaaaazzazazzaaaaazzzzzaaazzazz...

output:

6229118
5438629
6162119
5350067
5263770
5443998
6419968
6592325
5876576
5249432
6397577
5947645
5851620
6059174
6048260
5774316
6323371
6103930
5794311
5297842
5559753
6109729
5724850
5095495
5263069
5635785
5916607
5959557
5261499
5446440
5526488
5504207
7229030
5767214
5191558
5475249
5537449
6169...

result:

ok 200 numbers

Test #10:

score: 0
Accepted
time: 886ms
memory: 158664kb

input:

20
nnnllllnlnnllllllllllllnnnnllnnlllnnnnnnnlnlnnlnllnnlnnnnnnnnnllllnlllnnnlnllnnnlnnllnnlnnllnnnllnlnllnllllnnnlllnllllnlnnllnllllnnlllnnnlllnlnnnnlllnnnlnlnnlnllnnlnllnlllllllnnnnnnnnlnnlllnlnnnllnlllllnlnnllnllllnnnnnnnnnlnnnnnnnnlnlnnnllllllnllnlllnnnlnllnllnnllllllllllnnllnllllnlllnlllnlnnnlll...

output:

894196857
938803119
931699133
881434935
917400222
988704236
829814492
910180484
875107867
927874072
861165839
857715013
907953346
879864017
925887954
884818843
920746630
936583374
887419288
927606368

result:

ok 20 numbers

Test #11:

score: 0
Accepted
time: 1279ms
memory: 208704kb

input:

5
omomomommomommommoooommmommmoommmomommmoomoomoomomomoooommmmmmoomomomoommoooommommmooommomoomomommmmmmomooomoommomoommomoooooomoomomooommmommmmooooooomoooommmmomooomoommmmmomoooomommomomomommmomommmommoooomooommomooomoomoommmmmmmoomoommoomommommmmommmmmmmmmoooomomoooomoommmmoomooomomooommmmmoommom...

output:

17174226584
17605268588
18296766446
17539695533
18766633585

result:

ok 5 number(s): "17174226584 17605268588 18296766446 17539695533 18766633585"

Test #12:

score: 0
Accepted
time: 1450ms
memory: 253016kb

input:

2
ddvddvvvvvddddvddddddddddddvvdvvvvvvvddvddddddddvvvvdvvddvvdvvvdvdddvdddvvvvdvvvvdvdvdvddvvvddvdvdddvdddvdvvdvvvvdvdvvvvvvdvdvvdddvdddvvvdddvvddvvvdvdddvdddvvdvvddvddvdvdvddvvvvvvdvdddvvddvdddvdddvdvvvvdvvvvdvvddvvvddvvdddvvddvdddvdvdvddvvvddvddvvddvddvvddddvdddvddvvvdvdvvvvvdvvvvddddvdddvddvdvvdd...

output:

132896961339
129565821251

result:

ok 2 number(s): "132896961339 129565821251"

Test #13:

score: 0
Accepted
time: 717ms
memory: 172844kb

input:

1
aaaattttattataatattaatattatttatatataaaaaaaattttttaaaaataatttattaaaaaatttttataataataaattttatattatattaaaaatttaaatatatttataaattaatatatataaatataaataaattttattttattaaaatttataaaaatattaattataaaattattaaaatttataaaatataaataatatataaattttaaaaatattaattattattaaaaaaaataatttaataaatattataattaattattaataataatattatatt...

output:

119827510026

result:

ok 1 number(s): "119827510026"

Test #14:

score: 0
Accepted
time: 1667ms
memory: 295424kb

input:

1
wzwzzzwzzzwzwwzzwzzzwzzwzzzzwwzzzzzzwzzwzwzzwzwwzwzzwzzwwwwwwwzwzwzzzwzzzwwwwwwzwwwzzzwwwzzwwzwzwzzwzwzwwwwzwzwzzzzwwzwzzzwwwzwwzzwwzzzwzzzzzwwwzzzzwwwwwwzwwzzzwzwzzzwwwzwzzzzzwzwzzwwwwzwwzwzzzzwwwwwwwzwwzzwzwzwwwzwwwwwwzzzwwzzwwzzzzzzzwzzzwwwzwwwzzwwzzzzwzzzwzzwzwzwwwwzzwwwzwzwzwzzwzzzzzwwwwwzwww...

output:

554193679678

result:

ok 1 number(s): "554193679678"

Test #15:

score: 0
Accepted
time: 1701ms
memory: 293220kb

input:

1
eeeewweeewwweeeewewweweeweeeewweweeewweeewweewwwewwewwwewwewwwewewewwweewwwwweeeweweeeeeeewweewweewwwewwweweeeweweweeweeewwwwewweweewwewwwweeweeeewwwwewewwwewwwwewwewwewewwwwwweeweewweewweeewwwwewewewewwwwwweweeewwwwwewwwwweeewweeweewewwweewweeeewwewewewewweeeewwweweewewwwwewwwwwwwewwweeeeeewewewe...

output:

529663865648

result:

ok 1 number(s): "529663865648"

Test #16:

score: 0
Accepted
time: 1656ms
memory: 299304kb

input:

1
vvvvvaaavavaaavaavavvavaaaavavavaaaaavavvvvvvavvvvvaaaavvvvavaaavvvaavaaavavaaaavvvvvvavavaavvaavvvaavvvaavvvaaaaaavavavavvaavavvavavvvvvaavvavavvvavavvvvavavvaaavvvvavvvvvvaavvavvvaavvavaavvvvavvaaaaavvvaavvaaaaavaavvavvvaavavaaaavaavvaavvavvavvavvvvvaavvvavvaaavaavavaaavavavvaavaavavaavavvavvvaa...

output:

556151200408

result:

ok 1 number(s): "556151200408"

Test #17:

score: 0
Accepted
time: 1717ms
memory: 292548kb

input:

1
lslsslslssslllllslssllsssllllslllsllssllslllsslslslssllssslsssllsllslllllsssssllslslssslllslssslssslsslsllssllssslllllslslslsslssssssslsllslssslsslslllsssssslsslslslllslsssllsssslsllsssslssllslsllsllsssllslslllsslsllslsssslsssslslslsssllsslllsssssslsssllssllslllsllssslsssslllslslllllsslllsllsllsll...

output:

528149019431

result:

ok 1 number(s): "528149019431"

Test #18:

score: 0
Accepted
time: 1405ms
memory: 269220kb

input:

1
lllrllalaalllalaaraarlaralaaaalaarrrrralllllaarllllaarrlllalalrrlaarllraaaalrarrarrrlallrlaralraarlrrraallralrrlaraallralarrallarrrrarlllrrrarrlllllaaarlaararrlalalraallrlararalallalrrlrlrarlrraararrarllaaaaallalrlaaarllraaaalraalaarrrralllrlalalralalrrllrrallarllalraaalralrrlalrlarrralrlrrraraaal...

output:

22333600841

result:

ok 1 number(s): "22333600841"

Test #19:

score: 0
Accepted
time: 1261ms
memory: 247752kb

input:

1
iixvjvjjijijiijvvxjvxvjjjjjiixijvvxxvjxvvvivxixjixiivivijjiixvxvixxvvjjxiijvixjivjvxixxivxvxxjiixjxivjvivivjxxxjxiiviijjxxvxiijjvxxjjvjvjxixivxxjijjiiivjvvvjiijijxvvivivxixiijjvxxvxxvjjijjjjvvxjxxvjxixvvjijivjjjviixviivijvjjjvjjxvjjxiivxxxjxxjvxxvjxijjxxvxjjvvvvjivxjvjvxxiivvvxiivijxxjxjxjxvivvvxv...

output:

11581008357

result:

ok 1 number(s): "11581008357"

Test #20:

score: -100
Time Limit Exceeded

input:

1
llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll...

output:


result: