QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#203032#2476. Pizzo Collectorsnameless_story#AC ✓72ms59776kbC++201.8kb2023-10-06 14:49:582023-10-06 14:49:59

Judging History

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

  • [2023-10-06 14:49:59]
  • 评测
  • 测评结果:AC
  • 用时:72ms
  • 内存:59776kb
  • [2023-10-06 14:49:58]
  • 提交

answer

#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const ll inf=1e18;
template<class T1,class T2> bool cmin(T1 &x,const T2 &y) { if (y<x) { x=y; return 1; }return 0; }
template<class T1,class T2> bool cmax(T1 &x,const T2 &y) { if (x<y) { x=y; return 1; }return 0; }
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int n,p,i;
	cin>>n;
	vector<int> typ(n*2,-1);
	vector<int> val(27);
	{
		string s;
		cin>>s;
		for (i=0; i<n; i++) if (s[i]!='?') typ[i]=s[i]-'A';
	}
	int q;
	cin>>q;
	while (q--)
	{
		char c;
		int v;
		cin>>c>>v;
		val[c-'A']=v;
	}
	if (n==1)
	{
		cout<<(typ[0]==-1?*max_element(all(val)):val[typ[0]])<<endl;
		return 0;
	}
	for (p=2; n%p; p++);
	vector e(n*2,vector<int>());
	int id=n;
	vector<int> f(n*2);
	iota(all(f),0);
	vector<int> fa(n*2,-1);
	vector<int> sz(n*2);
	vector dp(n*2,vector<ll>(27,0));
	function<int(int)> getf=[&](int u) { return f[u]==u?u:f[u]=getf(f[u]); };
	for (int d=n/p; d; d/=p)
	{
		vector<int> rt(d);
		iota(all(rt),id);
		id+=d;
		// cerr<<id<<endl;
		for (i=0; i<n; i++)
		{
			fa[getf(i)]=rt[i%d];
			e[rt[i%d]].push_back(getf(i));
			++sz[rt[i%d]];
		}
		for (i=0; i<n; i++)
		{
			f[getf(i)]=rt[i%d];
		}
	}
	for (auto &v:e) sort(all(v)),v.resize(unique(all(v))-v.begin());
	for (i=0; i<n; i++) sz[i]=1;
	function<void(int)> dfs=[&](int u)
		{
			int i;
			for (i=0; i<26; i++) if (typ[u]==-1||typ[u]==i) dp[u][i]=(ll)sz[u]*val[i]; else dp[u][i]=-inf;
			dp[u][26]=0;
			for (int v:e[u])
			{
				dfs(v);
				for (i=0; i<26; i++) dp[u][i]=max(-inf,dp[u][i]+dp[v][i]);
				dp[u][26]+=*max_element(all(dp[v]));
			}
			// cerr<<u<<' '<<sz[u]<<' '<<dp[u][0]<<' '<<dp[u][1]<<' '<<dp[u][26]<<endl;
		};
	dfs(id-1);
	cout<<*max_element(all(dp[id-1]))<<endl;
}

詳細信息

Test #1:

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

input:

8
?A?B?A?C
3
A 1
B 1000
C 100000

output:

1301004

result:

ok single line: '1301004'

Test #2:

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

input:

4
ABCD
4
A 4
B 3
C 2
D 1

output:

10

result:

ok single line: '10'

Test #3:

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

input:

2
AB
2
A 1
B 2

output:

3

result:

ok single line: '3'

Test #4:

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

input:

7
???????
3
A 1
B 3
C 2

output:

42

result:

ok single line: '42'

Test #5:

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

input:

1
?
26
A 1
B 2
C 3
D 4
E 5
F 6
G 7
H 8
I 9
J 10
K 11
L 12
M 13
N 14
O 15
P 16
Q 17
R 18
S 19
T 20
U 21
V 22
W 23
X 24
Y 25
Z 26

output:

26

result:

ok single line: '26'

Test #6:

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

input:

4
A?A?
2
A 10
B 25

output:

140

result:

ok single line: '140'

Test #7:

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

input:

1
?
26
A 925691
B 784415
C 459872
D 532761
E 723841
F 43610
G 550337
H 362598
I 433441
J 830094
K 706780
L 870926
M 169396
N 614810
O 151788
P 802159
Q 74805
R 357984
S 654014
T 738826
U 367213
V 361083
W 22154
X 662187
Y 120341
Z 932546

output:

932546

result:

ok single line: '932546'

Test #8:

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

input:

8
AB??BBBC
3
A 226880
B 21007
C 187937

output:

1331550

result:

ok single line: '1331550'

Test #9:

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

input:

4
??AA
2
A 586426
B 609540

output:

7037112

result:

ok single line: '7037112'

Test #10:

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

input:

2
??
3
A 28745
B 469414
C 889999

output:

3559996

result:

ok single line: '3559996'

Test #11:

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

input:

9
D?CDADDBA
4
A 891831
B 540383
C 787792
D 316322

output:

6217922

result:

ok single line: '6217922'

Test #12:

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

input:

3
?BA
4
A 591794
B 849991
C 835076
D 706991

output:

2291776

result:

ok single line: '2291776'

Test #13:

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

input:

5
?DDDC
4
A 277536
B 300259
C 268269
D 674295

output:

2965449

result:

ok single line: '2965449'

Test #14:

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

input:

8
??A??B?A
3
A 892657
B 344729
C 759614

output:

15661428

result:

ok single line: '15661428'

Test #15:

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

input:

4
??BB
2
A 427975
B 505086

output:

6061032

result:

ok single line: '6061032'

Test #16:

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

input:

2
?B
3
A 553982
B 971440
C 799654

output:

3885760

result:

ok single line: '3885760'

Test #17:

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

input:

9
?BD???CCD
4
A 272237
B 751801
C 889541
D 404645

output:

10295999

result:

ok single line: '10295999'

Test #18:

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

input:

3
??B
4
A 357775
B 790006
C 254911
D 970091

output:

4740036

result:

ok single line: '4740036'

Test #19:

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

input:

5
????A
4
A 767484
B 111739
C 494875
D 677653

output:

7674840

result:

ok single line: '7674840'

Test #20:

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

input:

8
??A??ACB
3
A 325590
B 246789
C 560277

output:

5416491

result:

ok single line: '5416491'

Test #21:

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

input:

4
BABB
2
A 792459
B 534070

output:

3462809

result:

ok single line: '3462809'

Test #22:

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

input:

2
AB
3
A 656307
B 697344
C 427355

output:

1353651

result:

ok single line: '1353651'

Test #23:

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

input:

9
??B?ADD?B
4
A 580920
B 721154
C 858354
D 876934

output:

11066366

result:

ok single line: '11066366'

Test #24:

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

input:

3
?A?
4
A 439292
B 314685
C 246183
D 664655

output:

2635752

result:

ok single line: '2635752'

Test #25:

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

input:

5
???CA
4
A 620647
B 559270
C 553595
D 982214

output:

4120884

result:

ok single line: '4120884'

Test #26:

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

input:

8
?BAB??CC
3
A 138930
B 783078
C 166183

output:

7518998

result:

ok single line: '7518998'

Test #27:

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

input:

4
B??B
2
A 584378
B 333337

output:

4000044

result:

ok single line: '4000044'

Test #28:

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

input:

2
??
3
A 886046
B 415294
C 619440

output:

3544184

result:

ok single line: '3544184'

Test #29:

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

input:

9
D?D??CDA?
4
A 34222
B 257404
C 770908
D 891690

output:

9722030

result:

ok single line: '9722030'

Test #30:

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

input:

3
?DD
4
A 814949
B 503525
C 977750
D 568577

output:

3411462

result:

ok single line: '3411462'

Test #31:

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

input:

5
?DC??
4
A 449231
B 510080
C 954355
D 360422

output:

4177842

result:

ok single line: '4177842'

Test #32:

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

input:

8
???AAA?B
3
A 703510
B 534990
C 623491

output:

12494660

result:

ok single line: '12494660'

Test #33:

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

input:

4
ABAB
2
A 544494
B 385314

output:

3719232

result:

ok single line: '3719232'

Test #34:

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

input:

2
AA
3
A 441230
B 43946
C 171518

output:

1764920

result:

ok single line: '1764920'

Test #35:

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

input:

9
BC?C???CC
4
A 821508
B 146142
C 821764
D 293917

output:

11650838

result:

ok single line: '11650838'

Test #36:

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

input:

3
DC?
4
A 322498
B 599277
C 916029
D 410514

output:

2242572

result:

ok single line: '2242572'

Test #37:

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

input:

5
?DBBA
4
A 378999
B 968610
C 603823
D 534583

output:

3819412

result:

ok single line: '3819412'

Test #38:

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

input:

8
?B??ACC?
3
A 480537
B 890720
C 435654

output:

8554018

result:

ok single line: '8554018'

Test #39:

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

input:

4
A??B
2
A 727408
B 589715

output:

5268492

result:

ok single line: '5268492'

Test #40:

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

input:

2
BC
3
A 73285
B 863162
C 264923

output:

1128085

result:

ok single line: '1128085'

Test #41:

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

input:

9
??D?CDB?A
4
A 97396
B 962490
C 454116
D 236760

output:

9070552

result:

ok single line: '9070552'

Test #42:

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

input:

3
?D?
4
A 500155
B 811939
C 888931
D 587952

output:

3527712

result:

ok single line: '3527712'

Test #43:

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

input:

5
?AB?A
4
A 705726
B 387507
C 435398
D 224214

output:

3210411

result:

ok single line: '3210411'

Test #44:

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

input:

8
?CABBA?A
3
A 926717
B 887112
C 291376

output:

10287238

result:

ok single line: '10287238'

Test #45:

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

input:

4
???A
2
A 969312
B 936948

output:

11631744

result:

ok single line: '11631744'

Test #46:

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

input:

2
?A
3
A 568234
B 830302
C 159708

output:

2272936

result:

ok single line: '2272936'

Test #47:

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

input:

9
?C?D?B?B?
4
A 771297
B 901768
C 917543
D 151374

output:

10133922

result:

ok single line: '10133922'

Test #48:

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

input:

3
C??
4
A 688975
B 241727
C 818932
D 91536

output:

4913592

result:

ok single line: '4913592'

Test #49:

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

input:

5
AD?CD
4
A 543418
B 284525
C 850331
D 740165

output:

3724410

result:

ok single line: '3724410'

Test #50:

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

input:

8
A?B????A
3
A 954458
B 684238
C 796348

output:

18008280

result:

ok single line: '18008280'

Test #51:

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

input:

4
?B??
2
A 581901
B 215410

output:

3189244

result:

ok single line: '3189244'

Test #52:

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

input:

2
?B
3
A 959740
B 72429
C 623651

output:

1032169

result:

ok single line: '1032169'

Test #53:

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

input:

9
A?DDABAAC
4
A 397407
B 640932
C 592671
D 217463

output:

4847785

result:

ok single line: '4847785'

Test #54:

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

input:

3
??D
4
A 376063
B 568599
C 914893
D 321187

output:

2150973

result:

ok single line: '2150973'

Test #55:

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

input:

5
??ADC
4
A 688276
B 410703
C 809171
D 184066

output:

3299855

result:

ok single line: '3299855'

Test #56:

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

input:

8
A?CCBAA?
3
A 21623
B 247434
C 127506

output:

1197267

result:

ok single line: '1197267'

Test #57:

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

input:

4
B?A?
2
A 806419
B 585499

output:

4617594

result:

ok single line: '4617594'

Test #58:

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

input:

2
?C
3
A 919848
B 927494
C 487705

output:

1950820

result:

ok single line: '1950820'

Test #59:

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

input:

9
?DB?AADC?
4
A 423449
B 362240
C 881654
D 747001

output:

8201453

result:

ok single line: '8201453'

Test #60:

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

input:

3
BCB
4
A 382899
B 573494
C 708454
D 843677

output:

1855442

result:

ok single line: '1855442'

Test #61:

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

input:

5
?B???
4
A 44235
B 882584
C 449481
D 869802

output:

8825840

result:

ok single line: '8825840'

Test #62:

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

input:

8
??C??C??
3
A 837095
B 557123
C 969486

output:

31023552

result:

ok single line: '31023552'

Test #63:

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

input:

4
?B?B
2
A 3222
B 125590

output:

1507080

result:

ok single line: '1507080'

Test #64:

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

input:

2
A?
3
A 958375
B 119559
C 696704

output:

3833500

result:

ok single line: '3833500'

Test #65:

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

input:

9
??CAD?C??
4
A 681566
B 192620
C 761507
D 860988

output:

12039031

result:

ok single line: '12039031'

Test #66:

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

input:

3
B??
4
A 712112
B 202696
C 645344
D 88110

output:

1626920

result:

ok single line: '1626920'

Test #67:

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

input:

5
BC?AC
4
A 344591
B 900818
C 44285
D 867644

output:

2234797

result:

ok single line: '2234797'

Test #68:

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

input:

8
A?A?B?A?
3
A 741498
B 816894
C 209420

output:

14327112

result:

ok single line: '14327112'

Test #69:

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

input:

4
?BAB
2
A 96615
B 49978

output:

586372

result:

ok single line: '586372'

Test #70:

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

input:

2
B?
3
A 87654
B 674557
C 679799

output:

2698228

result:

ok single line: '2698228'

Test #71:

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

input:

9
ADDDC?C?A
4
A 810389
B 122952
C 845789
D 631182

output:

6897480

result:

ok single line: '6897480'

Test #72:

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

input:

3
?DC
4
A 452330
B 336396
C 38700
D 580305

output:

1199310

result:

ok single line: '1199310'

Test #73:

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

input:

5
D?CB?
4
A 453200
B 189645
C 321087
D 191070

output:

1608202

result:

ok single line: '1608202'

Test #74:

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

input:

65536
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????B??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

408817261167

result:

ok single line: '408817261167'

Test #75:

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

input:

65536
??????????????????????????????????????????????????????????????????????????????????????Y???????????????O???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

414163904759

result:

ok single line: '414163904759'

Test #76:

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

input:

65536
????????????????????????????????????????????????????????S?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????S?????R?????????????????????????????????????????...

output:

429918490805

result:

ok single line: '429918490805'

Test #77:

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

input:

65536
?????????????????G???????????????????????????????????????????????????????????????????????????????????????????????????V????????????????????????????????????????????????????????????????????Q????????????????????????????????????????????????H???????????????????????????????????U??????????????????????...

output:

410992098572

result:

ok single line: '410992098572'

Test #78:

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

input:

65536
?????????????????????????????????????????????????????????????????????????????????????????????????????T??????????????????????????????????????????????????????????????????????????J?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

430103766471

result:

ok single line: '430103766471'

Test #79:

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

input:

65536
?????Y??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????Z?????????????????????????????????????????????...

output:

410180088397

result:

ok single line: '410180088397'

Test #80:

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

input:

65536
???????????????????????????????????????????????????????????????????????????????????????????I??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

419329955796

result:

ok single line: '419329955796'

Test #81:

score: 0
Accepted
time: 35ms
memory: 40328kb

input:

59049
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

250106507498

result:

ok single line: '250106507498'

Test #82:

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

input:

78125
?????????????????????????????????????????????????????????????????????????????????????????????R????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????C???????????????????????????????????????????????...

output:

234819569595

result:

ok single line: '234819569595'

Test #83:

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

input:

16807
??????????????????????????????R??????????????????????????????N?????????????????????????????????????????????????????????????????????????????????????????????????I??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

43680180411

result:

ok single line: '43680180411'

Test #84:

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

input:

14641
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????K?????????????????????????????????????????????????????????????????????????????????????????????????O????????????...

output:

33454441455

result:

ok single line: '33454441455'

Test #85:

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

input:

28561
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????W???????????????????????????????????????????????????W?????????????????V??????????????????????????????????????????????????J????...

output:

49883458672

result:

ok single line: '49883458672'

Test #86:

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

input:

83521
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

158411668516

result:

ok single line: '158411668516'

Test #87:

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

input:

6859
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????X??????????????????????????????????????????????????????????????????????????????????????????????????????B???C???????????????...

output:

12588914547

result:

ok single line: '12588914547'

Test #88:

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

input:

12167
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????W???I???????????????????????????????????Y???????????????????????????????????M???????????...

output:

22658354738

result:

ok single line: '22658354738'

Test #89:

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

input:

24389
???????????????????????????J??????????????R???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

44393468855

result:

ok single line: '44393468855'

Test #90:

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

input:

29791
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????W???????????????????????????????????????????????K??????H????????????...

output:

53946016293

result:

ok single line: '53946016293'

Test #91:

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

input:

50653
??????????????????????????????????????????????????O??????????????????????????????????????????????????????????A????????????????????????????????????????????????????????I??????????????????????????????????????????????????E????????????????????????????????????????????????????????????????????????????...

output:

88986693179

result:

ok single line: '88986693179'

Test #92:

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

input:

68921
?????????????????????????????????????????????????????????????????????Y??????????????????????????????????????????????????????????????????????????????????????????S?????????????????????????????????????????????????????????????V???????????????????????????????????????????????????????????????????????...

output:

119267337059

result:

ok single line: '119267337059'

Test #93:

score: 0
Accepted
time: 35ms
memory: 49488kb

input:

79507
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????R?????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

139154055708

result:

ok single line: '139154055708'

Test #94:

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

input:

2209
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????O??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????I??????????????????????????????...

output:

3568055209

result:

ok single line: '3568055209'

Test #95:

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

input:

2809
??????????????????????????B????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????B???????????????????????????????????????????????????????????????????????...

output:

4707286279

result:

ok single line: '4707286279'

Test #96:

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

input:

3481
????????????????????Q???????????????????????????????????????????????????????????????T??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

6148416013

result:

ok single line: '6148416013'

Test #97:

score: 0
Accepted
time: 2ms
memory: 5688kb

input:

3721
???????????????????????R?????????????????????????????????????????????????????????????????????????????????????????????????I?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

5789445734

result:

ok single line: '5789445734'

Test #98:

score: 0
Accepted
time: 2ms
memory: 5860kb

input:

4489
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

7200197160

result:

ok single line: '7200197160'

Test #99:

score: 0
Accepted
time: 20ms
memory: 59656kb

input:

99013
???????????????????????????????????????????????????????????????????????O??????????????????????????????????????????????????????????????????????????ML????????????????????????????????????????????????????????????????????????????????????????????I????????????????????????A????????????????????????????...

output:

92673769170

result:

ok single line: '92673769170'

Test #100:

score: 0
Accepted
time: 24ms
memory: 59704kb

input:

99017
??F?????????????????L????????????????????????????????????????????????????????????????????????????????????????????????L?????????????????????????????????????????????????????????????????X??????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

97941003883

result:

ok single line: '97941003883'

Test #101:

score: 0
Accepted
time: 19ms
memory: 59656kb

input:

99023
??????????????????????????????????????????????????????????????????????????????????????????????Y?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????P?????????????????????????????????????????????????????????...

output:

95654275894

result:

ok single line: '95654275894'

Test #102:

score: 0
Accepted
time: 16ms
memory: 59492kb

input:

99041
????????????????????????????????????????????????????????????????????????Y?????????????????????????????????????????????????????????????????????????????????????????????????????????I???????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

93073254863

result:

ok single line: '93073254863'

Test #103:

score: 0
Accepted
time: 19ms
memory: 59596kb

input:

99053
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????T???????????????????????????????????????????????????????????????????????B???????????????????????????????????????????????????????????????????????????????????????????...

output:

98418074426

result:

ok single line: '98418074426'

Test #104:

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

input:

99079
?????????????????U??????????H??????????????????????????????????????????????????????????S??????????????Y???????????????????????????????????????????????????????????????????Q???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

97288401629

result:

ok single line: '97288401629'

Test #105:

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

input:

99083
??????????????????????????????????????????????????????????????????????????????S????????????????????????????????K????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????X?????????????????????...

output:

92825739735

result:

ok single line: '92825739735'

Test #106:

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

input:

4
A??A
2
A 10
B 25

output:

120

result:

ok single line: '120'

Test #107:

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

input:

99089
???????????????L??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????H??????????????????????????????????????????????????G????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

97080921520

result:

ok single line: '97080921520'

Test #108:

score: 0
Accepted
time: 25ms
memory: 59776kb

input:

97969
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

125357288942

result:

ok single line: '125357288942'

Test #109:

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

input:

14641
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

45331258051

result:

ok single line: '45331258051'

Test #110:

score: 0
Accepted
time: 2ms
memory: 6020kb

input:

4489
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

8035067453

result:

ok single line: '8035067453'

Test #111:

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

input:

57121
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????J???????????????????????????????????????????????...

output:

100019940495

result:

ok single line: '100019940495'

Test #112:

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

input:

16129
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

29154710316

result:

ok single line: '29154710316'

Test #113:

score: 0
Accepted
time: 24ms
memory: 52764kb

input:

85849
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

153403516302

result:

ok single line: '153403516302'

Test #114:

score: 0
Accepted
time: 20ms
memory: 49604kb

input:

80089
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

140499350038

result:

ok single line: '140499350038'

Test #115:

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

input:

16129
??????????????????????????????????????????????????????????????????????????????H???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

28647844670

result:

ok single line: '28647844670'

Test #116:

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

input:

50653
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

109172167226

result:

ok single line: '109172167226'

Test #117:

score: 0
Accepted
time: 16ms
memory: 26240kb

input:

39601
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

74071898580

result:

ok single line: '74071898580'

Test #118:

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

input:

65536
HFJJIFACKVXUWPXNVQGABQJELLMRRDSSNUXDQYQKQPOKZLYKCAWSOABKSXPQNCPFTDXWMXYYLTMFZXYUDRAHYGNHKRESRPISMMQLALFZWPENZHQTNBMTBNBSCDTKLEGCJCPPFOQJOULBBEZALLMJEDHBBUAYNAEMQJBVKUFUGLOXGDYWIHZVVVWNUAKHVQBQSKRTHGKWTWTSTCQJTVZSEHKMGXMLPTRTYEUSRESYDJTEDXVPXMMKQWOROOCCAENNSPYTIYOODPEZCXBPTHYITNYLCLJWSKWSWREYGW...

output:

36920925631

result:

ok single line: '36920925631'

Test #119:

score: 0
Accepted
time: 70ms
memory: 45984kb

input:

65536
CNWFZCXRVSESVNZAOFOEPFKXMAXQGPTFKQRMZSUUUWUIKVNKQWQRGVHBPVFDSNIQKLGKBXZIORFCYQPQCGTRTKNYNACQDKPJZKELLCGEAABJIOSPRHBPUCLJNXBUUFVXCJZJBFCXOTCWCNRHRETSQIZLPGOCTZSLNGEVQPHFWKEZZEERVOQWNZKPRHRZFLFRLNSLPCZYVGGLADBZJMQNLWOGMHTYFOBDWPFIVYWRREZNDJDLVZCDDHSQEWKMQYBSSEXDEPKDXGDTLVYFBTDRBRHUCOHRKXKARBZXQR...

output:

33418955316

result:

ok single line: '33418955316'

Test #120:

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

input:

65536
HVAYEAYQYSEDEPRAFPBJPAQBSWOCUWMZSKHJUAZVBBZMUCFBTKEPXMWQQNGGHUEJAIKLXQXKBKFHNVFOAZFEVHOCRDFLDDMROWIGFWUVVCIJSWTBMUVFUMOTPAUPLSEVZIBNXMLRBRMJRSGFZOALNCDHJMZHIZYYEBEKIMXYNYYTBBSRCNXQMOVLCZASSFCTJLXQGNHUBJRDCQSNJFIALMNPOHQDVIKRAJYELDZWLUBZWDUOSXFNLWZRMESWABNAQLMUTKNVGTCGOFJMYQVBEEAABYUXMINGADMEGB...

output:

35121616697

result:

ok single line: '35121616697'

Test #121:

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

input:

65536
ASWTUGLNXJRJNLGMYVSRABUQLCNSMUIMPCBCVWCMNKBJUEWMYQODLXPMBQJQODNSDWNYXDKFFIWJEEMOGMIPFSVUZGNGMDGOUPPQHMODAPXSDHBGQLEOULQLPIOGKLJSQIZSPAPOQNERJEHKTWWSEUMLDHVPEFTNKXUWXQTKDFQIFOSBMKTDZLGHFZRELPGNPDLRUKYGDPCKNYLKXBZHFLZUQTBMXKKKKNODOWNYZGCGHSXNZWNEGHVBVCHHGFNYLZZCQEGPUYCSPDSQIUHUGNUYSDSXQHCJTDNYUQ...

output:

36201629746

result:

ok single line: '36201629746'

Test #122:

score: 0
Accepted
time: 63ms
memory: 46008kb

input:

65536
RSYVIYQFLQGFMCWAIQVEURVDPZBKCAYNLABQVLBLZKKMOKMTPSFWHQZHHARJEDBOUJQSYTPIHTYEDMDNZHEBNIJLWYOVNHHVJMJTOFMIHUSZGKCWUFSZVSFTURKLKDBAQQJTOTKRNCJNDHCFUDITLAWKOMEZOLPUMFOONCECTBZFMIJZSAEOHASMLUEKHZYKLSNZOPHWVOSREPNEQHSYWMGJXKOPBQYOZIRWEOSCETIXJCNZFQIAFYFJALCFSQLOLMDRPZOGYMXFKIYBCAKXEEVEYMHNURQPNWOLDW...

output:

36540454947

result:

ok single line: '36540454947'

Test #123:

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

input:

65536
CRJBUDTNBCXSOVWSEUSOZNWMRNQWUNQXYHTCZSHZBMAVZTWHGJEPWWBYIHWTVSSUXVILQWHXMQEZSMNKFBQWRRKGLSTHXZROITEDQVVWERONPOQCTIKTIUBNAAZXQCJQBIKSFFKSPNMOOQZYBHNJKARGEXYLZDJLSGLZBRFGAUTMQFNICFFABNQWQEXSGCLAMYMHUYCBABLEKHKJUTWQYDOGLRUJENRKYBKUWBGCNPZBTQKGLHYBSYINDFAMDVBIDZLEWPTCLWVHZASXUHWWJOXSJZYGIIWQBHEEVM...

output:

30273753231

result:

ok single line: '30273753231'

Test #124:

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

input:

65536
PLYDJRAQWTXQDUBVPAFWMXUVAQFVENBGTXLKSTGCWEWWMZMTBODQINGHEXAHBYUDFZDFPTFDKCUBXFHXPFAIFYEFPUHBNJVPUQSPUXEHQEWDWUGUXBZYVEZTFXFBRCSTATHTWZWEFZQZYZLGQWQAXKJQCSESDGYGORAGPBNGWUJZTIAXSVZZWLMIUMAHBSZKNALTKORUFCBUIBVICGYTFKMRPFXWKLOQNOHUGHYZCASGCYAUXJACPEXPQSAIJKVMFMTPUHMRCHZYXQFUGKCHGQSUEDFFCIALXCTUOI...

output:

38589801757

result:

ok single line: '38589801757'

Test #125:

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

input:

65536
MIRUYSTHTILUUDQNEZOYHJSBZSANSEBZLWSNFGNRARBCGXAAXXGOEYMMJAZMUFTQZYXLVUNFSWUWIBNRHGBYEYWHEIYQOHWFLZKLGNEOLZRCHHNZHUQVXGXXGKUSSHUSQERKNKCPZUNHEFVIPMEDATVYULQSFTUMQFFDCZRCDAONMGLLHKMOULBZHJFYSDWNCRNYKTGNQCVNFRKMNNFANWJSLQVXYQIOMXBCYDFMXMAGDMAMJGQHAHRHFUFZGLZJZNIPIJAZRBUUJNUJHAZNTQQMUYXGUCJHSGXNDL...

output:

35559501063

result:

ok single line: '35559501063'

Test #126:

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

input:

65536
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

587396612096

result:

ok single line: '587396612096'

Test #127:

score: 0
Accepted
time: 63ms
memory: 46076kb

input:

65536
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????A??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

778365435904

result:

ok single line: '778365435904'

Test #128:

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

input:

65536
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

590010371328

result:

ok single line: '590010371328'

Test #129:

score: 0
Accepted
time: 68ms
memory: 45948kb

input:

65536
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????B????????????????????????????????????????...

output:

590875541724

result:

ok single line: '590875541724'

Test #130:

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

input:

65536
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

559333050720

result:

ok single line: '559333050720'

Test #131:

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

input:

65536
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

509113239978

result:

ok single line: '509113239978'

Test #132:

score: 0
Accepted
time: 67ms
memory: 46068kb

input:

65536
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

438046231002

result:

ok single line: '438046231002'

Test #133:

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

input:

65536
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????D??????????????????????????????????????????...

output:

613743427168

result:

ok single line: '613743427168'

Test #134:

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

input:

65536
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????C???????????????????????????????????????????????????????????????????????????...

output:

460816762199

result:

ok single line: '460816762199'

Test #135:

score: 0
Accepted
time: 72ms
memory: 45996kb

input:

65536
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

503034878751

result:

ok single line: '503034878751'

Test #136:

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

input:

65536
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

775616921600

result:

ok single line: '775616921600'