过了样例,测试时第二个AC,其余都WR

P1228 地毯填补问题

mazel @ 2023-09-20 16:57:43

#include<iostream>
using namespace std;

#define upleft deal(a,b,a+l-1,b+l-1,l);   //左上
#define upright deal(a,a+l,a+l-1,b+l,l);   //右上
#define downleft deal(a+l,b,a+l,b+l-1,l);   //左下
#define downright deal(a+l,b+l,a+l,b+l,l);   //右下

void deal(int a,int b,int x,int y,int l)
{
    if (l == 1)return;        //递归终止条件
    l >>= 1;
    if (x - a < l && y - b < l)       //判断在左上
    {
        cout << a + l << " " << b + l << " 1" << endl;
        deal(a, b, x, y, l);
        upright
        downleft
        downright
    }
    else if (x - a < l && y - b >= l)   //判断在右上
    {
        cout << a + l << " " << b + l - 1 << " 2" << endl;
        deal(a, b + l, x, y, l);
        upleft
        downleft
        downright
    }
    else if (x - a >= l && y - b < l)   //判断在左下
    {
        cout << a + l - 1 << " " << b + l << " 3" << endl;
        deal(a + l, b, x, y, l);
        upleft
        upright
        downright
    }
    else if (x - a >= 1 && y - b >= 1)   //判断在右下
    {
        cout << a + l - 1 << " " << b + l - 1 << " 4" << endl;
        deal(a + l, b + l, x, y, l);
        upleft
        upright
        downleft
    }
}
int main()
{
    int k = 0;
    int x = 0, y = 0;
    cin >> k;
    cin >> x >> y;
    deal(1, 1, x, y, 1 << k);
    return 0;
}

by hexuchen @ 2023-09-20 16:58:40

@mazel 《WR》


by mazel @ 2023-09-21 15:29:16

@hexuchen 请问什么意思啊?


by Tang____ @ 2024-01-13 22:27:08

注意输出的顺序和样例可能不同,(递归顺序不要错),递归顺序是:先坐上,再右上,再左下,再右下。真被ex到了


by HEROBRINEH @ 2024-02-10 12:44:45

@hexuchen 应该是wrong的意思


|