3 条题解

  • 0
    @ 2026-11-21 17:39:26

    #include<bits/stdc++.h> using namespace std; const int MAX=1<<11; char mp[MAX][MAX]; void dfs(int x,int y,int sz);

    int main(){ int n; cin>>n; memset(mp,' ',sizeof mp); dfs(0,0,n); int h=1<<n; for(int i=0;i<h;i++) { int last=0; for(int j=0;j<(1<<(n+1));j++) if(mp[i][j]!=' ') last=j; for(int j=0;j<=last;j++) cout<<mp[i][j]; cout<<endl; } return 0; }

    void dfs(int x,int y,int sz){ if(sz==1) { mp[x][y+1]='/'; mp[x][y+2]='\'; mp[x+1][y]='/'; mp[x+1][y+1]=''; mp[x+1][y+2]=''; mp[x+1][y+3]='\'; return; } int half=1<<(sz-1); dfs(x,y+half,sz-1); dfs(x+half,y,sz-1); dfs(x+half,y+half*2,sz-1); }

    信息

    ID
    1295
    时间
    1000ms
    内存
    256MiB
    难度
    6
    标签
    递交数
    429
    已通过
    140
    上传者