251432026-02-18 09:18:50BravoRácsháló gráfcpp17Compilation error
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;

int mintav(int d[], bool volt[], int n){
    int m=INT_MAX,mini;
    for(int i=0;i<n;i++){
        if(volt[i]==false && d[i]<=m){
            m=d[i];
            mini=i;
        }
    }
    return mini;
}
void kiir(int d[],int n){
    for(int i=0;i<n;i++){
        cout << d[i] << " ";
    }
}
int main()
{
    int n,m,k;
    //ifstream f("csm.txt");
    cin >> n >> m >> k;
    int b[n][m];
    int x=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            b[i][j]=x;
            x++;
        }
    }
    x--;
    int a[x][x];
    for(int i=0;i<x;i++){
        for(int j=0;j<x;j++){
            a[i][j]=0;
        }
    }
    int x1[4]={1,-1,0,0};
    int y1[4]={0,0,1,-1};
    for(int i=0;i<x;i++){
        int o=0;
        int x2,y2;
        for(int j=0;j<n;j++){
            for(int u=0;u<m;u++){
                if(b[j][u]==i+1){
                    x2=j;
                    y2=u;
                }
            }
        }
        while(o!=4){
            if(x2+x1[o]>=0 && x2+x1[o]<n && y2+y1[o]>=0 && y2+y1[o]<m){
                int z=0;
                int x3=x2+x1[o], y3=y2+y1[o];
                z=b[x3][y3];
                a[i][z-1]=1;
                a[z-1][i]=1;
            }
            o++;
        }
    }
    for(int u=0;u<k;u++){
        int ujx,ujy;
        int b[x];
        int c=INT_MIN;
        cin >> ujx >> ujy;
        a[ujx-1][ujy-1]=1;
        a[ujy-1][ujx-1]=1;
        int d[x];
        bool volt[x];
        for(int i=0;i<x;i++){
            for(int j=0;j<x;j++){
                d[j]=INT_MAX;
                volt[j]=false;
            }
            d[i]=0;
            for(int j=0;j<x-1;j++){
                int u=mintav(d,volt,x);
                volt[u]=true;
                for(int o=0;o<x;o++){
                    if(!volt[o] && a[u][o] && d[u]!=INT_MAX && d[u]+a[u][o]<d[o]){
                        d[o]=d[u]+a[u][o];
                    }
                }
            }
            c=INT_MIN;
            for(int j=0;j<x;j++){
                if(d[j]>c){
                    c=d[j];
                }
            }
            b[i]=c;
        }
        c=INT_MIN;
        for(int i=0;i<x;i++){
            if(b[i]>c){
                c=b[i];
            }
        }
        cout << c << " ";
    }
    return 0;
}
Compilation error
open /var/local/lib/isolate/412/box/a.out: no such file or directory
main.cpp: In function 'int mintav(int*, bool*, int)':
main.cpp:7:11: error: 'INT_MAX' was not declared in this scope
    7 |     int m=INT_MAX,mini;
      |           ^~~~~~~
main.cpp:4:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
    3 | #include <cmath>
  +++ |+#include <climits>
    4 | using namespace std;
main.cpp:11:13: error: 'mini' was not declared in this scope
   11 |             mini=i;
      |             ^~~~
main.cpp:14:12: error: 'mini' was not declared in this scope
   14 |     return mini;
      |            ^~~~
main.cpp: In function 'int main()':
main.cpp:68:15: error: 'INT_MIN' was not declared in this scope
   68 |         int c=INT_MIN;
      |               ^~~~~~~
main.cpp:68:15: note: 'INT_MIN' is defined in header '<climits>'; did you forget to '#include <climits>'?
main.cpp:76:22: error: 'INT_MAX' was not declared in this scope
   76 |                 d[j]=INT_MAX;
      |                      ^~~~~~~
main.cpp:76:22: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
main.cpp:84:53: error: 'INT_MAX' was not declared in this scope
   84 |                     if(!volt[o] && a[u][o] && d[u]!=INT_MAX && d[u]+a[u][o]<d[o]){
      |                                                     ^~~~~~~
main.cpp:84:53: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?