1 条题解
-
1
#include<bits/stdc++.h> using namespace std; void read(int &h){ char o; int x=0,y=1; o=getchar_unlocked(); while(!(o<='9'&&o>='0')){ if(o=='-'){ y=-1; } o=getchar_unlocked(); } while(o<='9'&&o>='0'){ x*=10; x+=o-'0'; o=getchar_unlocked(); } h=x*y; return ; } int n,m,o,oo; int deep[15]={0,1,2,5,11,23,47,95,191,383,767,1535}; char tree[10000][10000]; bool check[1000000]; void buildroot(int,int,int,int); void buildlc(int a,int b,int x,int y){ int i=x,j=y,now=deep[b]; while(now--){ i++;j--; tree[i][j]='/'; } i++,j--; tree[i][j]='o'; buildroot(a,b-1,i,j); } void buildrc(int a,int b,int x,int y){ int i=x,j=y,now=deep[b]; while(now--){ i++;j++; tree[i][j]='\\'; } i++,j++; tree[i][j]='o'; buildroot(a,b-1,i,j); } void buildroot(int a,int b,int x,int y){ if(!b){ return ; } if(check[a*2]){ buildlc(a*2,b,x,y); } if(check[a*2+1]){ buildrc(a*2+1,b,x,y); } } int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); memset(tree,char(32),sizeof(tree)); read(m);read(n); for(int i=1;i<(1<<m);i++){ check[i]=1; } for(int i=1;i<=n;i++){ read(o);read(oo); int now=(1<<(o-1))-1; now+=oo; check[now]=0; } tree[1][deep[m]+1]='o'; buildroot(1,m-1,1,deep[m]+1); for(int i=1;i<=deep[m]+1;i++){ for(int j=1;j<=deep[m+1]+1;j++){ printf("%c",tree[i][j]); } printf("\n"); } return 0; }
- 1
信息
- ID
- 5243
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 6
- 标签
- 递交数
- 8
- 已通过
- 6
- 上传者