QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#217423#6637. Perfect StringsEastKingWA 24ms3948kbC++17646b2023-10-16 20:52:102023-10-16 20:52:10

Judging History

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

  • [2023-10-16 20:52:10]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:3948kb
  • [2023-10-16 20:52:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int M=1e3+5,P=1e9+7;
int dp[2][M];
int main(){
	int cas;
	scanf("%d",&cas);
	while(cas--){
		int n,c;
		scanf("%d %d",&n,&c);
		int cur=0;
		memset(dp[0],0,sizeof(dp[0]));
		dp[0][0]=1;
		for(int i=1;i<=2*n;i++){
			int pre=cur;
			cur^=1;
			for(int j=0;j<=i;j++){
				dp[cur][j]=0;
				dp[cur][j]=(dp[cur][j]+dp[pre][j+1])%P;
				if(j>0){
					if(j>1)dp[cur][j]=(dp[cur][j]+1ll*dp[pre][j-1]*(c-1))%P;
					else dp[cur][j]=(dp[cur][j]+1ll*dp[pre][j-1]*c)%P;
				}
				//printf("dp[%d][%d]=%d\n",i,j,dp[cur][j]);
			}
		}
		printf("%d\n",dp[cur][0]);
	}
	return 0;
}

詳細信息

Test #1:

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

input:

2
3 1
2 2

output:

1
6

result:

ok 2 number(s): "1 6"

Test #2:

score: -100
Wrong Answer
time: 24ms
memory: 3948kb

input:

100000
1 1
4 1
5 5
3 5
1 2
5 3
1 1
3 3
5 2
2 1
4 1
5 5
2 3
4 1
3 3
2 5
3 2
4 3
4 4
3 5
3 1
5 2
2 2
4 2
5 4
1 2
3 1
4 5
2 5
5 3
1 5
5 2
3 2
5 2
4 1
1 3
3 2
4 5
2 1
4 1
2 2
1 1
3 5
4 5
2 3
3 5
2 5
2 4
5 4
2 3
1 1
2 1
4 4
1 5
5 4
1 3
5 4
4 5
1 3
1 1
3 3
2 4
2 4
2 1
5 5
1 3
2 3
4 1
4 3
2 4
2 4
4 2
1 1
1...

output:

1
1
71445
3678965
2
748396395
1
689688788
737208911
90470556
906419123
749486304
852967581
117268734
87
178289118
852625494
383947957
897711628
143457583
916481451
345420560
594870549
351888802
100884115
2
30951813
588453226
866817292
21740061
5
950183754
979407456
887245661
154848631
3
20
69675540
...

result:

wrong answer 4th numbers differ - expected: '485', found: '3678965'