196022025-12-16 17:27:31szabelrRácsháló gráfcpp17Compilation error
// Rácsháló gráf.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;
int dist[201][201];
int main()
{
    int n, m, k;
    cin >> n >> m>>k;
    
    for (int i = 1; i <= n*m; i++)
    {
        for (int j = 1; j <=n*m; j++)
        {
            dist[i][j]= abs((i - 1) / m - (j - 1) / m) + abs((i - 1) % m - (j - 1) % m);
        }
    }
    for (int z = 0; z < k; z++)
    {
        int a, b;
        cin >> a >> b;
        dist[a][b] = 1;
        dist[b][a] = 1;
        for (int i = 1; i <= m * n; i++)
        {
            for (int j = 1; j <= m * n; j++)
            {
                int p1 = dist[i][a] + 1 + dist[b][j];
                int p2 = dist[i][b] + 1 + dist[a][j];
                dist[i][j] = min(dist[i][j], min(p1, p2));
            }
        }
        int maxi = INT_MIN;
        for (int i = 1; i <= m*n; i++) {
            for (int j = 1; j <= m * n; j++) {
                maxi = max(dist[i][j], maxi);
            }
        }
        cout << maxi << endl;
    }

}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Compilation error
open /var/local/lib/isolate/409/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:34:20: error: 'INT_MIN' was not declared in this scope
   34 |         int maxi = INT_MIN;
      |                    ^~~~~~~
main.cpp:5:1: note: 'INT_MIN' is defined in header '<climits>'; did you forget to '#include <climits>'?
    4 | #include <iostream>
  +++ |+#include <climits>
    5 | using namespace std;