题目
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int n,Aix,Aiy,Cnt;
int Map[1000][1000];
void Dac(int Stx,int Sty,int Dep,int Tx,int Ty,int Pas) {
if(Dep == 1) {
return;
}
int Tmp = Dep / 2;
int a = 0,b = 0,c = 0,d = 0;
if(Tx < Stx + Tmp && Ty < Sty + Tmp) { //左上
Dac(Stx,Sty,Tmp,Tx,Ty,1);
} else {
int Sx = Stx + Tmp - 1;
int Sy = Sty + Tmp - 1;
a = 1;
Dac(Stx,Sty,Tmp,Sx,Sy,1);
}
if(Tx < Stx + Tmp && Ty >= Sty + Tmp) { //左下
Dac(Stx,Sty + Tmp,Tmp,Tx,Ty,2);
} else {
int Sx = Stx + Tmp - 1;
int Sy = Sty + Tmp;
b = 1;
// printf("%d %d %d\n",Sx,Sy,2);
Dac(Stx,Sty + Tmp,Tmp,Sx,Sy,2);
}
if(Tx >= Stx + Tmp && Ty < Sty + Tmp) {
Dac(Stx + Tmp,Sty,Tmp,Tx,Ty,3);
} else {
int Sx = Stx + Tmp;
int Sy = Sty + Tmp - 1;
c = 1;
Dac(Stx + Tmp,Sty,Tmp,Sx,Sy,3);
}
if(Tx >= Stx + Tmp && Ty >= Sty + Tmp) {
Dac(Stx + Tmp,Sty + Tmp,Tmp,Tx,Ty,4);
} else {
int Sx = Stx + Tmp;
int Sy = Sty + Tmp;
d = 1;
Dac(Stx + Tmp,Sty + Tmp,Tmp,Sx,Sy,4);
}
if(!d) {
printf("%d %d %d\n",Stx + Tmp,Sty + Tmp,1);
} else if(!c) {
printf("%d %d %d\n",Stx + Tmp,Sty + Tmp,2);
} else if(!b) {
printf("%d %d %d\n",Stx + Tmp,Sty + Tmp,3);
} else if(!a){
printf("%d %d %d\n",Stx + Tmp,Sty + Tmp,4);
}
}
int main() {
scanf("%d%d%d",&n,&Aix,&Aiy);
n = (1 << n);
Dac(0,0,n,Aix - 1,Aiy - 1,0);
return 0;
}