QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#76956#5357. 芒果冰加了空气xzzduang5 252ms321544kbC++141.6kb2023-02-12 21:32:082023-02-12 21:32:10

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-12 21:32:10]
  • 评测
  • 测评结果:5
  • 用时:252ms
  • 内存:321544kb
  • [2023-02-12 21:32:08]
  • 提交

answer

#include<iostream>
#include<stdio.h>
#include<ctype.h>
#include<vector>
#include<string.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pii pair<int,int>
#define lowbit(x) ((x)&-(x))
#define popcount(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define umap unordered_map
#define all(x) x.begin(),x.end()
#define mk make_pair
#define pb push_back
#define ckmax(x,y) x=max(x,y)
#define ckmin(x,y) x=min(x,y)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define N 5005
#define int long long
using namespace std;
inline int read(){
	int x=0,f=0; char ch=getchar();
	while(!isdigit(ch)) f|=(ch==45),ch=getchar();
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int mo=998244353;
inline void red(int &x){x>=mo?x-=mo:0;}
int n,C[N][N],f[N][N],sze[N];
vector<int> G[N];
void dfs(int u,int fa){
	for(int v:G[u]){
		if(v==fa) continue;
		dfs(v,u);
	}
	sze[u]=1;
	f[u][1]=1;
	for(int v:G[u]){
		if(v==fa) continue;
		memcpy(f[0],f[u],sizeof(f[u]));
		memset(f[u],0,sizeof(f[u]));
		for(int i=1;i<=sze[u];++i){
			for(int j=0;j<=sze[v];++j){
				red(f[u][i+j]+=f[0][i]*f[v][j]%mo*C[i+j-1][i-1]%mo);
			}
		}
		sze[u]+=sze[v];
	}
	for(int i=sze[u];i>=0;--i) red(f[u][i]+=f[u][i+1]);
}
signed main(){
	n=read();
	C[0][0]=1;
	for(int i=1;i<=n;++i){
		C[i][0]=1;
		for(int j=1;j<=i;++j){
			red(C[i][j]=C[i-1][j]+C[i-1][j-1]);
		}
	}
	for(int i=1;i<n;++i){
		int x=read(),y=read();
		G[x].pb(y),G[y].pb(x);
	}
	dfs(1,0);
	cout<<f[1][0];
	return 0;
}

详细

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 3ms
memory: 5604kb

input:

10
1 2
2 3
3 4
5 4
6 4
7 4
8 4
9 4
10 4

output:

310862

result:

ok single line: '310862'

Test #2:

score: 0
Accepted
time: 3ms
memory: 5756kb

input:

10
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
8 10

output:

64804

result:

ok single line: '64804'

Test #3:

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

input:

10
1 2
1 3
3 4
3 5
3 6
4 7
3 8
4 9
4 10

output:

258182

result:

ok single line: '258182'

Test #4:

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

input:

10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10

output:

16796

result:

ok single line: '16796'

Test #5:

score: 0
Accepted
time: 3ms
memory: 7780kb

input:

10
1 2
2 3
3 4
4 5
1 6
2 7
3 8
4 9
5 10

output:

78384

result:

ok single line: '78384'

Test #6:

score: 0
Accepted
time: 3ms
memory: 5916kb

input:

10
1 2
1 3
2 4
3 5
2 6
4 7
3 8
7 9
9 10

output:

38896

result:

ok single line: '38896'

Test #7:

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

input:

10
1 2
2 3
4 3
5 3
6 3
7 3
8 3
9 3
10 3

output:

609656

result:

ok single line: '609656'

Test #8:

score: 0
Accepted
time: 3ms
memory: 7460kb

input:

10
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
9 10

output:

64804

result:

ok single line: '64804'

Test #9:

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

input:

10
1 2
1 3
3 4
3 5
1 6
4 7
1 8
4 9
9 10

output:

118638

result:

ok single line: '118638'

Test #10:

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

input:

10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
8 10

output:

22438

result:

ok single line: '22438'

Test #11:

score: 0
Accepted
time: 4ms
memory: 7880kb

input:

10
1 2
1 3
2 4
3 5
4 6
5 7
6 8
7 9
8 10

output:

16796

result:

ok single line: '16796'

Test #12:

score: 0
Accepted
time: 3ms
memory: 5616kb

input:

10
1 2
1 3
1 4
3 5
4 6
2 7
3 8
5 9
5 10

output:

82316

result:

ok single line: '82316'

Test #13:

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

input:

8
1 2
3 2
4 2
5 2
6 2
7 2
8 2

output:

13700

result:

ok single line: '13700'

Test #14:

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

input:

8
1 2
1 3
2 4
2 5
3 6
3 7
3 8

output:

3996

result:

ok single line: '3996'

Test #15:

score: 0
Accepted
time: 3ms
memory: 7884kb

input:

8
1 2
2 3
1 4
1 5
1 6
3 7
6 8

output:

3490

result:

ok single line: '3490'

Test #16:

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

input:

8
1 2
2 3
3 4
4 5
5 6
6 7
7 8

output:

1430

result:

ok single line: '1430'

Test #17:

score: 0
Accepted
time: 3ms
memory: 5912kb

input:

8
1 2
1 3
2 4
3 5
4 6
5 7
6 8

output:

1430

result:

ok single line: '1430'

Test #18:

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

input:

8
1 2
2 3
3 4
2 5
3 6
5 7
4 8

output:

3232

result:

ok single line: '3232'

Test #19:

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

input:

8
1 2
2 3
4 3
5 3
6 3
7 3
8 3

output:

8970

result:

ok single line: '8970'

Test #20:

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

input:

8
1 2
1 3
2 4
2 5
3 6
3 7
2 8

output:

3996

result:

ok single line: '3996'

Test #21:

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

input:

8
1 2
1 3
1 4
4 5
3 6
4 7
2 8

output:

3332

result:

ok single line: '3332'

Test #22:

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

input:

8
1 2
2 3
3 4
4 5
5 6
6 7
2 8

output:

1870

result:

ok single line: '1870'

Test #23:

score: 0
Accepted
time: 3ms
memory: 5648kb

input:

8
1 2
2 3
1 4
2 5
3 6
4 7
5 8

output:

2416

result:

ok single line: '2416'

Test #24:

score: 0
Accepted
time: 3ms
memory: 7684kb

input:

8
1 2
1 3
2 4
3 5
2 6
6 7
3 8

output:

2802

result:

ok single line: '2802'

Test #25:

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

input:

3
1 2
2 3

output:

5

result:

ok single line: '5'

Test #26:

score: 0
Accepted
time: 3ms
memory: 7704kb

input:

10
1 2
1 3
1 4
4 5
1 6
6 7
3 8
5 9
2 10

output:

78904

result:

ok single line: '78904'

Subtask #2:

score: 0
Wrong Answer

Test #27:

score: 0
Wrong Answer
time: 252ms
memory: 321544kb

input:

5000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52 53
...

output:

302039569

result:

wrong answer 1st lines differ - expected: '138172849', found: '302039569'

Subtask #3:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #37:

score: 0
Wrong Answer
time: 4ms
memory: 8024kb

input:

20
1 2
2 3
3 4
1 5
3 6
5 7
5 8
8 9
7 10
10 11
9 12
12 13
10 14
11 15
13 16
16 17
17 18
18 19
16 20

output:

555866770

result:

wrong answer 1st lines differ - expected: '85351498', found: '555866770'

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%