Director_Ni @ 2024-11-12 17:36:00
56fen求调
#include <bits/stdc++.h>
using namespace std;
// int x0,y0;
//bool a[1025][1025] = {0};
long long n;
void solve( long long x1, long long y1, long long l, long long x0, long long y0)
{
long long t = l >> 1;
bool a1 = (x0 >=x1 + t), a2 = (y0 >= y1 + t);
// 空点在右侧,空点在下侧
if (l != 1)
{
if (a1 && a2)
{ // 右下
cout << y1 + t - 1 << " " << x1 + t - 1 << " 4" << endl;
solve(x1, y1, t, x1 + t - 1, y1 + t - 1); // 左上
solve(x1 + t, y1, t, x1 + t, y1 + t - 1); // 右上
solve(x1, y1 + t, t, x1 + t , y1 + t-1); // 左下
solve(x1 + t, y1 + t, t, x0, y0);
}
else if (a1 && !a2)
{ // 右上kong
cout << y1 + t << " " << x1 + t -1<< " 2" << endl;
solve(x1, y1, t, x1 + t - 1, y1 + t-1 ); // 左上
solve(x1 + t, y1, t, x0,y0); // 右上
solve(x1, y1 + t, t, x1 + t - 1, y1 + t); // 左下
solve(x1 + t, y1 + t, t, x1 + t , y1 + t);
}
else if (!a1 && !a2)
{ // 左上
cout << y1 + t << " " << x1 + t << " 1" << endl;
solve(x1, y1, t, x0,y0); // 左上
solve(x1 + t, y1, t, x1 + t , y1 + t-1); // 右上
solve(x1, y1 + t, t, x1 + t-1 , y1 + t); // 左下
solve(x1 + t, y1 + t, t, x1 + t , y1 + t);
}
else if (!a1 && a2)
{ //左下
cout << y1 + t -1 << " " << x1 + t << " 3" << endl;
solve(x1, y1, t, x1 + t-1 , y1 + t-1); // 左上
solve(x1 + t, y1, t, x1 + t , y1 + t-1); // 右上
solve(x1, y1 + t, t, x0,y0); // 左下
solve(x1 + t, y1 + t, t, x1 + t , y1 + t);
}
}
else
return;
}
int main()
{
cin >> n;
long long v, z;//x0 y0
cin >> v >> z;
n = pow(2, n);
solve(1,1,n,v,z);
return 0;
}
by hark @ 2024-12-04 20:53:11
#include<bits/stdc++.h>
using namespace std;
void up(int k,int x,int y,int x0,int y0){
int hn=k/2;
if(hn<1)return;
if(x<x0+hn&&y<y0+hn){//第一象限
cout<<x0+hn<<" "<<y0+hn<<" 1"<<endl;
up(hn,x,y,x0,y0);
up(hn,x0+hn-1,y0+hn,x0,y0+hn);
up(hn,x0+hn,y0+hn-1,x0+hn,y0);
up(hn,x0+hn,y0+hn,x0+hn,y0+hn);
}else if(x<x0+hn&&y>=y0+hn){//第二象限
cout<<x0+hn<<" "<<y0+hn-1<<" 2"<<endl;
up(hn,x0+hn-1,y0+hn-1,x0,y0);
up(hn,x,y,x0,y0+hn);
up(hn,x0+hn,y0+hn-1,x0+hn,y0);
up(hn,x0+hn,y0+hn,x0+hn,y0+hn);
}else if(x>=x0+hn&&y<y0+hn){//第三象限
cout<<x0+hn-1<<" "<<y0+hn<<" 3"<<endl;
up(hn,x0+hn-1,y0+hn-1,x0,y0);
up(hn,x0+hn-1,y0+hn,x0,y0+hn);
up(hn,x,y,x0+hn,y0);
up(hn,x0+hn,y0+hn,x0+hn,y0+hn);
}else if(x>=x0+hn&&y>=y0+hn){//第四象限
cout<<x0+hn-1<<" "<<y0+hn-1<<" 4"<<endl;
up(hn,x0+hn-1,y0+hn-1,x0,y0);
up(hn,x0+hn-1,y0+hn,x0,y0+hn);
up(hn,x0+hn,y0+hn-1,x0+hn,y0);
up(hn,x,y,x0+hn,y0+hn);
}
}
int main(){
int n;
cin>>n;
int x0,y0;
cin>>y0>>x0;
n=1<<n;
up(n,x0,y0,1,1);
return 0;
}
我也一样
by zhanghaozhen @ 2024-12-07 16:32:49
@Director_Ni 你这是x,y与数学坐标系的弄混了 这里x指横排,y是纵列,也就是第几排,第几列 建议输入时的x,y对调一下 其他不用改先输入y,在输入x
by zhanghaozhen @ 2024-12-07 16:34:25
@hark 你和楼主一样,看看我回复楼主的。 给个关注谢谢
by zhanghaozhen @ 2024-12-07 16:34:56
@Director_Ni 求关注谢谢
by hark @ 2024-12-07 20:24:27
@zhanghaozhen 谢谢,关注了
by Director_Ni @ 2024-12-11 12:50:36
感谢