56分求调
查看原帖
56分求调
1067789
Director_Ni楼主2024/11/12 17:36

56fen求调

#include <bits/stdc++.h>
using namespace std;
// int x0,y0;
//bool a[1025][1025] = {0};
 long long n;
void solve( long long x1,  long long y1,  long long l,  long long x0,  long long y0)
{
     long long t = l >> 1;
    bool a1 = (x0 >=x1 + t), a2 = (y0 >= y1 + t); 
        // 空点在右侧,空点在下侧
    if (l != 1)
    {
        if (a1 && a2)
        { // 右下
            cout << y1 + t - 1 << " " << x1 + t - 1 << " 4" << endl;
            solve(x1, y1, t, x1 + t - 1, y1 + t - 1); // 左上
            solve(x1 + t, y1, t, x1 + t, y1 + t - 1); // 右上
            solve(x1, y1 + t, t, x1 + t , y1 + t-1); // 左下
            solve(x1 + t, y1 + t, t, x0, y0);
        }

        else if (a1 && !a2)
        { // 右上kong
            cout << y1 + t  << " " << x1 + t -1<< " 2" << endl;
            solve(x1, y1, t, x1 + t - 1, y1 + t-1 ); // 左上
            solve(x1 + t, y1, t, x0,y0); // 右上
            solve(x1, y1 + t, t, x1 + t - 1, y1 + t); // 左下
            solve(x1 + t, y1 + t, t, x1 + t , y1 + t);
        }
        else if (!a1 && !a2)
        { // 左上
            cout << y1 + t  << " " << x1 + t  << " 1" << endl;
            solve(x1, y1, t, x0,y0); // 左上
            solve(x1 + t, y1, t, x1 + t , y1 + t-1); // 右上
            solve(x1, y1 + t, t, x1 + t-1 , y1 + t); // 左下
            solve(x1 + t, y1 + t, t, x1 + t , y1 + t);
        }
        else if (!a1 && a2)
        { //左下
            cout << y1 + t -1 << " " << x1 + t  << " 3" << endl;
            solve(x1, y1, t, x1 + t-1 , y1 + t-1); // 左上
            solve(x1 + t, y1, t, x1 + t , y1 + t-1); // 右上
            solve(x1, y1 + t, t, x0,y0); // 左下
            solve(x1 + t, y1 + t, t, x1 + t , y1 + t);
        }
    }
    else
    return;
}
int  main()
{

    cin >> n;
     long long v, z;//x0  y0
    cin >> v >> z;
    n = pow(2, n);
    solve(1,1,n,v,z);
    return 0;
}
2024/11/12 17:36
加载中...