Guest User

Untitled

a guest
Jul 27th, 2020
11
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. #define Z(x)if(g.find(x)==g.end())return x;
  3. using I=int;using C=char*;I a,t,s,h;struct p{I x,y;}j,k;std::map<I,std::set<I>>l;std::map<I,p>g;C m,M=" |-";I L(I n,C q,C Q){j=g[n],h=1;for(I o:l[n])if(g.find(o)!=g.end())if((a=(k=g[o]).y==j.y)|k.x==j.x)for(I x=j.x,y=j.y,e=k.y*s+k.x,b,d=k.x<j.x|k.y<j.y?-1:1;(a?x:y)+=d,(b=y*s+x)^e&&(m[b]^Q[a]?h=0:1);m[b]=q[a]);else h=0;}I N(){for(auto i:g)for(I n:l[i.first])Z(n)for(auto i:l)Z(i.first)exit(puts(m));}I f(){for(I n=N(),x,y=0,b;y<s;y+=2)for(x=0;x<s;x+=2)m[b=y*s+x]==*M?g[n]={x,y},L(m[b]=n,M+2,M),h&&f(),L(n,M,M+2),m[b]=*M,g.erase(n):0;}main(I c,C*v){for(;--c;l[s].insert(a))l[a=*v[c]].insert(s=v[c][1]);s=l.size()|1;for(memset(m=(C)calloc(a=s,s),*M,s*s-1);--a;)m[a*s-1]=10;f();}
RAW Paste Data