#include // Robert Nystrom #include // @munificentbob #include // for Ginny #define r return // 2008-2019 #define l(a, b, c, d) for (i y=a;y\ t +w;i t=y u+h; if(s ^t&& m[ y] [x ]=='#' ){d++; if(g (d ) ==0) e=x,f=y; }}if (d == 0)r; }l(u-1,u +h+2 ,t -1 ,t+w +2){i s= x< t || x> t+w; i t= y u+ h; m[y] [x]= s &&t? '!' :s^t ?'#' :'.' ;}if (d>0)m [f][ e]=g(2 )?'\'':'+';for(i j=0;j<(s? 1:g(6) +1);j++)m[g(h)+u][g(w) +t]=s?'@' :g(4) ==0? '$':65+g(62) ;}i main(i argc, const char* argv[]) {srand((i) time(NULL));l(0, H, 0,W)m[y][x]=' '; for(i j=0;j<1000;j++)cave(j==0);l(0, H,0,W) {i c=m[y][x]; putchar(c=='!'? '#':c);if(x==W-1)printf("\n");}r 0;}