第九个点输出超限,求帮助
查看原帖
第九个点输出超限,求帮助
366108
tombs楼主2021/9/13 19:59
#include<iostream>
#include<cstring>
#define re register
using namespace std;
int n,m;
char a[10010][10010];
void del(int x,int y){
	a[x][y]=' ';
	//cout<<x<<" "<<y<<endl;
	if(a[x+1][y-1]!=' ') del(x+1,y-1);
	if(a[x+1][y+1]!=' ') del(x+1,y+1);
}
void solve(int x,int y){
	int tx=x,ty=y;
	if(a[x-1][y-1]=='\\')
	  while(a[--x][--y]=='\\') a[x][y]=' ';
	else if(a[x-1][y+1]=='/')
	  while(a[--x][++y]=='/')  a[x][y]=' ';
	del(tx,ty);
}
int main(){
	ios::sync_with_stdio(false);
	memset(a,' ',sizeof a);
	cin>>m>>n;
	int k=(3<<(m-2));
	for(re int j=1;j<=6*(1<<(m-2));++j)
		if(j%6==1||j%6==5) a[k][j]='o';
		else a[k][j]=' ';
	for(re int i=k-1;i>=1;--i){
		int t=0;
		for(re int j=1;j<=6*(1<<(m-2));++j){
			//if (a[i+1][j]=='o') t++;
		    if(a[i+1][j-1]=='/'&&a[i+1][j+1]=='\\') 
		        a[i][j]='o';
		    else if(a[i+1][j-1]=='/') a[i][j]='/';
		    else if(a[i+1][j+1]=='\\') a[i][j]='\\';
		    else if(a[i+1][j-1]=='o'&&t==0&&a[i][j-2]!='\\') a[i][j]='/',t=1;
		    else if(a[i+1][j+1]=='o'&&t==1) a[i][j]='\\',t=0;
		    else a[i][j]=' ';
		}
	}
	for(re int i=1;i<=n;++i){
		int x,y;
		cin>>x>>y;
		if(m-x>=2)
		  a[k-(3*(1<<(m-x-1)))+1][(2*y-1)*(3<<(m-x-1))]=' ';
		else if(m-x==0&&y%2==0) a[k][y/2*6-1]=' ';
		else if(m-x==0&&y%2==1) a[k][y/2*6+1]=' ';
		else if(m-x==1) a[k-2][(2*y-1)*3]=' ';
	}
	for(re int i=0;i<=k;++i){
		for(re int j=0;j<=6*(1<<(m-2));++j){
			if(a[i+1][j+1]=='\\'&&a[i-1][j-1]=='\\'&&a[i][j]==' ')
		        solve(i,j);
		    if(a[i+1][j-1]=='/'&&a[i-1][j+1]=='/'&&a[i][j]==' ')
		        solve(i,j);
		    if(a[i+1][j+1]=='\\'&&a[i-1][j+1]=='/'&&a[i][j]==' ')
		        solve(i,j);
		    if(a[i+1][j-1]=='/'&&a[i-1][j-1]=='\\'&&a[i][j]==' ')
		        solve(i,j);
		    if(a[i-1][j+1]=='/'&&a[i][j]==' '&&i==k)
		        solve(i,j);
		    if(a[i-1][j-1]=='\\'&&a[i][j]==' '&&i==k)
		        solve(i,j);
		}
		 
	}
	for(re int i=1;i<=k;++i,cout<<endl){
		string s="";
		for(re int j=1;j<=6*(1<<(m-2));++j)
	      s+=a[i][j];
	    cout<<s;
	    while(s[s.size()-1]==' ')                   s.erase(s.size()-1,1);
	}
	  
}
2021/9/13 19:59
加载中...