zzxLLL @ 2022-02-10 22:41:12
2 4 7 WA 求调
#include<cstdio>
#define printf(str,a,b) printf(str,b,a)
const int M=1200;
void solve(int x,int y,int size,int ux,int uy){
if(size==2){
if(ux==x&&uy==y) printf("%d %d 1\n",x+1,y+1);
if(ux==x+1&&uy==y) printf("%d %d 2\n",x,y+1);
if(ux==x&&uy==y+1) printf("%d %d 3\n",x+1,y);
if(ux==x+1&&uy==y+1) printf("%d %d 4\n",x,y);
return;
}
int subsize=size/2;
int midx=x+subsize,midy=y+subsize;
// 1 \ 2
//----\----
// 3 \ 4
if(ux<midx&&uy<midy){
printf("%d %d 1\n",midx,midy);
solve(x,y,subsize,ux,uy);
solve(midx,y,subsize,midx,midy-1);
solve(x,midy,subsize,midx-1,midy);
solve(midx,midy,subsize,midx,midy);
return;
}
if(ux>=midx&&uy<midy){
printf("%d %d 2\n",midx-1,midy);
solve(x,y,subsize,midx-1,midy-1);
solve(midx,y,subsize,ux,uy);
solve(x,midy,subsize,midx-1,midy);
solve(midx,midy,subsize,midx,midy);
return;
}
if(ux<midx&&uy>=midy){
printf("%d %d 3\n",midx,midy-1);
solve(x,y,subsize,midx-1,midy-1);
solve(midx,y,subsize,midx,midy-1);
solve(x,midy,subsize,ux,uy);
solve(midx,midy,subsize,midx,midy);
return;
}
if(ux>=midx&&uy>=midy){
printf("%d %d 4\n",midx-1,midy-1);
solve(x,y,subsize,midx-1,midy-1);
solve(midx,y,subsize,midx,midy-1);
solve(x,midy,subsize,midx-1,midy);
solve(midx,midy,subsize,ux,uy);
return;
}
}
int k,x,y;
int main(){
scanf("%d%d%d",&k,&x,&y);
solve(1,1,1<<k,x,y);
return 0;
}
by alsfrj @ 2022-02-19 18:15:40
输入X,Y反了 行坐标y 列坐标x 所以函数调用应该是solve(y,x)
by zzxLLL @ 2022-02-25 23:58:34
@alsfrj 已过,感谢大佬
by W_Sibo @ 2023-07-11 10:46:44
@alsfrj 非常感谢,已过