QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#376331#8047. DFS Order 4LynkcatAC ✓735ms11124kbC++171.0kb2024-04-04 07:57:072024-04-04 07:57:07

Judging History

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

  • [2024-04-04 07:57:07]
  • 评测
  • 测评结果:AC
  • 用时:735ms
  • 内存:11124kb
  • [2024-04-04 07:57:07]
  • 提交

answer

#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define sz(x) (int)((x).size())
// #define int ll
//#define N
using namespace std;
const int N=1005;
int n,mod;
int h[N][N],C[N][N];
void BellaKira()
{
	cin>>n>>mod;
	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<=n;i++)
		h[i][0]=h[i][1]=1;
	for (int i=2;i<=n;i++)
		for (int j=0;i+j<=n;j++)
		{
			for (int x=1;x<i;x++)
				if (h[0][x])
				{
					int y=i-1-x;
					if (!h[j][y]) continue;
					if (y)
						h[j][i]=(h[j][i]+1ll*h[j][y]*(1ll*h[0][x]*C[i+j-1][x]%mod-h[y+j][x]+mod)%mod)%mod;
					else
						h[j][i]=(h[j][i]+1ll*h[0][x]*C[i+j-1][x]%mod)%mod;
				}	
		}
	cout<<h[0][n-1]<<'\n';
}
signed main()
{
	IOS;
	cin.tie(0);
	int T=1;
	while (T--)
	{
		BellaKira();
	}
}

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

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5728kb

input:

4 114514199

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

10 998244353

output:

11033

result:

ok 1 number(s): "11033"

Test #3:

score: 0
Accepted
time: 2ms
memory: 6092kb

input:

100 1000000007

output:

270904395

result:

ok 1 number(s): "270904395"

Test #4:

score: 0
Accepted
time: 624ms
memory: 11004kb

input:

756 1001338769

output:

901942543

result:

ok 1 number(s): "901942543"

Test #5:

score: 0
Accepted
time: 716ms
memory: 11092kb

input:

793 1009036033

output:

301770320

result:

ok 1 number(s): "301770320"

Test #6:

score: 0
Accepted
time: 629ms
memory: 10548kb

input:

759 1005587659

output:

846376219

result:

ok 1 number(s): "846376219"

Test #7:

score: 0
Accepted
time: 663ms
memory: 10640kb

input:

773 1007855479

output:

1398019

result:

ok 1 number(s): "1398019"

Test #8:

score: 0
Accepted
time: 609ms
memory: 10440kb

input:

751 1006730639

output:

321287237

result:

ok 1 number(s): "321287237"

Test #9:

score: 0
Accepted
time: 678ms
memory: 11124kb

input:

778 1007760653

output:

430322899

result:

ok 1 number(s): "430322899"

Test #10:

score: 0
Accepted
time: 735ms
memory: 10784kb

input:

798 1007543827

output:

688720826

result:

ok 1 number(s): "688720826"

Test #11:

score: 0
Accepted
time: 724ms
memory: 10640kb

input:

796 1004841413

output:

258829347

result:

ok 1 number(s): "258829347"

Test #12:

score: 0
Accepted
time: 671ms
memory: 10676kb

input:

775 1005185189

output:

744278608

result:

ok 1 number(s): "744278608"

Test #13:

score: 0
Accepted
time: 732ms
memory: 10764kb

input:

800 1006012831

output:

508549367

result:

ok 1 number(s): "508549367"

Test #14:

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

input:

1 1001338769

output:

1

result:

ok 1 number(s): "1"

Test #15:

score: 0
Accepted
time: 0ms
memory: 5684kb

input:

2 1001338769

output:

1

result:

ok 1 number(s): "1"

Test #16:

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

input:

9 1009036033

output:

1780

result:

ok 1 number(s): "1780"

Test #17:

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

input:

14 1001338769

output:

43297358

result:

ok 1 number(s): "43297358"

Extra Test:

score: 0
Extra Test Passed