typedef long long ll; typedef long double ld; #include using namespace std; #define int long long ll isqrt(ll N){ ll sqrtN=sqrt(N)-1; while(sqrtN+1<=N/(sqrtN+1))sqrtN++; return sqrtN; } // Union-Find struct UnionFind { // core member vector par; // constructor UnionFind() { } UnionFind(int n) : par(n, -1) { } void init(int n) { par.assign(n, -1); } // core methods int root(int x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool same(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x), y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); // merge technique par[x] += par[y]; par[y] = x; return true; } int size(int x) { return -par[root(x)]; } // debug friend ostream& operator << (ostream &s, UnionFind uf) { map> groups; for (int i = 0; i < uf.par.size(); ++i) { int r = uf.root(i); groups[r].push_back(i); } for (const auto &it : groups) { s << "group: "; for (auto v : it.second) s << v << " "; s << endl; } return s; } }; signed main(){ ll n,k; std::cin >> n>>k; pair s,g; std::cin >> s.first>>s.second>>g.first>>g.second; vector x(n),y(n); for (int i = 0; i < n; i++) { std::cin >> x[i]>>y[i]; } ll r = 2*1e7; ll l = 0; while(r-l>1){ ll m =(r+l)/2; vector dd(n+2,1e10); dd[n]=0; using P = pair; priority_queue,greater

> pq; pq.push({0, n}); vector> dis(n+2,vector(n+2)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { dis[i][j] = (abs(x[i]-x[j])+abs(y[i]-y[j])+m-1)/m-1; } } for (int i = 0; i < n; i++) { dis[n][i] = dis[i][n] = (abs(x[i]-s.first)+abs(y[i]-s.second)+m-1)/m-1; dis[n+1][i] = dis[i][n+1] = (abs(x[i]-g.first)+abs(y[i]-g.second)+m-1)/m-1; } for (int i = 0; i < n+2; i++) { dis[i][i] = 0; } dis[n][n+1]=dis[n+1][n] = abs(s.first-g.first)+abs(s.second-g.second); while(!pq.empty()){ auto [dist, pos] = pq.top();pq.pop(); // std::cout << dist<<" "<dd[pos])continue; for (int i = 0; i < n+2; i++) { if(i==pos)continue; // std::cout << i<<" "<dist+dis[pos][i]){ dd[i] = dist+dis[pos][i]; // std::cout << l<<" "<