zby2_ @ 2024-07-02 17:42:13
#include<bits/stdc++.h>
using namespace std;
void f(int x,int y,int gx,int gy,int l){
if(l==1) return;
if(gx<=x+l/2-1 && gy<=y+l/2-1){
cout<<x+l/2<<" "<<y+l/2<<" "<<1<<endl;
f(x,y,gx,gy,l/2);
f(x,y+l/2,x+l/2-1,y+l/2,l/2);
f(x+l/2,y,x+l/2,y+l/2-1,l/2);
f(x+l/2,y+l/2,x+l/2,y+l/2,l/2);
}
else if(gx<=x+l/2-1 && gy>=y+l/2){
cout<<x+l/2<<" "<<y+l/2-1<<" "<<2<<endl;
f(x,y,x+l/2-1,y+l/2-1,l/2);
f(x,y+l/2,gx,gy,l/2);
f(x+l/2,y,x+l/2,y+l/2-1,l/2);
f(x+l/2,y+l/2,x+l/2,y+l/2,l/2);
}
else if(gx>=x+l/2 && gy<=y+l/2-1){
cout<<x+l/2-1<<" "<<y+l/2<<" "<<3<<endl;
f(x,y,x+l/2-1,y+l/2-1,l/2);
f(x,y+l/2,x+l/2-1,y+l/2,l/2);
f(x+l/2,y,gx,gy,l/2);
f(x+l/2,y+l/2,x+l/2,y+l/2,l/2);
}
else if(gx<=x+l/2-1 && gy>=y+l/2){
cout<<x+l/2<<" "<<y+l/2-1<<" "<<2<<endl;
f(x,y,x+l/2-1,y+l/2-1,l/2);
f(x,y+l/2,gx,gy,l/2);
f(x+l/2,y,x+l/2,y+l/2-1,l/2);
f(x+l/2,y+l/2,x+l/2,y+l/2,l/2);
}
}
int main(){
int k,x,y;
cin>>k>>x>>y;
f(1,1,x,y,pow(2,k));
return 0;
}
by ouxiyao @ 2024-08-06 16:32:25
坐标是反的!