12345limengqi @ 2023-12-15 12:41:27
#include <iostream>
#include <cmath>
using namespace std;
#define ll long long
void h(ll x, ll y, ll gx, ll gy, ll 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;
h(x, y, gx, gy, l / 2);
h(x, y + l / 2, x + l / 2 - 1, y + l / 2, l / 2);
h(x + l / 2, y, x + l / 2, y + l / 2 - 1, l / 2);
h(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;
h(x, y, x + l / 2 - 1, y + l / 2 - 1, l / 2);
h(x, y + l / 2, gx, gy, y + l / 2);
h(x + l / 2, y, x + l / 2, y + l / 2 - 1, l / 2);
h(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;
h(x, y, x + l / 2 - 1, y + l / 2 - 1, l / 2);
h(x, y + l / 2, x + l / 2 - 1, y + l / 2, l / 2);
h(x + l / 2, y, gx, gy, l / 2);
h(x + l / 2, y + l / 2, x + l / 2, y + l / 2, l / 2);
}
else if(gx >= x + l / 2 && gy >= y + l / 2){
cout << x + l / 2 - 1 << " " << y + l / 2 - 1 << " " << 4 << endl;
h(x, y, x + l / 2 - 1, y + l / 2 - 1, l / 2);
h(x, y + l / 2, x + l / 2 - 1, y + l / 2, l / 2);
h(x + l / 2, y, x + l / 2, y + l / 2 - 1, l / 2);
h(x + l / 2, y + l / 2, gx, gy, l / 2);
}
}
ll a, x, y;
int main () {
cin >> a >> x >> y;
h(1, 1, x, y, pow(2, a));
return 0;
}
by 12345limengqi @ 2023-12-15 12:42:04
快把我逼疯了
by 12345limengqi @ 2023-12-15 12:44:00
回复记得@我一下