#include #include #include using namespace std; typedef long long ll; int main() { int n, m; cin >> n >> m; int mat[n][m]; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { mat[i][j] = -1; } } int R, K; cin >> R >> K; R--; K--; queue Q; Q.push(R); Q.push(K); Q.push(0); mat[R][K] = 0; int biggest_number = 0; while(!Q.empty()) { int ci = Q.front(); Q.pop(); int cj = Q.front(); Q.pop(); int number = Q.front(); Q.pop(); biggest_number = max(biggest_number, number); if(ci + 1 < n and mat[ci + 1][cj] == -1) { Q.push(ci + 1); Q.push(cj); Q.push(number + 1); mat[ci + 1][cj] = number + 1; } if(ci - 1 >= 0 and mat[ci - 1][cj] == -1) { Q.push(ci - 1); Q.push(cj); Q.push(number + 1); mat[ci - 1][cj] = number + 1; } if(cj + 1 < m and mat[ci][cj + 1] == -1) { Q.push(ci); Q.push(cj + 1); Q.push(number + 1); mat[ci][cj + 1] = number + 1; } if(cj - 1 >= 0 and mat[ci][cj - 1] == -1) { Q.push(ci); Q.push(cj - 1); Q.push(number + 1); mat[ci][cj - 1] = number + 1; } } int chocolates = 0; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(mat[i][j] == biggest_number) { chocolates++; } } } cout << biggest_number << endl; cout << chocolates << endl; return 0; }