样例对了,可交到洛谷上只有14分,怎么回事,求大佬解答

P1228 地毯填补问题

JMY111213 @ 2024-09-27 22:23:28

样例对了,可交到洛谷上只有14分,怎么回事


using namespace std;
void f(int x,int y,int gx,int gy,int 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;
        f(x,y,gx,gy,l/2);
        f(x,y+l/2,x+l/2-1,y+l/2,l/2);
        f(x+l/2,y,x+l/2,y+l/2-1,l/2);
        f(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;
        f(x,y,x+l/2-1,y+l/2-1,l/2);
        f(x,y+l/2,gx,gy,l/2);
        f(x+l/2,y,x+l/2,y+l/2-1,l/2);
        f(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;
        f(x,y,x+l/2-1,y+l/2-1,l/2);
        f(x,y+l/2,x+l/2-1,y+l/2,l/2);
        f(x+l/2,y,gx,y+l/2-1,l/2);
        f(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;
        f(x,y,x+l/2-1,y+l/2-1,l/2);
        f(x,y+l/2,x+l/2-1,y+l/2,l/2);
        f(x+l/2,y,x+l/2,y+l/2-1,l/2);
        f(x+l/2,y+l/2,gx,gy,l/2);
    }
}

int main(){
    int k,x,y;
    cin>>k>>x>>y;
    f(1,1,x,y,pow(2,k));
    return 0;
} ```

|