lij123 @ 2023-07-26 13:29:53
#include<bits/stdc++.h>
using namespace std;
int k,x_p,y_p;
int prin(int a,int b,int a3,int b3){
int ans=0;
if(a>a3) ans+=2;
if(b>b3) ans++;
return ans;
}
void make_s(int a1,int b1,int a2,int b2,int x,int y){
if(a1+1==a2&&b1+1==b2){
switch(x-a1+y-b1){
case 0:cout<<a2<<" "<<b2<<" "<<3<<endl;return ;
case 2:cout<<a1<<" "<<b1<<" "<<4<<endl;return ;
}
if(x==a1) cout<<a2<<" "<<b1<<" "<<1<<endl;
else cout<<a1<<" "<<b2<<" "<<2<<endl;
return ;
}
int a3=(a1+a2)/2,b3=(b1+b2)/2;
switch(prin(x,y,a3,b3)){
case 0:cout<<a3+1<<" "<<b3+1<<" "<<3<<endl;
make_s(a1,b1,a3,b3,x,y);
make_s(a1,b3+1,a3,b2,a3,b3+1);
make_s(a3+1,b1,a2,b3,a3+1,b3);
make_s(a3+1,b3+1,a2,b2,a3+1,b3+1);
return ;
case 1:cout<<a3+1<<" "<<b3<<" "<<1<<endl;
make_s(a1,b1,a3,b3,a3,b3);
make_s(a1,b3+1,a3,b2,x,y);
make_s(a3+1,b1,a2,b3,a3+1,b3);
make_s(a3+1,b3+1,a2,b2,a3+1,b3+1);
return ;
case 2:cout<<a3<<" "<<b3+1<<" "<<2<<endl;
make_s(a1,b1,a3,b3,a3,b3);
make_s(a1,b3+1,a3,b2,a3,b3+1);
make_s(a3+1,b1,a2,b3,x,y);
make_s(a3+1,b3+1,a2,b2,a3+1,b3+1);
return ;
case 3:cout<<a3<<" "<<b3<<" "<<4<<endl;
make_s(a1,b1,a3,b3,a3,b3);
make_s(a1,b3+1,a3,b2,a3,b3+1);
make_s(a3+1,b1,a2,b3,a3+1,b3);
make_s(a3+1,b3+1,a2,b2,x,y);
return ;
}
}
int main(){
cin>>k>>x_p>>y_p;
k=(1<<k);
make_s(1,1,k,k,x_p,y_p);
}