14分求助
查看原帖
14分求助
487383
imnoob楼主2024/3/2 08:53

点2AC, 其他全WA

#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
long long k, x, y;
void slove(long long x1, long long y1, long long x2, long long y2, long long n)
{
	if(n == 1)
	{
		return;
	}
	n /= 2;
	if(x1 - x2 < n && y1 - y2 < n)
	{
		cout << x2 + n << ' ' << y2 + n << ' ' << 1 << '\n';
		slove(x1, y1, x2, y2, n);
		slove(x2 + n - 1, y2 + n, x2, y2 + n, n);
		slove(x2 + n, y2 + n - 1, x2 + n, y2, n);
		slove(x2 + n, y2 + n, x2 + n, y2 + n, n);
		return;
	}
	if(x1 - x2 < n && y1 - y2 >= n)
	{
		cout << x2 + n << ' ' << y2 + n - 1 << ' ' << 2 << '\n';
		slove(x2 + n - 1, y2 + n - 1, x2, y2, n);
		slove(x1, y1, x2, y2 + n, n);
		slove(x2 + n, y2 + n - 1, x2 + n, y2, n);
		slove(x2 + n, y2 + n, x2 + n, y2 + n, n);
		return;
	}
	if(x1 - x2 >= n && y1 - y2 < n)
	{
		cout << x2 + n - 1 << ' ' << y2 + n << ' ' << 3 << '\n';
        slove(x2 + n - 1, y2 + n - 1, x2, y2, n);
        slove(x2 + n - 1, y2 + n, x2, y2 + n, n);
        slove(x1, y1, x2 + n, y2, n);
        slove(x2 + n, y2 + n, x2 + n, y2 + n, n);
        return;
	}
    cout << x2 + n - 1 << ' ' << y2 + n - 1 << ' ' << 4 << '\n';
    slove(x2 + n - 1, y2 + n - 1, x2, y2, n);
    slove(x2 + n - 1, y2 + n, x2, y2 + n, n);
    slove(x2 + n, y2 + n - 2, x2 + n, y2, n);
    slove(x1, y1, x2 + n, y2 + n, n);
    return;
}
int main()
{
	cin >> k >> x >> y;
	slove(x, y, 1, 1, pow(2, k));
	return 0;
}
2024/3/2 08:53
加载中...