#include #include using namespace std; using ll=long long; #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int H,W,N,D; cin>>H>>W>>N>>D; vectorX(N),Y(N); for(int i=0;i>X[i]>>Y[i]; X[i]--; Y[i]--; } auto to=[&](int i,int j)-> int { return W*i+j; }; vector flag(H,vector(W)); for(int i=0;iD)continue; if(0<=i+p&&i+pR(H*W); int cnt=0; for(int i=0;i=2)cnt++; } } } int ans_min=H*W,ans_max=0; for(int i=0;ise; int b=0; for(int p=-D;p<=D;p++)for(int q=-D;q<=D;q++){ if(abs(p)+abs(q)>D)continue; if(0<=i+p&&i+p