可真麻烦啊
#include<iostream>
using namespace std;
const int N = 1e4 + 10;
int w, n, m, house[N][N];
int main()
{
cin >> w >> n >> m;
if(n > m) swap(n, m);
//定义起始点
int i = 1, j = 1, t = 1;
//记录n的未知
int nx, ny;
while(t <= m)
{
while(j <= w && t <= m)
{
if(t == n) nx = i, ny = j;
t ++, j ++;
}
if(t <= m) i ++, j --;
while(t <= m && j >= 1)
{
if(t == n) nx = i, ny = j;
t ++, j --;
// cout << i << endl;
}
if(t <= m) i ++, j ++;
}
if(i % 2) j --;
else j ++;
cout << abs(nx - i) + abs(ny - j) << endl;
}