QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#852052#8702. 狼人杀ANIG100 ✓2705ms151116kbC++141.0kb2025-01-11 09:53:472025-01-11 09:53:49

Judging History

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

  • [2025-01-11 09:53:49]
  • 评测
  • 测评结果:100
  • 用时:2705ms
  • 内存:151116kb
  • [2025-01-11 09:53:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=155,M=3e4+5,mods=1e9+7;
int pows(int a,int b){
	if(b==0)return 1;
	int res=pows(a,b>>1);
	res=res*res%mods;
	if(b&1)res=res*a%mods;
	return res;
}
int n,m,inv[M],res,f[2][N][M][2],rs[N][M][2],gs[M];
int C(int x){
	return x*(x+1)/2;
}
signed main(){
	cin>>n>>m;
	int K=n*(n+1)/2;
	for(int i=1;i<=n*n;i++)inv[i]=pows(i,mods-2);
	f[0][0][0][0]=-1;
	for(int i=1;i<=n+1;i++){
		for(int j=0;j<i;j++){
			for(int k=0;k+C(i-j-1)<=K;k++){
				f[0][j][k][0]%=mods;
				f[0][j][k][1]%=mods;
				if(i==m){
					f[1][j][k][0]+=f[0][j][k][0];
					f[1][j][k][1]+=f[0][j][k][1];
				}else{
					f[1][j][k][0]+=f[0][j][k][0];
					f[1][i][k+C(i-j-1)][0]-=f[0][j][k][0];
					f[1][j][k][1]+=f[0][j][k][1];
					f[1][i][k+C(i-j-1)][1]-=f[0][j][k][1];
					f[1][j][k][1]+=f[0][j][k][0];
				}
			}
		}
		swap(f[1],f[0]);
		memset(f[1],0,sizeof(f[1]));
	}
	for(int i=0;i<=K;i++)res-=inv[K-i]*(f[0][n+1][i][1]%mods)%mods;
	cout<<(res%mods*K%mods*inv[n-1]%mods+mods)%mods;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 23
Accepted

Test #1:

score: 23
Accepted
time: 198ms
memory: 149788kb

input:

12 2

output:

183756997

result:

ok single line: '183756997'

Test #2:

score: 23
Accepted
time: 268ms
memory: 149564kb

input:

17 6

output:

97571903

result:

ok single line: '97571903'

Test #3:

score: 23
Accepted
time: 226ms
memory: 150148kb

input:

13 3

output:

209826617

result:

ok single line: '209826617'

Test #4:

score: 23
Accepted
time: 220ms
memory: 149388kb

input:

13 8

output:

176038768

result:

ok single line: '176038768'

Test #5:

score: 23
Accepted
time: 294ms
memory: 149860kb

input:

18 4

output:

288404061

result:

ok single line: '288404061'

Test #6:

score: 23
Accepted
time: 163ms
memory: 150616kb

input:

10 10

output:

219657163

result:

ok single line: '219657163'

Test #7:

score: 23
Accepted
time: 320ms
memory: 149048kb

input:

19 15

output:

590577825

result:

ok single line: '590577825'

Test #8:

score: 23
Accepted
time: 204ms
memory: 149280kb

input:

11 6

output:

488143489

result:

ok single line: '488143489'

Test #9:

score: 23
Accepted
time: 169ms
memory: 149656kb

input:

10 5

output:

470594541

result:

ok single line: '470594541'

Test #10:

score: 23
Accepted
time: 348ms
memory: 151036kb

input:

20 5

output:

582458555

result:

ok single line: '582458555'

Test #11:

score: 23
Accepted
time: 322ms
memory: 150848kb

input:

20 12

output:

648081410

result:

ok single line: '648081410'

Test #12:

score: 23
Accepted
time: 330ms
memory: 149252kb

input:

20 4

output:

335777285

result:

ok single line: '335777285'

Test #13:

score: 23
Accepted
time: 336ms
memory: 150132kb

input:

20 15

output:

389216500

result:

ok single line: '389216500'

Test #14:

score: 23
Accepted
time: 330ms
memory: 150180kb

input:

20 16

output:

582458555

result:

ok single line: '582458555'

Test #15:

score: 23
Accepted
time: 334ms
memory: 149552kb

input:

20 19

output:

589126150

result:

ok single line: '589126150'

Test #16:

score: 23
Accepted
time: 327ms
memory: 149324kb

input:

20 6

output:

389216500

result:

ok single line: '389216500'

Subtask #2:

score: 34
Accepted

Dependency #1:

100%
Accepted

Test #17:

score: 34
Accepted
time: 770ms
memory: 150104kb

input:

49 14

output:

486918542

result:

ok single line: '486918542'

Test #18:

score: 34
Accepted
time: 453ms
memory: 150296kb

input:

28 13

output:

642223597

result:

ok single line: '642223597'

Test #19:

score: 34
Accepted
time: 570ms
memory: 150484kb

input:

35 23

output:

842346505

result:

ok single line: '842346505'

Test #20:

score: 34
Accepted
time: 749ms
memory: 149876kb

input:

47 11

output:

583647040

result:

ok single line: '583647040'

Test #21:

score: 34
Accepted
time: 544ms
memory: 150008kb

input:

34 30

output:

990970048

result:

ok single line: '990970048'

Test #22:

score: 34
Accepted
time: 489ms
memory: 149612kb

input:

30 7

output:

393675971

result:

ok single line: '393675971'

Test #23:

score: 34
Accepted
time: 691ms
memory: 150152kb

input:

43 5

output:

737421246

result:

ok single line: '737421246'

Test #24:

score: 34
Accepted
time: 492ms
memory: 150504kb

input:

30 21

output:

254760745

result:

ok single line: '254760745'

Test #25:

score: 34
Accepted
time: 428ms
memory: 150124kb

input:

27 22

output:

266692865

result:

ok single line: '266692865'

Test #26:

score: 34
Accepted
time: 653ms
memory: 150668kb

input:

40 12

output:

133652311

result:

ok single line: '133652311'

Test #27:

score: 34
Accepted
time: 488ms
memory: 150488kb

input:

29 4

output:

873892090

result:

ok single line: '873892090'

Test #28:

score: 34
Accepted
time: 790ms
memory: 150680kb

input:

50 46

output:

267950067

result:

ok single line: '267950067'

Test #29:

score: 34
Accepted
time: 804ms
memory: 149384kb

input:

50 11

output:

423642322

result:

ok single line: '423642322'

Test #30:

score: 34
Accepted
time: 796ms
memory: 149804kb

input:

50 43

output:

625476642

result:

ok single line: '625476642'

Test #31:

score: 34
Accepted
time: 798ms
memory: 149616kb

input:

50 36

output:

767166129

result:

ok single line: '767166129'

Test #32:

score: 34
Accepted
time: 800ms
memory: 150792kb

input:

50 14

output:

357467965

result:

ok single line: '357467965'

Test #33:

score: 34
Accepted
time: 813ms
memory: 150788kb

input:

50 30

output:

219673347

result:

ok single line: '219673347'

Test #34:

score: 34
Accepted
time: 810ms
memory: 150736kb

input:

50 44

output:

392786132

result:

ok single line: '392786132'

Test #35:

score: 34
Accepted
time: 796ms
memory: 150736kb

input:

50 10

output:

848251616

result:

ok single line: '848251616'

Subtask #3:

score: 43
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #36:

score: 43
Accepted
time: 1203ms
memory: 149172kb

input:

75 47

output:

668751416

result:

ok single line: '668751416'

Test #37:

score: 43
Accepted
time: 1228ms
memory: 149432kb

input:

75 41

output:

310834114

result:

ok single line: '310834114'

Test #38:

score: 43
Accepted
time: 2288ms
memory: 150196kb

input:

133 124

output:

57167600

result:

ok single line: '57167600'

Test #39:

score: 43
Accepted
time: 2181ms
memory: 150252kb

input:

129 74

output:

751074385

result:

ok single line: '751074385'

Test #40:

score: 43
Accepted
time: 2293ms
memory: 150036kb

input:

135 133

output:

759430862

result:

ok single line: '759430862'

Test #41:

score: 43
Accepted
time: 1220ms
memory: 149504kb

input:

75 19

output:

967921272

result:

ok single line: '967921272'

Test #42:

score: 43
Accepted
time: 2087ms
memory: 150828kb

input:

124 9

output:

641081661

result:

ok single line: '641081661'

Test #43:

score: 43
Accepted
time: 1209ms
memory: 151096kb

input:

76 66

output:

465902083

result:

ok single line: '465902083'

Test #44:

score: 43
Accepted
time: 2485ms
memory: 149648kb

input:

142 13

output:

12401929

result:

ok single line: '12401929'

Test #45:

score: 43
Accepted
time: 2653ms
memory: 150276kb

input:

150 5

output:

388058135

result:

ok single line: '388058135'

Test #46:

score: 43
Accepted
time: 1798ms
memory: 149132kb

input:

109 97

output:

381109644

result:

ok single line: '381109644'

Test #47:

score: 43
Accepted
time: 2700ms
memory: 150972kb

input:

150 133

output:

174431234

result:

ok single line: '174431234'

Test #48:

score: 43
Accepted
time: 2643ms
memory: 149428kb

input:

150 147

output:

198921722

result:

ok single line: '198921722'

Test #49:

score: 43
Accepted
time: 2641ms
memory: 151040kb

input:

150 142

output:

631473185

result:

ok single line: '631473185'

Test #50:

score: 43
Accepted
time: 2665ms
memory: 151116kb

input:

150 136

output:

743180069

result:

ok single line: '743180069'

Test #51:

score: 43
Accepted
time: 2649ms
memory: 149964kb

input:

150 138

output:

621574340

result:

ok single line: '621574340'

Test #52:

score: 43
Accepted
time: 2634ms
memory: 149308kb

input:

150 119

output:

872660153

result:

ok single line: '872660153'

Test #53:

score: 43
Accepted
time: 2595ms
memory: 150876kb

input:

150 144

output:

939939060

result:

ok single line: '939939060'

Test #54:

score: 43
Accepted
time: 2682ms
memory: 150760kb

input:

150 1

output:

166208360

result:

ok single line: '166208360'

Test #55:

score: 43
Accepted
time: 2705ms
memory: 149352kb

input:

150 75

output:

353929212

result:

ok single line: '353929212'