c++28分求大佬调qwq
查看原帖
c++28分求大佬调qwq
765239
sakura_21楼主2024/7/10 11:57
#include<bits/stdc++.h>
#define int long long
using namespace std;
int k,xx,yy;
void dt(int k,int x,int y,int u,int l)
{
	if (k==0)return ;
	if (k==1)
	{
		if (x==u&&y==l)
		{
			cout<<u+1<<" "<<l+1<<" 1"<<endl;
		}
		else if (x==u&&y==l+1)
		{
			cout<<u+1<<" "<<l<<" 2"<<endl;
		}
		else if (x==u+1&&y==l)
		{
			cout<<u<<" "<<l+1<<" 3"<<endl;
		}
		else if (x==u+1&&y==l+1)
		{
			cout<<u<<" "<<l<<" 4"<<endl;
		}
		return ;
	}
	else//void dt(int k,int x,int y,int u,int l)
	{
		int h=u+pow(2,k-1)-1,s=l+pow(2,k-1)-1;
		if (x<=h&&y<=s)

		{
			cout<<h+1<<" "<<s+1<<" 1"<<endl;
			dt(k-1,x,y,u,l);
			dt(k-1,h,s+1,u,s+1);
			dt(k-1,h+1,s,h+1,l);
			dt(k-1,h+1,s+1,h+1,s+1);
			return ;
		}
		
		
		else if (x<=h&y>s)
		{
			cout<<h+1<<" "<<s<<" 2"<<endl;
			dt(k-1,h,s,u,l);
			dt(k-1,x,y,u,s+1);
			dt(k-1,h+1,s,h+1,l);
			dt(k-1,h+1,s+1,h+1,s+1);
		}
		
		
		else if (x>h&&y<=s)
		{
			cout<<h<<" "<<s+1<<" 3"<<endl;
			dt(k-1,h,s,u,l);
			dt(k-1,h,s+1,u,s+1);
			dt(k-1,x,y,h+1,l);
			dt(k-1,h+1,s+1,h+1,s+1);
		}
		
		
		else if (x>h&&y>s)
		{
			cout<<h<<" "<<s<<" 4"<<endl;
			dt(k-1,h,s,u,l);
			dt(k-1,h,s+1,u,s+1);
			dt(k-1,h+1,s,h+1,l);
			dt(k-1,x,y,s+1,h+1);
		}
		return ;
	}
}
signed main()
{
	cin>>k;
	cin>>xx>>yy;
	dt(k,xx,yy,1,1);
	return 0;
}
2024/7/10 11:57
加载中...