QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#411139#8300. Game Designbright_mlAC ✓1ms3652kbC++14906b2024-05-15 00:27:192024-05-15 00:27:19

Judging History

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

  • [2024-05-15 00:27:19]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3652kb
  • [2024-05-15 00:27:19]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;

const int N = 500;

int idx,fa[N],l[N],r[N],val[N];

int dfs(int u,int sum) { // 为节点 u 建造一颗能贡献 sum 种方案的子树,并返回子树的根节点编号
    fa[++idx] = u, sum = sum - 1;
    int temp = idx;
    if (sum == 0) {
        val[idx] = 1;
        return idx;
    }
    int x = 1;
    if(sum % 2 == 0) x = 2;
    l[temp] = dfs(temp,x);
    r[temp] = dfs(temp,sum/x);
    val[temp] = val[l[temp]] + val[r[temp]];
    return temp;
}

signed main(){
    int k;
    cin >> k;
    if(k == 1){
        cout << 2 << '\n' << 1 << '\n' << 100 << ' ' << 1 <<'\n';
        return 0;
    }
    dfs(0,k);
    cout << idx << '\n';
    for(int i=2;i<=idx;i++){
        cout << fa[i] << ' ';
    }
    cout << '\n';
    for(int i=1;i<=idx;i++) cout << val[i] << ' ';
    cout << '\n';
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2

output:

3
1 1 
2 1 1 

result:

ok correct

Test #2:

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

input:

1

output:

2
1
100 1

result:

ok correct

Test #3:

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

input:

3

output:

5
1 2 2 1 
3 2 1 1 1 

result:

ok correct

Test #4:

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

input:

4

output:

7
1 1 3 4 4 3 
4 1 3 2 1 1 1 

result:

ok correct

Test #5:

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

input:

5

output:

7
1 2 2 1 5 5 
4 2 1 1 2 1 1 

result:

ok correct

Test #6:

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

input:

6

output:

9
1 1 3 4 4 3 7 7 
5 1 4 2 1 1 2 1 1 

result:

ok correct

Test #7:

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

input:

7

output:

9
1 2 2 1 5 6 6 5 
5 2 1 1 3 2 1 1 1 

result:

ok correct

Test #8:

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

input:

8

output:

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

result:

ok correct

Test #9:

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

input:

9

output:

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

result:

ok correct

Test #10:

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

input:

11

output:

11
1 2 2 1 5 6 6 5 9 9 
6 2 1 1 4 2 1 1 2 1 1 

result:

ok correct

Test #11:

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

input:

23

output:

15
1 2 2 1 5 6 6 5 9 10 10 9 13 13 
8 2 1 1 6 2 1 1 4 2 1 1 2 1 1 

result:

ok correct

Test #12:

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

input:

64

output:

23
1 1 3 4 4 3 7 8 8 7 11 12 12 11 15 16 16 15 19 20 20 19 
12 1 11 2 1 1 9 2 1 1 7 2 1 1 5 2 1 1 3 2 1 1 1 

result:

ok correct

Test #13:

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

input:

87

output:

25
1 2 2 1 5 6 6 5 9 10 10 9 13 13 15 16 16 15 19 19 21 22 22 21 
13 2 1 1 11 2 1 1 9 2 1 1 7 1 6 2 1 1 4 1 3 2 1 1 1 

result:

ok correct

Test #14:

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

input:

103

output:

25
1 2 2 1 5 6 6 5 9 10 10 9 13 13 15 16 16 15 19 20 20 19 23 23 
13 2 1 1 11 2 1 1 9 2 1 1 7 1 6 2 1 1 4 2 1 1 2 1 1 

result:

ok correct

Test #15:

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

input:

128

output:

27
1 1 3 4 4 3 7 8 8 7 11 12 12 11 15 16 16 15 19 20 20 19 23 24 24 23 
14 1 13 2 1 1 11 2 1 1 9 2 1 1 7 2 1 1 5 2 1 1 3 2 1 1 1 

result:

ok correct

Test #16:

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

input:

325

output:

35
1 2 2 1 5 5 7 8 8 7 11 11 13 14 14 13 17 18 18 17 21 22 22 21 25 26 26 25 29 29 31 32 32 31 
18 2 1 1 16 1 15 2 1 1 13 1 12 2 1 1 10 2 1 1 8 2 1 1 6 2 1 1 4 1 3 2 1 1 1 

result:

ok correct

Test #17:

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

input:

567

output:

39
1 2 2 1 5 6 6 5 9 10 10 9 13 13 15 16 16 15 19 19 21 22 22 21 25 25 27 28 28 27 31 32 32 31 35 36 36 35 
20 2 1 1 18 2 1 1 16 2 1 1 14 1 13 2 1 1 11 1 10 2 1 1 8 1 7 2 1 1 5 2 1 1 3 2 1 1 1 

result:

ok correct

Test #18:

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

input:

9999

output:

57
1 2 2 1 5 6 6 5 9 10 10 9 13 14 14 13 17 17 19 20 20 19 23 24 24 23 27 28 28 27 31 32 32 31 35 35 37 38 38 37 41 41 43 44 44 43 47 47 49 50 50 49 53 54 54 53 
29 2 1 1 27 2 1 1 25 2 1 1 23 2 1 1 21 1 20 2 1 1 18 2 1 1 16 2 1 1 14 2 1 1 12 1 11 2 1 1 9 1 8 2 1 1 6 1 5 2 1 1 3 2 1 1 1 

result:

ok correct

Test #19:

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

input:

93256

output:

75
1 1 3 4 4 3 7 8 8 7 11 12 12 11 15 15 17 18 18 17 21 22 22 21 25 26 26 25 29 29 31 32 32 31 35 36 36 35 39 40 40 39 43 44 44 43 47 47 49 50 50 49 53 53 55 56 56 55 59 60 60 59 63 63 65 66 66 65 69 69 71 72 72 71 
38 1 37 2 1 1 35 2 1 1 33 2 1 1 31 1 30 2 1 1 28 2 1 1 26 2 1 1 24 1 23 2 1 1 21 2 1...

result:

ok correct

Test #20:

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

input:

3532462

output:

109
1 1 3 4 4 3 7 7 9 10 10 9 13 13 15 16 16 15 19 19 21 22 22 21 25 26 26 25 29 29 31 32 32 31 35 36 36 35 39 39 41 42 42 41 45 46 46 45 49 49 51 52 52 51 55 55 57 58 58 57 61 62 62 61 65 66 66 65 69 69 71 72 72 71 75 75 77 78 78 77 81 81 83 84 84 83 87 87 89 90 90 89 93 94 94 93 97 97 99 100 100 9...

result:

ok correct

Test #21:

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

input:

54389236

output:

131
1 1 3 4 4 3 7 8 8 7 11 11 13 14 14 13 17 18 18 17 21 21 23 24 24 23 27 27 29 30 30 29 33 33 35 36 36 35 39 39 41 42 42 41 45 45 47 48 48 47 51 52 52 51 55 56 56 55 59 59 61 62 62 61 65 66 66 65 69 69 71 72 72 71 75 75 77 78 78 77 81 81 83 84 84 83 87 87 89 90 90 89 93 94 94 93 97 97 99 100 100 9...

result:

ok correct

Test #22:

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

input:

93453967

output:

127
1 2 2 1 5 6 6 5 9 10 10 9 13 14 14 13 17 17 19 20 20 19 23 24 24 23 27 28 28 27 31 31 33 34 34 33 37 38 38 37 41 41 43 44 44 43 47 47 49 50 50 49 53 53 55 56 56 55 59 59 61 62 62 61 65 65 67 68 68 67 71 71 73 74 74 73 77 77 79 80 80 79 83 83 85 86 86 85 89 90 90 89 93 94 94 93 97 98 98 97 101 10...

result:

ok correct

Test #23:

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

input:

1000000000

output:

139
1 1 3 4 4 3 7 8 8 7 11 12 12 11 15 16 16 15 19 20 20 19 23 24 24 23 27 28 28 27 31 32 32 31 35 36 36 35 39 39 41 42 42 41 45 46 46 45 49 49 51 52 52 51 55 56 56 55 59 60 60 59 63 63 65 66 66 65 69 69 71 72 72 71 75 76 76 75 79 79 81 82 82 81 85 86 86 85 89 89 91 92 92 91 95 95 97 98 98 97 101 10...

result:

ok correct

Test #24:

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

input:

999999999

output:

137
1 2 2 1 5 6 6 5 9 10 10 9 13 14 14 13 17 18 18 17 21 22 22 21 25 26 26 25 29 30 30 29 33 34 34 33 37 37 39 40 40 39 43 44 44 43 47 47 49 50 50 49 53 54 54 53 57 58 58 57 61 61 63 64 64 63 67 67 69 70 70 69 73 74 74 73 77 77 79 80 80 79 83 84 84 83 87 87 89 90 90 89 93 93 95 96 96 95 99 100 100 9...

result:

ok correct

Test #25:

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

input:

888888888

output:

149
1 1 3 4 4 3 7 8 8 7 11 12 12 11 15 15 17 18 18 17 21 21 23 24 24 23 27 27 29 30 30 29 33 34 34 33 37 38 38 37 41 42 42 41 45 45 47 48 48 47 51 51 53 54 54 53 57 57 59 60 60 59 63 63 65 66 66 65 69 70 70 69 73 73 75 76 76 75 79 80 80 79 83 83 85 86 86 85 89 89 91 92 92 91 95 96 96 95 99 99 101 10...

result:

ok correct

Test #26:

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

input:

333333334

output:

141
1 1 3 4 4 3 7 7 9 10 10 9 13 13 15 16 16 15 19 20 20 19 23 23 25 26 26 25 29 30 30 29 33 33 35 36 36 35 39 40 40 39 43 43 45 46 46 45 49 49 51 52 52 51 55 56 56 55 59 60 60 59 63 64 64 63 67 68 68 67 71 71 73 74 74 73 77 78 78 77 81 82 82 81 85 85 87 88 88 87 91 91 93 94 94 93 97 97 99 100 100 9...

result:

ok correct

Test #27:

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

input:

83495645

output:

129
1 2 2 1 5 5 7 8 8 7 11 11 13 14 14 13 17 17 19 20 20 19 23 23 25 26 26 25 29 30 30 29 33 33 35 36 36 35 39 39 41 42 42 41 45 46 46 45 49 49 51 52 52 51 55 56 56 55 59 59 61 62 62 61 65 66 66 65 69 70 70 69 73 74 74 73 77 78 78 77 81 82 82 81 85 85 87 88 88 87 91 92 92 91 95 95 97 98 98 97 101 10...

result:

ok correct

Test #28:

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

input:

894567865

output:

139
1 2 2 1 5 5 7 8 8 7 11 12 12 11 15 15 17 18 18 17 21 21 23 24 24 23 27 27 29 30 30 29 33 34 34 33 37 37 39 40 40 39 43 43 45 46 46 45 49 50 50 49 53 53 55 56 56 55 59 60 60 59 63 64 64 63 67 68 68 67 71 72 72 71 75 76 76 75 79 80 80 79 83 83 85 86 86 85 89 90 90 89 93 94 94 93 97 97 99 100 100 9...

result:

ok correct

Test #29:

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

input:

88479456

output:

123
1 1 3 4 4 3 7 8 8 7 11 12 12 11 15 16 16 15 19 20 20 19 23 23 25 26 26 25 29 29 31 32 32 31 35 35 37 38 38 37 41 42 42 41 45 45 47 48 48 47 51 51 53 54 54 53 57 58 58 57 61 61 63 64 64 63 67 68 68 67 71 72 72 71 75 76 76 75 79 80 80 79 83 83 85 86 86 85 89 89 91 92 92 91 95 96 96 95 99 100 100 9...

result:

ok correct

Test #30:

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

input:

1000000

output:

87
1 1 3 4 4 3 7 8 8 7 11 12 12 11 15 16 16 15 19 20 20 19 23 24 24 23 27 27 29 30 30 29 33 34 34 33 37 38 38 37 41 41 43 44 44 43 47 48 48 47 51 52 52 51 55 56 56 55 59 60 60 59 63 63 65 66 66 65 69 70 70 69 73 73 75 76 76 75 79 79 81 82 82 81 85 85 
44 1 43 2 1 1 41 2 1 1 39 2 1 1 37 2 1 1 35 2 1 ...

result:

ok correct

Test #31:

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

input:

429085001

output:

133
1 2 2 1 5 5 7 8 8 7 11 12 12 11 15 15 17 18 18 17 21 22 22 21 25 26 26 25 29 29 31 32 32 31 35 36 36 35 39 39 41 42 42 41 45 46 46 45 49 50 50 49 53 54 54 53 57 57 59 60 60 59 63 64 64 63 67 67 69 70 70 69 73 74 74 73 77 77 79 80 80 79 83 83 85 86 86 85 89 90 90 89 93 94 94 93 97 97 99 100 100 9...

result:

ok correct

Test #32:

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

input:

882138811

output:

143
1 2 2 1 5 6 6 5 9 9 11 12 12 11 15 15 17 18 18 17 21 21 23 24 24 23 27 27 29 30 30 29 33 34 34 33 37 37 39 40 40 39 43 44 44 43 47 47 49 50 50 49 53 53 55 56 56 55 59 59 61 62 62 61 65 65 67 68 68 67 71 72 72 71 75 75 77 78 78 77 81 82 82 81 85 86 86 85 89 90 90 89 93 93 95 96 96 95 99 100 100 9...

result:

ok correct

Test #33:

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

input:

513157691

output:

137
1 2 2 1 5 6 6 5 9 9 11 12 12 11 15 15 17 18 18 17 21 21 23 24 24 23 27 27 29 30 30 29 33 34 34 33 37 38 38 37 41 42 42 41 45 45 47 48 48 47 51 52 52 51 55 55 57 58 58 57 61 62 62 61 65 65 67 68 68 67 71 72 72 71 75 76 76 75 79 80 80 79 83 83 85 86 86 85 89 89 91 92 92 91 95 96 96 95 99 99 101 10...

result:

ok correct

Test #34:

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

input:

813900859

output:

133
1 2 2 1 5 6 6 5 9 9 11 12 12 11 15 15 17 18 18 17 21 21 23 24 24 23 27 27 29 30 30 29 33 34 34 33 37 38 38 37 41 42 42 41 45 46 46 45 49 49 51 52 52 51 55 56 56 55 59 60 60 59 63 63 65 66 66 65 69 70 70 69 73 74 74 73 77 77 79 80 80 79 83 83 85 86 86 85 89 90 90 89 93 94 94 93 97 98 98 97 101 10...

result:

ok correct

Test #35:

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

input:

454848871

output:

135
1 2 2 1 5 6 6 5 9 10 10 9 13 13 15 16 16 15 19 20 20 19 23 23 25 26 26 25 29 29 31 32 32 31 35 36 36 35 39 39 41 42 42 41 45 46 46 45 49 50 50 49 53 54 54 53 57 57 59 60 60 59 63 63 65 66 66 65 69 69 71 72 72 71 75 76 76 75 79 80 80 79 83 84 84 83 87 87 89 90 90 89 93 93 95 96 96 95 99 99 101 10...

result:

ok correct

Test #36:

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

input:

151401319

output:

125
1 2 2 1 5 6 6 5 9 10 10 9 13 13 15 16 16 15 19 20 20 19 23 23 25 26 26 25 29 29 31 32 32 31 35 36 36 35 39 39 41 42 42 41 45 45 47 48 48 47 51 52 52 51 55 56 56 55 59 59 61 62 62 61 65 65 67 68 68 67 71 72 72 71 75 76 76 75 79 80 80 79 83 83 85 86 86 85 89 89 91 92 92 91 95 96 96 95 99 100 100 9...

result:

ok correct

Test #37:

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

input:

280898521

output:

139
1 2 2 1 5 5 7 8 8 7 11 12 12 11 15 15 17 18 18 17 21 21 23 24 24 23 27 28 28 27 31 31 33 34 34 33 37 37 39 40 40 39 43 43 45 46 46 45 49 49 51 52 52 51 55 56 56 55 59 59 61 62 62 61 65 66 66 65 69 69 71 72 72 71 75 76 76 75 79 80 80 79 83 84 84 83 87 87 89 90 90 89 93 93 95 96 96 95 99 99 101 10...

result:

ok correct

Test #38:

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

input:

412968047

output:

133
1 2 2 1 5 6 6 5 9 10 10 9 13 14 14 13 17 17 19 20 20 19 23 23 25 26 26 25 29 29 31 32 32 31 35 36 36 35 39 40 40 39 43 44 44 43 47 47 49 50 50 49 53 54 54 53 57 58 58 57 61 61 63 64 64 63 67 67 69 70 70 69 73 74 74 73 77 77 79 80 80 79 83 84 84 83 87 87 89 90 90 89 93 93 95 96 96 95 99 99 101 10...

result:

ok correct

Extra Test:

score: 0
Extra Test Passed