QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#742263#2506. 数列Parsley_100 ✓68ms18840kbC++141.5kb2024-11-13 16:13:242024-11-13 16:13:30

Judging History

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

  • [2024-11-13 16:13:30]
  • 评测
  • 测评结果:100
  • 用时:68ms
  • 内存:18840kb
  • [2024-11-13 16:13:24]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int N = 35, M = 105, mod = 998244353;

int n, m, K;

int pwv[M][N];
int C[N][N];
int f[M][N][N][N];
int v[M];

inline int popcount(int x) {
	int ret = 0;
	while (x) ret += x & 1, x >>= 1;
	return ret;
}

int main()
{
	cin >> n >> m >> K;
	for (int i = 0; i <= m; i++) cin >> v[i];
	C[0][0] = 1;
	for (int i =1 ; i <= n; i++) {
		C[i][0] = 1;
		for (int j = 1; j <= i; j++) {
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
		}
	}
	for (int i = 0; i <= m; i++) {
		pwv[i][0] = 1;
		for (int j = 1; j <= n; j++) {
			pwv[i][j] = 1ll * pwv[i][j - 1] * v[i] % mod;
		}
	}
	
	// 解释一下f[i][j][k][p]的含义
	// 在S中确定了前i-1位,现在考虑i位,或者说,是用了v[0]~v[i-1],现在用v[i]
	// 使用了a数组中的前j个数
	// k表示前i-1位中有多少个1
	// 向i位进位p个1
	f[0][0][0][0] = 1;
	for (int i = 0; i <= m; i++) {
	for (int j = 0; j <= n; j++) {
	for (int k = 0; k <= K; k++) { // mention
	for (int p = 0; p <= n / 2; p++) { // mention
	for (int t = 0; t <= n -j; t++) {
		f[i + 1][j + t][k + (t + p & 1)][(t + p) / 2] = 
		(f[i + 1][j + t][k + (t + p & 1)][(t + p) / 2] + 
		 1ll * f[i][j][k][p] * pwv[i][t] %mod * C[n - j][t] % mod
		) % mod;
		
	}}}}}
	
	int ans = 0;
	// we must need a f[m + 1][n][k][p]
	for (int k = 0; k <= K; k++) {
		for (int p = 0; p <= n / 2; p++) {
			if (popcount(p) + k <= K)
				ans = (ans + f[m + 1][n][k][p]) % mod;
		}
	}
	cout << ans << "\n";
	return 0;
}

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

详细


Pretests


Final Tests

Test #1:

score: 5
Accepted
time: 1ms
memory: 4072kb

input:

8 9 1
499488183 118995914 332316574 399234563 246850128 338768262 489466833 673193710 723933572 12759125

output:

789420212

result:

ok single line: '789420212'

Test #2:

score: 5
Accepted
time: 1ms
memory: 3984kb

input:

8 9 3
215521602 492908007 261206435 521145497 259750366 553629902 997991039 523071946 767416953 56767036

output:

450775894

result:

ok single line: '450775894'

Test #3:

score: 5
Accepted
time: 1ms
memory: 4048kb

input:

8 9 5
396559700 356016879 796231055 117198018 986043211 5573279 915325714 896890982 238440937 772820521

output:

34463958

result:

ok single line: '34463958'

Test #4:

score: 5
Accepted
time: 1ms
memory: 4044kb

input:

8 9 8
823551883 246279514 512316795 50015811 596048859 634297559 357816173 172030638 277258510 920803140

output:

650836255

result:

ok single line: '650836255'

Test #5:

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

input:

30 7 5
277343567 231557726 518417466 839831772 308153685 661255375 10400942 137452650

output:

570273281

result:

ok single line: '570273281'

Test #6:

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

input:

30 7 6
769481383 218933928 397917786 715817994 28458205 1741468 432666671 767453624

output:

802897416

result:

ok single line: '802897416'

Test #7:

score: 5
Accepted
time: 4ms
memory: 4812kb

input:

30 7 9
560097542 225678652 985380091 657360686 588960965 286023927 39451645 813153395

output:

200784526

result:

ok single line: '200784526'

Test #8:

score: 5
Accepted
time: 5ms
memory: 5544kb

input:

30 12 7
233649570 882345965 363522936 697518226 276565878 305171861 862016201 694650802 295202855 895115917 87982489 198145962 118457524

output:

191413880

result:

ok single line: '191413880'

Test #9:

score: 5
Accepted
time: 5ms
memory: 5572kb

input:

30 12 8
280972635 121394003 96961086 311593799 16824904 872035232 806270513 706873478 838387709 911762507 518375946 363189973 93846934

output:

878193241

result:

ok single line: '878193241'

Test #10:

score: 5
Accepted
time: 8ms
memory: 5592kb

input:

30 12 14
33118764 570808334 277911327 206225040 739764940 873120222 787166401 297143172 542645907 209959496 558572198 749568456 492469905

output:

8638776

result:

ok single line: '8638776'

Test #11:

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

input:

30 100 1
280989359 685610909 652483091 218262426 612187297 933993851 128465889 118119862 758459128 482869427 840417548 996214463 836110953 8956015 894945622 619560556 219818505 29451496 358272495 696206257 230342287 851588985 859573270 833968093 763204877 853785448 282969832 273841812 923102044 4584...

output:

918455864

result:

ok single line: '918455864'

Test #12:

score: 5
Accepted
time: 10ms
memory: 18080kb

input:

30 100 1
238187011 269812145 373797704 493559311 525459197 494840062 127348462 781447685 540053429 448451906 15397875 202443100 38732140 40023578 278484005 462334159 562679988 736926803 282626752 723781472 662277299 358863810 27984540 832197799 962665975 699557436 986649610 436908753 320494341 95769...

output:

524381135

result:

ok single line: '524381135'

Test #13:

score: 5
Accepted
time: 14ms
memory: 17264kb

input:

30 100 1
624756242 578099224 322063599 955163372 527409783 886224870 196768173 678404094 71254380 400463809 462704961 522697398 174568824 839996207 181664607 564129436 324853491 954240664 279841814 134343701 734819121 855324702 517923195 647253253 321867400 801360468 25886504 866237487 301424065 286...

output:

483241545

result:

ok single line: '483241545'

Test #14:

score: 5
Accepted
time: 1ms
memory: 4968kb

input:

5 50 2
254286688 725442098 427960764 796779405 986706963 905854411 818897107 964334286 867743930 583810772 621078041 875275863 94943935 993613474 699229610 139437533 160785883 74877034 8820884 154629232 776225564 385632450 792900606 570001565 857615216 758514611 34346579 426872784 329305393 59552423...

output:

816583992

result:

ok single line: '816583992'

Test #15:

score: 5
Accepted
time: 1ms
memory: 5072kb

input:

5 50 3
398838269 62831191 767680179 548733975 555826543 359315797 126732814 236236917 736299966 477904769 853166426 287461631 463135258 178798437 997403650 87158184 572906600 697966474 960138109 242347816 879956491 777432793 390570007 708647774 714109560 612901589 377307686 585724634 560144176 50107...

output:

937159818

result:

ok single line: '937159818'

Test #16:

score: 5
Accepted
time: 4ms
memory: 11396kb

input:

15 100 8
537276628 100186052 185892981 934916070 567805882 918515644 431750302 796355931 218646822 867528879 340335349 895838502 324783806 28262471 36921137 16069248 30657555 649491332 119673208 552651140 623025591 114876021 403198375 59453768 518635907 617927870 217741861 573018213 950960313 720041...

output:

272087880

result:

ok single line: '272087880'

Test #17:

score: 5
Accepted
time: 15ms
memory: 8256kb

input:

30 30 15
60466183 610467381 171141086 693914857 963904829 564659588 530320949 440079007 365069705 829699120 283564411 328402092 300168872 613261423 746486046 10288211 360128573 745361137 454560349 807372883 536663856 136356261 883801886 164316038 21520306 943453842 666136933 543391844 857298855 3384...

output:

72174927

result:

ok single line: '72174927'

Test #18:

score: 5
Accepted
time: 23ms
memory: 8316kb

input:

30 30 27
791704008 141733617 624846593 851709929 992710617 212811783 633109877 793261502 936354310 396919562 836912348 231815656 963288997 740034788 423011666 759150033 384434935 683576701 853721112 420009380 582576185 749031968 9524373 451203892 109835437 775487403 621839989 303055045 36699775 3463...

output:

253611021

result:

ok single line: '253611021'

Test #19:

score: 5
Accepted
time: 49ms
memory: 18756kb

input:

30 100 16
875698537 331313447 201148316 859357152 75556427 84009302 29165462 183164679 801095477 362574916 174220357 904633392 840544725 26263814 209015337 148424354 181158359 130045322 130726397 756114144 893268484 890267565 401189740 163241681 937879687 734913073 137564816 583877304 334189462 8327...

output:

221099086

result:

ok single line: '221099086'

Test #20:

score: 5
Accepted
time: 68ms
memory: 18840kb

input:

30 100 21
316605536 504649194 334973924 478542137 897005201 967219463 982199815 294027518 578515247 444956501 169932813 517443072 608712080 853574514 517686368 318771389 413578320 648466530 224572747 536246850 615211381 271710227 740813454 795114103 726388592 324201075 793546883 933899825 539137621 ...

output:

483943039

result:

ok single line: '483943039'

Extra Test:

score: 0
Extra Test Passed