QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#618641#9435. Welcome to NPCAPCKlaus26TL 2607ms3912kbC++202.0kb2024-10-07 01:43:182024-10-07 01:43:25

Judging History

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

  • [2024-10-07 01:43:25]
  • 评测
  • 测评结果:TL
  • 用时:2607ms
  • 内存:3912kb
  • [2024-10-07 01:43:18]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "../debug.h"
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = long long;
using lf = long double;

const ll mod = 998244353;
const int Z = 26 * 2;


struct Matrix{
	int n, m;
	vector<vector<ll>> mx;
	Matrix(){}
	Matrix(int r, int c, int identity = false): n(r), m(c){
		mx.assign(n, vector<ll> (m));
		if( identity ){
			for(int i=0; i<n; ++i){
				mx[i][i] = 1;
			}
		}
	}
	Matrix operator * (const Matrix & o ) const {
		Matrix ret(n, o.m);
		for(int i=0; i<n; ++i){
			for(int j=0; j<o.m; ++j){
				ll& sum = ret.mx[i][j];
				for(int k=0; k<m; ++k){
					sum = ( sum + mx[i][k] * o.mx[k][j] % mod ) % mod;
				}
			}
		}
		return ret;
	}
};

Matrix mx_fpow(Matrix x, int e){
	Matrix ret(x.n,x.m,1);
	while(e){
		if(e&1) ret = ret * x;
		x = x * x;
		e >>= 1;
	}
	return ret;
}

string s = "AAAAAA", t = "aaaaaa";

vector<string> st;
void solve(int i, int j, string& cur){
	if( i == 6 && j == 6){
		st.push_back(cur);
	}else{
		if(i<6){
			cur.push_back(s[i]);
			solve(i+1,j,cur);
			cur.pop_back();
		}
		if(j<6){
			cur.push_back(t[j]);
			solve(i,j+1,cur);
			cur.pop_back();
		}
	}
}

bool isUpper(char x){
	return 'A' <= x && x <= 'Z';
}

bool isLower(char x){
	return 'a' <= x && x <= 'a';
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	string c = "";
	solve(0,0,c);
	sort(st.begin(),st.end());
	st.resize( unique(st.begin(),st.end()) - st.begin() );
	int T;
	cin >> T;
	while(T--){
		int n;
		cin >> n;
		ll tot = 0;
		for(auto& cur : st){
			const int N = 12;
			vector<int> values(N);
			int lw = 0, up = 0;
			for(int i=N-1; i>=0; --i){
				lw |= isLower(cur[i]);
				up |= isUpper(cur[i]);
				values[i] = Z - lw - up;
			}
			Matrix ans(N+1,N+1);
			for(int i=0; i<N; ++i){
				ans.mx[i][i] = values[i];
				ans.mx[i][i+1] = 1;
			}
			ans.mx[12][12] = Z;
			ans = mx_fpow(ans,n);
			tot = (tot +  ans.mx[0][12] ) % mod;
		}
		cout << tot << '\n';
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 303ms
memory: 3656kb

input:

4
12
6
5839
123456

output:

924
0
966252995
432934749

result:

ok 4 number(s): "924 0 966252995 432934749"

Test #2:

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

input:

3
123456789
987654321
999999999

output:

333574957
124462731
163251704

result:

ok 3 number(s): "333574957 124462731 163251704"

Test #3:

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

input:

10
19425
102461
155567
158836
113140
53389
161281
4594
30575
108615

output:

373186365
206571483
970383134
989350567
625537601
996030441
764136313
478343127
585610797
77642861

result:

ok 10 numbers

Test #4:

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

input:

10
194023
129263
48544
122512
184189
36584
109090
185910
157471
165449

output:

646584725
685247409
562517647
135100440
554171085
18276445
599247609
645458744
157353305
961701460

result:

ok 10 numbers

Test #5:

score: 0
Accepted
time: 1301ms
memory: 3840kb

input:

10
62619
102803
103157
53078
141131
131278
107572
72144
3962
2993

output:

336681005
218835081
977425093
939622730
599861248
730434007
143005189
81452469
648743259
392146337

result:

ok 10 numbers

Test #6:

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

input:

10
115339
14918
142121
161511
64217
158940
60253
133675
8663
16414

output:

447424283
701409014
925899837
229615050
384906046
868361271
510779619
719867379
676960448
767190917

result:

ok 10 numbers

Test #7:

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

input:

10
85495
199819
142473
79698
166538
169504
10264
127098
60974
49524

output:

758217665
362989371
849601874
914823277
258052558
895462991
815236067
354182017
319596227
827075400

result:

ok 10 numbers

Test #8:

score: 0
Accepted
time: 1243ms
memory: 3564kb

input:

10
1425
152469
89993
198158
35858
99757
121657
13600
1674
146517

output:

696406093
386918828
204106049
632497695
611949542
844728055
614167688
322636556
426859719
892745895

result:

ok 10 numbers

Test #9:

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

input:

10
54362
116337
187366
29763
59353
2441
42427
123694
39351
17442

output:

770174476
485360795
966181928
673166447
778039253
223255284
308023018
467109595
776512421
478342322

result:

ok 10 numbers

Test #10:

score: 0
Accepted
time: 1334ms
memory: 3668kb

input:

10
164862
189993
197025
186958
183986
19454
195717
3595
37637
12900

output:

947618397
310127426
515768872
713650103
443160420
174103041
140536245
261888957
199480824
62935695

result:

ok 10 numbers

Test #11:

score: 0
Accepted
time: 1364ms
memory: 3720kb

input:

10
28188
195373
19757
86671
172167
174607
177795
177036
12036
112202

output:

503461377
349476278
864992772
433340965
139666723
854367908
243493730
1094272
259503082
826525753

result:

ok 10 numbers

Test #12:

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

input:

10
88207
181591
178531
140277
166887
34746
6840
165413
59380
59478

output:

143757409
281674172
448638880
297367509
478750591
255032414
933878821
32023173
935444021
274623740

result:

ok 10 numbers

Test #13:

score: 0
Accepted
time: 1284ms
memory: 3880kb

input:

10
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000

output:

506140892
506140892
506140892
506140892
506140892
506140892
506140892
506140892
506140892
506140892

result:

ok 10 numbers

Test #14:

score: 0
Accepted
time: 1415ms
memory: 3880kb

input:

10
199536
199550
199072
199194
199060
199366
199657
199655
199094
199719

output:

481722685
54139495
880783257
99692802
662599550
24374548
920897431
172638709
252873358
209225624

result:

ok 10 numbers

Test #15:

score: 0
Accepted
time: 1457ms
memory: 3560kb

input:

10
199807
199096
199795
199167
199711
199872
199869
199819
199926
199350

output:

367522490
286203805
693295181
50327284
88810278
219613677
982654709
362989371
966844602
867613613

result:

ok 10 numbers

Test #16:

score: 0
Accepted
time: 1414ms
memory: 3608kb

input:

10
199593
199408
199421
199293
199794
199460
199729
199105
199372
199022

output:

466283395
553823751
380000204
487478554
575318483
864937097
426511912
44082833
707337922
239404455

result:

ok 10 numbers

Test #17:

score: 0
Accepted
time: 1456ms
memory: 3616kb

input:

10
200000
199999
199998
199997
199996
199995
199994
199993
199992
199991

output:

506140892
911964033
303924978
398821586
438893397
76590482
411029242
892235395
594543147
771453296

result:

ok 10 numbers

Test #18:

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

input:

10
11
10
9
8
7
6
5
4
3
2

output:

0
0
0
0
0
0
0
0
0
0

result:

ok 10 numbers

Test #19:

score: 0
Accepted
time: 253ms
memory: 3720kb

input:

10
10
9
8
7
6
5
4
3
2
1

output:

0
0
0
0
0
0
0
0
0
0

result:

ok 10 numbers

Test #20:

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

input:

10
740346385
341459044
685873195
712330160
845425986
109013394
244579134
217830251
547169313
609684204

output:

766699231
847872712
203527560
272258995
208976108
621776344
205331484
613050178
954364000
939977995

result:

ok 10 numbers

Test #21:

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

input:

10
104220438
220012808
722191216
150219939
239504792
832701733
180959602
411203729
358722728
926309434

output:

47120700
867174187
689002154
448054783
567162499
677117785
303174119
86224452
99068205
898725628

result:

ok 10 numbers

Test #22:

score: 0
Accepted
time: 2370ms
memory: 3912kb

input:

10
159983782
57923501
570206283
171249114
415797489
256627352
848767359
432894583
918419336
695084407

output:

614174608
11173041
638188107
249991097
978029063
377705598
394358867
51979335
679246508
262030655

result:

ok 10 numbers

Test #23:

score: 0
Accepted
time: 2382ms
memory: 3564kb

input:

10
906347660
743630516
777024166
457126026
154388907
514131440
466683846
805146349
660244963
549114563

output:

292886558
512127240
662644256
881503705
848032095
919829066
563499920
884669631
524186103
525510963

result:

ok 10 numbers

Test #24:

score: 0
Accepted
time: 2318ms
memory: 3680kb

input:

10
17504426
925387034
763325931
11640610
82737460
917937999
121446212
897045905
101598639
178843375

output:

777648359
269584314
111674710
516486440
725205194
343741197
767898898
198028941
890451307
248901012

result:

ok 10 numbers

Test #25:

score: 0
Accepted
time: 2288ms
memory: 3880kb

input:

10
277265119
889108337
912629604
23822798
817824711
70860624
34850777
407740702
137686408
41846681

output:

923590372
246907747
111616575
379917071
102567920
77332262
452913300
629739392
558526565
389432722

result:

ok 10 numbers

Test #26:

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

input:

10
950032065
508026481
939844586
12008461
896500100
591930415
216515648
813399922
865351143
416775810

output:

128816496
128076409
844122369
415175189
130339000
813456407
224205618
724316572
627750175
290125408

result:

ok 10 numbers

Test #27:

score: 0
Accepted
time: 2335ms
memory: 3716kb

input:

10
593149450
303742247
287333477
456793130
862554620
227164737
665577687
489388140
144126441
905298962

output:

623439114
633586059
336145307
246697813
686448635
326871422
794408704
897058485
667471246
289169102

result:

ok 10 numbers

Test #28:

score: 0
Accepted
time: 2291ms
memory: 3584kb

input:

10
298032406
958808309
907721166
205825741
650840964
336151424
601275205
508094947
939661061
148729256

output:

30846803
215687416
739529557
32705184
930044027
247195624
291584472
435484359
347164105
884608928

result:

ok 10 numbers

Test #29:

score: 0
Accepted
time: 2379ms
memory: 3616kb

input:

10
955407778
663321698
720183776
770914211
846318993
85404917
741389294
689761431
563669782
907676224

output:

288290428
280089649
957601148
975327153
809339109
143518480
33667515
812426512
432736785
596026119

result:

ok 10 numbers

Test #30:

score: 0
Accepted
time: 2430ms
memory: 3848kb

input:

10
999948806
999959496
999923971
999971001
999975544
999923826
999936371
999974101
999969078
999961603

output:

165875776
243162678
42249804
726484281
922576576
862146096
805390244
712324931
241422988
918366968

result:

ok 10 numbers

Test #31:

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

input:

10
999935331
999901601
999912981
999963436
999939815
999959974
999960470
999990911
999993914
999961413

output:

83467952
595290880
195385357
895425567
934735430
562787212
360938884
865596390
551422898
462573157

result:

ok 10 numbers

Test #32:

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

input:

10
999934787
999951830
999976785
999981483
999934509
999980169
999961050
999941794
999908311
999990184

output:

741247231
460580920
707825183
721619217
848455287
977235033
367140794
300510062
173250866
902901966

result:

ok 10 numbers

Test #33:

score: 0
Accepted
time: 2607ms
memory: 3908kb

input:

10
1000000000
999999999
999999998
999999997
999999996
999999995
999999994
999999993
999999992
999999991

output:

320556054
163251704
169354215
887053493
577433400
664002115
687518575
384589591
141047287
326295284

result:

ok 10 numbers

Test #34:

score: 0
Accepted
time: 2284ms
memory: 3560kb

input:

10
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000

output:

320556054
320556054
320556054
320556054
320556054
320556054
320556054
320556054
320556054
320556054

result:

ok 10 numbers

Test #35:

score: -100
Time Limit Exceeded

input:

5000
818833582
360470268
372417686
382951017
249252660
522603147
182966996
840247325
184328603
265669824
494221452
986930588
178703088
206919687
923146513
827827836
829632563
23157967
521402859
410821226
512420277
838171069
722174187
3979662
314177774
797293065
880327999
584084783
565197444
95327062...

output:


result: