QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#450569 | #8300. Game Design | -Ofast# | AC ✓ | 0ms | 3676kb | C++14 | 852b | 2024-06-22 15:46:32 | 2024-06-22 15:46:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int k,cnt,fa[N],val[N],sum[N];
int dfs(int k,int p){
if(k==0){
++cnt;
val[cnt]=sum[cnt]=1;
sum[p]++;
fa[cnt]=p;
return cnt;
}
assert(k>=0);
if(k&1){
++cnt;int now=cnt;
int s=dfs(k-1,cnt);
fa[now]=p;
val[now]=sum[s];
sum[p]+=val[now];
return now;
}else{
++cnt;int now=cnt;
int s=dfs(k/2-1,cnt);
fa[now]=p;
val[now]=sum[now]=sum[s]+1;
sum[p]+=val[now];
fa[++cnt]=now;val[cnt]=1;
int tmp=cnt;
fa[++cnt]=tmp;val[cnt]=1;
return now;
}
}
int main(){
cin>>k;
if(k==1){
cout<<2<<endl;
cout<<1<<endl;
cout<<1<<" "<<2<<endl;return 0;
}
k--;
dfs(k,0);
cout<<cnt<<endl;
for(int i=2;i<=cnt;i++)cout<<fa[i]<<" ";
cout<<endl;
for(int i=1;i<=cnt;i++)cout<<val[i]<<" ";
cout<<endl;
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
input:
2
output:
2 1 1 1
result:
ok correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
1
output:
2 1 1 2
result:
ok correct
Test #3:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
3
output:
4 1 1 3 2 1 1 1
result:
ok correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
4
output:
5 1 2 2 4 2 2 1 1 1
result:
ok correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 3476kb
input:
5
output:
5 1 2 1 4 2 1 1 1 1
result:
ok correct
Test #6:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
6
output:
6 1 2 3 2 5 2 2 1 1 1 1
result:
ok correct
Test #7:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
7
output:
7 1 2 2 4 1 6 3 2 1 1 1 1 1
result:
ok correct
Test #8:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
8
output:
8 1 2 3 3 5 2 7 3 3 2 1 1 1 1 1
result:
ok correct
Test #9:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
9
output:
8 1 2 3 3 5 1 7 3 2 2 1 1 1 1 1
result:
ok correct
Test #10:
score: 0
Accepted
time: 0ms
memory: 3508kb
input:
11
output:
8 1 2 3 2 5 1 7 3 2 1 1 1 1 1 1
result:
ok correct
Test #11:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
23
output:
11 1 2 3 4 3 6 2 8 1 10 4 3 2 1 1 1 1 1 1 1 1
result:
ok correct
Test #12:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
64
output:
17 1 2 3 4 5 6 6 8 5 10 4 12 3 14 2 16 6 6 5 4 3 2 1 1 1 1 1 1 1 1 1 1 1
result:
ok correct
Test #13:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
87
output:
18 1 2 3 4 5 6 7 7 9 5 11 3 13 2 15 1 17 6 5 4 3 3 2 2 1 1 1 1 1 1 1 1 1 1 1
result:
ok correct
Test #14:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
103
output:
18 1 2 3 4 5 6 7 6 9 5 11 3 13 2 15 1 17 6 5 4 3 3 2 1 1 1 1 1 1 1 1 1 1 1 1
result:
ok correct
Test #15:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
128
output:
20 1 2 3 4 5 6 7 7 9 6 11 5 13 4 15 3 17 2 19 7 7 6 5 4 3 2 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
ok correct
Test #16:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
325
output:
25 1 2 3 4 5 6 7 8 9 10 10 12 8 14 7 16 6 18 5 20 3 22 1 24 8 7 7 6 6 5 4 3 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
ok correct
Test #17:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
567
output:
28 1 2 3 4 5 6 7 8 9 10 11 11 13 10 15 9 17 7 19 5 21 3 23 2 25 1 27 9 8 7 6 6 5 5 4 4 3 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
ok correct
Test #18:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
9999
output:
41 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 16 18 15 20 13 22 11 24 9 26 8 28 7 30 6 32 4 34 3 36 2 38 1 40 13 12 11 10 9 9 8 7 6 5 5 4 4 3 3 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
ok correct
Test #19:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
93256
output:
53 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 22 24 20 26 18 28 17 30 15 32 13 34 12 36 11 38 10 40 8 42 7 44 6 46 4 48 3 50 2 52 16 16 15 14 13 13 12 11 10 10 9 8 7 6 6 5 5 4 3 3 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
ok correct
Test #20:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
3532462
output:
75 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 33 36 32 38 30 40 29 42 27 44 25 46 23 48 21 50 20 52 19 54 17 56 15 58 14 60 12 62 11 64 9 66 8 68 6 70 4 72 2 74 21 21 20 20 19 19 18 18 17 16 16 15 14 14 13 12 12 11 11 10 9 8 8 7 7 6 6 5 5 4 3 3 2 1 ...
result:
ok correct
Test #21:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
54389236
output:
90 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 40 43 39 45 38 47 36 49 34 51 32 53 30 55 29 57 27 59 25 61 23 63 21 65 20 67 18 69 17 71 16 73 14 75 12 77 10 79 8 81 6 83 5 85 3 87 2 89 25 25 24 23 23 22 21 21 20 20 19 19 18 18 1...
result:
ok correct
Test #22:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
93453967
output:
89 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 38 40 36 42 34 44 33 46 32 48 30 50 29 52 28 54 27 56 25 58 23 60 21 62 19 64 17 66 15 68 13 70 11 72 10 74 8 76 7 78 6 80 4 82 3 84 2 86 1 88 26 25 24 23 22 22 21 20 19 19 18 17 17 16 16 15 ...
result:
ok correct
Test #23:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
1000000000
output:
98 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 40 43 38 45 37 47 35 49 33 51 31 53 30 55 29 57 27 59 25 61 24 63 22 65 21 67 19 69 17 71 16 73 15 75 13 77 12 79 10 81 9 83 8 85 7 87 6 89 5 91 4 93 3 95 2 97 29 29 28 27 26 25 24 2...
result:
ok correct
Test #24:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
999999999
output:
97 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 39 42 37 44 36 46 34 48 32 50 30 52 29 54 28 56 26 58 24 60 23 62 21 64 20 66 18 68 16 70 15 72 14 74 12 76 11 78 9 80 8 82 7 84 6 86 5 88 4 90 3 92 2 94 1 96 29 28 27 26 25 24 23 22 21...
result:
ok correct
Test #25:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
888888888
output:
103 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 45 48 44 50 42 52 41 54 40 56 38 58 36 60 34 62 32 64 30 66 29 68 27 70 25 72 24 74 22 76 21 78 19 80 17 82 15 84 13 86 12 88 11 90 10 92 8 94 6 96 4 98 3 100 2 102 2...
result:
ok correct
Test #26:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
333333334
output:
98 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 43 45 42 47 40 49 38 51 36 53 34 55 33 57 31 59 29 61 27 63 25 65 24 67 23 69 21 71 20 73 19 75 18 77 17 79 15 81 13 83 12 85 10 87 9 89 7 91 6 93 4 95 2 97 28 28 27 27 26 26 2...
result:
ok correct
Test #27:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
83495645
output:
90 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 39 41 38 43 36 45 34 47 32 49 30 51 28 53 27 55 25 57 24 59 23 61 22 63 21 65 20 67 18 69 17 71 15 73 14 75 12 77 10 79 9 81 7 83 5 85 3 87 1 89 26 25 25 24 24 23 23 22 22 21 20 20 19 19 1...
result:
ok correct
Test #28:
score: 0
Accepted
time: 0ms
memory: 3480kb
input:
894567865
output:
98 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 40 43 39 45 37 47 36 49 34 51 33 53 31 55 30 57 28 59 27 61 26 63 24 65 23 67 22 69 21 71 20 73 19 75 18 77 16 79 15 81 13 83 11 85 10 87 8 89 6 91 4 93 3 95 1 97 29 28 28 27 26 26 2...
result:
ok correct
Test #29:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
88479456
output:
87 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 36 38 34 40 33 42 31 44 30 46 29 48 28 50 26 52 24 54 23 56 22 58 21 60 20 62 18 64 17 66 15 68 13 70 12 72 10 74 8 76 6 78 5 80 4 82 3 84 2 86 26 26 25 24 23 22 21 21 20 20 19 19 18 17 17 16 16 15...
result:
ok correct
Test #30:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
1000000
output:
62 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 24 27 22 29 20 31 19 33 17 35 16 37 15 39 14 41 13 43 11 45 10 47 9 49 7 51 6 53 5 55 4 57 3 59 2 61 19 19 18 17 16 15 14 13 13 12 11 10 10 9 8 7 6 5 5 4 3 3 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok correct
Test #31:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
429085001
output:
94 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 38 41 37 43 36 45 34 47 32 49 31 51 30 53 28 55 27 57 26 59 24 61 22 63 21 65 19 67 18 69 16 71 15 73 14 75 13 77 11 79 10 81 8 83 7 85 6 87 4 89 3 91 1 93 28 27 27 26 25 25 24 23 22 22 21...
result:
ok correct
Test #32:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
882138811
output:
100 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 42 45 41 47 39 49 38 51 37 53 35 55 34 57 33 59 31 61 30 63 28 65 27 67 26 69 25 71 23 73 22 75 20 77 18 79 16 81 14 83 13 85 11 87 10 89 8 91 6 93 4 95 2 97 1 99 29 28 27 27 ...
result:
ok correct
Test #33:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
513157691
output:
96 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 40 43 38 45 36 47 35 49 33 51 32 53 31 55 29 57 28 59 26 61 24 63 23 65 22 67 21 69 19 71 18 73 16 75 15 77 13 79 12 81 11 83 10 85 8 87 6 89 4 91 2 93 1 95 28 27 26 26 25 25 24 24 2...
result:
ok correct
Test #34:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
813900859
output:
95 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 37 40 36 42 35 44 34 46 33 48 31 50 30 52 29 54 28 56 27 58 26 60 24 62 22 64 21 66 20 68 18 70 17 72 16 74 14 76 13 78 12 80 11 82 10 84 8 86 6 88 4 90 2 92 1 94 29 28 27 27 26 26 25 25 24 2...
result:
ok correct
Test #35:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
454848871
output:
95 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 39 42 38 44 36 46 34 48 33 50 32 52 31 54 29 56 27 58 25 60 24 62 23 64 22 66 20 68 18 70 16 72 15 74 14 76 13 78 11 80 10 82 8 84 6 86 5 88 3 90 2 92 1 94 28 27 26 25 25 24 23 23 22 22...
result:
ok correct
Test #36:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
151401319
output:
89 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 36 38 35 40 33 42 32 44 31 46 30 48 29 50 28 52 26 54 24 56 23 58 22 60 21 62 19 64 17 66 16 68 15 70 13 72 11 74 10 76 8 78 6 80 5 82 3 84 2 86 1 88 27 26 25 24 24 23 22 22 21 21 20 19 19 18 18 17...
result:
ok correct
Test #37:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
280898521
output:
97 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 42 44 41 46 40 48 39 50 37 52 36 54 34 56 32 58 30 60 28 62 26 64 25 66 24 68 23 70 21 72 20 74 18 76 17 78 15 80 13 82 11 84 9 86 8 88 6 90 4 92 3 94 1 96 28 27 27 26 25 25 24 24...
result:
ok correct
Test #38:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
412968047
output:
94 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 38 41 37 43 36 45 35 47 33 49 32 51 31 53 29 55 27 57 25 59 24 61 22 63 21 65 19 67 17 69 16 71 15 73 13 75 12 77 11 79 10 81 8 83 6 85 4 87 3 89 2 91 1 93 28 27 26 25 24 24 23 23 22 22 21...
result:
ok correct
Extra Test:
score: 0
Extra Test Passed