QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#497472#9115. Contour Multiplicationucup-team3282WA 706ms40424kbC++14797b2024-07-29 09:39:272024-07-29 09:39:28

Judging History

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

  • [2024-07-29 09:39:28]
  • 评测
  • 测评结果:WA
  • 用时:706ms
  • 内存:40424kb
  • [2024-07-29 09:39:27]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=18;
const int maxk=5e5+10;

int n,mod,k;
int f[2][(1<<maxn)+10][maxn];

int main(){
	ios::sync_with_stdio(0);
	cin>>n>>mod>>k;
	int U=(1<<n)-1;
	for(int S=0;S<=U;S++)
		for(int i=0;i<=n;i++)
			f[0][S][i]=f[1][S][i]=1;
	for(int i=1;i<=k;i++){
		int c,d,x;
		cin>>c>>d>>x;
		f[0][c][d]=(ll)f[0][c][d]*x%mod;
	}
	for(int i=0;i<n;i++){
		for(int s=0;s<=U;s++)
			for(int j=0;j<=n;j++){
				if(j>0)
					f[i&1^1][s^(1<<i)][j-1]=(ll)f[i&1^1][s^(1<<i)][j-1]*f[i&1][s][j]%mod;
				f[i&1^1][s][j]=(ll)f[i&1^1][s][j]*f[i&1][s][j]%mod;
			}
		for(int s=0;s<=U;s++)
			for(int j=0;j<=n;j++)
				f[i&1][s][j]=1;
	}
	for(int i=0;i<=U;i++)
		cout<<f[n&1][i][0]<<' ';
	cout<<endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 100 2
0 2 4
3 0 25

output:

1 1 1 0 1 4 4 1 

result:

ok 8 tokens

Test #2:

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

input:

4 998244353 7
0 2 4
3 0 25
9 4 37
4 1 16
6 3 8
1 4 68
13 3 97

output:

1552 8 1 9700 1 64 229696 1 8 4 388 8 64 8 68 1 

result:

ok 16 tokens

Test #3:

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

input:

1 2 1
0 1 696782227

output:

1 1 

result:

ok 2 tokens

Test #4:

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

input:

5 461799503 500000
26 2 741819583
24 4 16805970
5 2 192769861
5 4 365614234
31 0 680795402
23 5 256636931
24 4 150277578
3 1 912506287
27 5 785022824
1 4 645930009
8 2 715559837
3 4 166807726
22 2 584850050
23 1 481241174
7 0 947410124
0 4 588117991
13 5 882053755
16 5 430265734
29 5 324612363
9 4 8...

output:

0 0 45928586 0 134497770 0 206758057 394352068 0 244291949 0 209807785 0 285761102 402778530 0 0 0 61435341 287059619 347978730 135518317 363576818 0 0 0 0 0 0 0 0 349412261 

result:

ok 32 tokens

Test #5:

score: 0
Accepted
time: 90ms
memory: 6336kb

input:

13 471577301 500000
6468 6 306578522
8113 3 479854366
720 5 444779113
8132 12 228254993
6354 13 64735677
6877 9 421810792
541 9 278526040
3090 0 986913987
5352 8 16271033
3263 5 929162219
3483 8 459160836
5355 12 867871503
3035 9 877478088
4090 10 88145277
468 6 252659128
4500 6 628030207
455 5 2083...

output:

295995843 436808476 339073319 155918282 48455511 1287988 263069937 40898455 250933189 115069799 274609439 140251254 130482131 221130936 48158903 362421527 310052080 102853257 367494088 214098183 133285802 100856795 170719263 335861409 110676293 435022783 13399750 339217190 201068790 224869164 579876...

result:

ok 8192 tokens

Test #6:

score: 0
Accepted
time: 371ms
memory: 26352kb

input:

17 776322399 500000
4238 2 949485315
55273 2 237870062
18140 17 991755666
3716 11 874076305
56421 6 370528096
44131 7 213869498
123361 5 779889655
14050 15 844502241
121141 15 30699796
3357 1 429213877
111087 3 497729135
57491 12 942050435
56577 6 386925573
101116 9 695049379
119745 5 557908130
4848...

output:

607821963 435030711 61464891 533141760 226500969 217414755 501264864 288361389 632731971 68903544 602992200 555115194 113967195 306579312 377033709 674976501 523269435 299103978 680309115 251645877 16963974 320830545 637207830 697053579 603067512 9627471 269126778 224492217 218616426 108838875 56676...

result:

ok 131072 tokens

Test #7:

score: 0
Accepted
time: 71ms
memory: 5872kb

input:

11 491132898 500000
2007 5 514244254
34 3 290853058
743 9 616880073
1348 1 736717064
2040 3 754468370
1513 9 300895505
422 5 908138116
433 6 918909941
1410 6 966980703
1403 7 417478787
1602 1 241330134
1083 9 311196667
1574 10 269488211
1535 2 928838328
1454 1 863157133
316 10 196067895
634 9 372754...

output:

414133272 474484338 256673952 140105142 195317172 476786178 58733460 140213250 277643358 403460928 60165954 435023046 445753188 301547322 295684974 51032322 182346084 318614076 291117042 26058744 2338686 39639294 158298426 332380512 456925698 160618824 233964054 278105418 272143008 237853602 3969225...

result:

ok 2048 tokens

Test #8:

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

input:

15 579058550 500000
32545 3 157151048
18523 15 753901453
3827 12 163856627
27651 15 304390524
9099 12 548474043
3952 11 876134765
8555 11 741419277
19584 7 993317642
25039 15 903261611
19930 13 622563144
31381 13 201750579
14308 11 385375599
16204 5 483968395
257 15 535742431
14234 8 168406136
5392 ...

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 32768 tokens

Test #9:

score: 0
Accepted
time: 69ms
memory: 5668kb

input:

1 883803649 500000
0 0 16877287
0 0 511917149
0 0 710833180
1 1 245179137
0 1 854266463
0 1 963160772
1 0 947815593
1 0 145873197
1 0 917690374
0 1 122614801
0 0 240318877
0 1 459554531
0 0 71563734
0 0 142646535
1 0 473655139
0 0 764105581
1 0 459003177
0 1 699373680
1 0 343384433
1 0 659732785
1 1...

output:

0 0 

result:

ok 2 tokens

Test #10:

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

input:

9 893581447 500000
436 0 581636226
205 9 269932845
266 4 962842432
387 4 517885295
177 8 238206737
124 8 50186780
244 0 76064055
30 9 630346296
106 7 853971282
150 9 405847011
315 6 983919875
308 1 828700763
407 0 581011218
262 5 454583337
372 1 73871442
184 6 509050498
391 6 80275234
426 9 99655915...

output:

668718083 173925928 614241298 507965183 286658361 766976287 646875922 244456289 779102082 506578875 230749255 625692100 419633885 550049896 789747167 721376656 736167531 606974500 602727697 607975071 340181127 595354496 508276406 231750882 310922216 228355490 526648617 882696320 544439324 599197819 ...

result:

ok 512 tokens

Test #11:

score: -100
Wrong Answer
time: 706ms
memory: 40424kb

input:

18 798547896 500000
127781 5 700634392
187048 4 461074149
85414 5 560703099
152376 5 45078516
173616 3 370561806
103182 4 278920182
133392 4 745396914
208374 4 790769334
1671 5 889763129
259586 3 975955043
34043 3 927380442
7253 3 63867802
47965 3 793901753
14380 5 824806721
253914 4 941100282
90157...

output:

366699312 624462048 711682200 331082640 790692192 383796792 581511960 734294808 246983256 437954040 381970728 502779960 312491520 241764912 479389104 145518120 433060992 748038240 569157840 648335016 655128648 460011312 692789760 221700888 49502664 451022904 538071336 603427968 189162216 599141448 6...

result:

wrong answer 2nd words differ - expected: '201991320', found: '624462048'