QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#405138 | #8320. 种树 | marher | 0 | 0ms | 0kb | C++14 | 1.5kb | 2024-05-05 11:55:27 | 2024-05-05 11:55:35 |
answer
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned __int128
const int N=150;
int now;
char s[N];
ull z=1,f[N][N],g[N][N];
void dfs(int x,const int*p,int n)
{
// if(x==69)
// {
// cerr<<x<<' '<<n<<'\n';
// for(int i=1;i<=n;i++)cerr<<p[i]<<' ';
// cerr<<'\n';
// }
for(int i=1;i<=n;i++)if(p[i]==x)
{
s[now++]='(';
dfs(i,p,n);
s[now++]=')';
}
}
ull encoder(int n, const int *p)
{
// for(int i=1;i<=n;i++)cerr<<p[i]<<' ';cerr<<'\n';
// exit(0);
dfs(1,p,n);
f[0][0]=1;
for(int i=1;i<N;i++)
{
f[i][0]=f[i-1][1];
for(int j=1;j<N;j++)f[i][j]=f[i-1][j-1]+f[i-1][j+1];
}
ull rk=0;int num=0;
for(int i=0;i<now;i++)
{
if(s[i]==')')rk+=f[now-i-1][num+1],num--;
else num++;
}
// cerr<<s<<' '<<now<<'\n';
return rk+1;
}
char t[N];
void decoder(int n, ull M, int *p)
{
g[0][0]=1;
for(int i=1;i<N;i++)
{
g[i][0]=g[i-1][1];
for(int j=1;j<N;j++)g[i][j]=g[i-1][j-1]+g[i-1][j+1];
}
int num=0,len=2*n-2;
for(int i=1;i<=len;i++)
{
if(num+1<=(len>>1)&&g[len-i][num+1]>=M) t[i]='(',num++;
else
{
t[i]=')';
if(num+1<=(len>>1)) M-=g[len-i][num+1];
num--;
}
}
// cerr<<(t+1)<<'\n';
int cnt=1,now=1;
for(int i=1;i<=len;i++)
{
if(t[i]=='(')
{
p[++cnt]=now;now=cnt;
}
else now=p[now];
}
}
詳細信息
Subtask #1:
score: 0
Stage 1: Program encoder Runtime Error
Test #1:
score: 0
Stage 1: Program encoder Runtime Error
Manager to Encoder
3000 64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 36 14 30 9 50 27 42 13 18 34 16 12 22 47 65 0 1 2 2 2 3 1 7 1 8 6 10 8 6 5 1 15 1 6 18 2 6 12 10 14 13 10 9 20 29 17 16 19 6 5 31 9 32 33 37 39 31 38 33...
Encoder to Manager
Manager to Decoder
Decoder to Manager
result:
Subtask #2:
score: 0
Stage 1: Program encoder Runtime Error
Test #2:
score: 0
Stage 1: Program encoder Runtime Error
Manager to Encoder
3000 66 0 1 1 2 4 2 6 7 3 3 6 9 10 10 13 4 8 12 15 5 18 15 9 13 8 5 17 20 17 16 11 19 18 30 29 22 23 35 37 33 36 27 27 7 23 25 21 46 22 45 40 25 20 43 38 41 34 35 34 29 50 42 47 24 24 40 70 0 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 1 1 1 1 1 13 19 32 1 20 14 25 42 14 30 2...
Encoder to Manager
Manager to Decoder
Decoder to Manager
result:
Subtask #3:
score: 0
Stage 1: Program encoder Runtime Error
Test #3:
score: 0
Stage 1: Program encoder Runtime Error
Manager to Encoder
100000 70 0 1 2 2 2 2 1 2 4 8 3 1 6 12 13 6 1 14 2 8 3 6 2 1 8 25 24 5 10 11 30 28 15 7 23 20 12 29 28 17 31 27 10 18 6 3 38 39 40 43 7 33 23 23 38 28 24 26 57 44 16 18 20 39 9 26 25 16 67 58 67 0 1 1 1 1 4 3 4 6 2 10 3 10 7 14 6 11 15 7 13 6 14 18 9 9 4 20 24 28 3 20 7 4 18 32 5 12 25 7 12 7 20 18 ...
Encoder to Manager
Manager to Decoder
Decoder to Manager
result:
Subtask #4:
score: 0
Stage 1: Program encoder Runtime Error
Test #4:
score: 0
Stage 1: Program encoder Runtime Error
Manager to Encoder
100000 68 0 1 1 3 4 4 3 5 7 8 8 10 9 10 11 11 14 15 7 14 13 6 17 6 21 16 20 25 9 2 5 28 25 24 30 32 27 16 23 33 27 26 42 22 15 40 2 22 31 12 47 50 18 12 38 50 39 18 52 34 38 59 56 61 19 46 55 56 70 0 1 2 1 2 4 4 3 6 6 7 10 11 5 9 15 13 9 5 11 7 14 22 20 21 21 10 13 19 12 17 12 20 15 14 18 17 19 24 2...
Encoder to Manager
Manager to Decoder
Decoder to Manager
result:
Subtask #5:
score: 0
Stage 1: Program encoder Runtime Error
Test #5:
score: 0
Stage 1: Program encoder Runtime Error
Manager to Encoder
100000 70 0 1 1 3 3 5 4 5 8 8 4 9 11 9 11 14 7 13 2 14 17 15 12 6 18 21 20 22 18 25 7 10 27 22 15 32 30 6 33 38 25 19 10 16 32 36 23 36 41 29 38 17 21 16 45 37 23 24 37 19 30 29 27 42 53 41 2 64 58 40 65 0 1 2 3 3 4 2 5 5 6 10 10 8 1 13 5 6 4 4 5 5 15 16 16 6 8 7 20 6 24 10 22 19 17 17 32 31 37 1 25...