Help me in solving ICL16AA problem

My issue

give correct code

My code

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

#define MAX_N 2000
#define MAX_M 25

// Function to calculate the maximum absolute difference between corresponding characters in two rows
int calculate_distance(char *row1, char *row2, int m) {
    int max_diff = 0;
    for (int i = 0; i < m; ++i) {
        int diff = abs(row1[i] - row2[i]);
        if (diff > max_diff) {
            max_diff = diff;
        }
    }
    return max_diff;
}

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    
    char grid[MAX_N][MAX_M + 1]; // +1 for null terminator
    
    // Read the grid
    for (int i = 0; i < n; ++i) {
        scanf("%s", grid[i]);
    }
    
    // Initialize the minimum maximum distance to the maximum possible integer value
    int min_max_cost = INT_MAX;
    
    // Compute distances
    for (int i = 1; i < n; ++i) {
        int max_cost = calculate_distance(grid[0], grid[i], m);
        if (max_cost < min_max_cost) {
            min_max_cost = max_cost;
        }
    }
    
    // Output the result
    printf("%d\n", min_max_cost);
    
    return 0;
}

Learning course: Analysis and Design of Algorithms
Problem Link: Fullmetal Alchemist in Analysis and Design of Algorithms