Submission #1167704

#TimeUsernameProblemLanguageResultExecution timeMemory
1167704madtCommuter Pass (JOI18_commuter_pass)C++20
Compilation error
0 ms0 KiB
#include <iostream>

using namespace std;

long long gr[400][400];

int main()
{
    int n=0, m=0;
    int s=0, t=0;
    int u=0, v=0;
    cin>>n>>m>>s>>t>>u>>v;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            gr[i][j]=INT_MAX;
            if(i==j)
                gr[i][j]=0;
        }
    }
    for(int i=0; i<m; i++)
    {
        int a=0, b=0;
        long long c=0;
        cin>>a>>b>>c;
        gr[a][b]=c;
        gr[b][a]=c;
    }


    for(int i=1; i <= n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            for(int p=1; p<=n; p++)
            {
                if(gr[j][i]!=INT_MAX && gr[p][i]!= INT_MAX)
                {
                    gr[j][p]=min(gr[p][j], gr[i][p] + gr[i][j]);
                    gr[p][j]=gr[j][p];
                    //cout<<j<<"-->"<<p<<" "<<gr[j][p]<<endl;
                }
            }
        }
    }
    //cout<<gr[u][v]<<' '<<gr[s][t]<<endl;
    long long mn=gr[u][v];
    for(int i=1; i<=n; i++)
        for(int j=1; j<=n; j++)
            if(gr[s][t]==(gr[s][i]+gr[i][j]+gr[j][t]) || gr[s][t]==(gr[s][j]+gr[i][j]+gr[i][t]))
            {
                mn=min(mn, min(gr[u][i] + gr[v][j], gr[u][j] + gr[v][i]));
            }

    cout<<mn<<endl;
    return 0;
}

Compilation message (stderr)

commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:17:22: error: 'INT_MAX' was not declared in this scope
   17 |             gr[i][j]=INT_MAX;
      |                      ^~~~~~~
commuter_pass.cpp:2:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
    1 | #include <iostream>
  +++ |+#include <climits>
    2 | 
commuter_pass.cpp:38:30: error: 'INT_MAX' was not declared in this scope
   38 |                 if(gr[j][i]!=INT_MAX && gr[p][i]!= INT_MAX)
      |                              ^~~~~~~
commuter_pass.cpp:38:30: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?