Language: C++

#include<iostream>
#include<cstring>
using namespace std;

int time[10][10];
int town;
int INF = 9999;

void fw(){
    for(int k = 0; k <= town; k++){
        for(int i = 0; i <= town; i++){
            for(int j = 0; j <= town; j++){
                time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
            }
        }
    }
}

void solve(){
    int ret, mintime = 1<<21;
    for(int i = 0; i <= town; i++){
        int candidate = 0;
        for(int j = 0; j <= town; j++){
            candidate += time[i][j];
        }
        if(candidate < mintime){
            mintime = candidate;
            ret = i;
        }
    }

    cout << ret << " " << mintime << endl;
}

int main(){
    while(1){
        int n;
        cin >> n;

        if(n == 0)  break;

        town = 0;
        memset(time, INF, sizeof(time));
        for(int i = 0; i < 10; i++) time[i][i] = 0;

        int a, b, c;
        while(n-- > 0){
            cin >> a >> b >> c;
            time[a][b] = time[b][a] = c;
            town = max(town, max(a,b));
        }

        fw();
        solve();
    }
    return 0;
}


Compiler output:
a.cc:5:16: error: 'int time [10][10]' redeclared as different kind of entity
    5 | int time[10][10];
      |                ^
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'void fw()':
a.cc:13:23: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   13 |                 time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                       ^
a.cc:13:26: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   13 |                 time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                          ^
a.cc:13:40: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   13 |                 time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                        ^
a.cc:13:43: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   13 |                 time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                           ^
a.cc:13:52: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   13 |                 time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                                    ^
a.cc:13:55: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   13 |                 time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                                       ^
a.cc:13:65: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   13 |                 time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                                                 ^
a.cc:13:68: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   13 |                 time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                                                    ^
a.cc:13:57: error: invalid operands of types 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} to binary 'operator+'
   13 |                 time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                              ~~~~~~~~~~ ^ ~~~~~~~~~~
      |                                                       |            |
      |                                                       |            time_t(time_t*) noexcept {aka long int(long int*) noexcept}
      |                                                       time_t(time_t*) noexcept {aka long int(long int*) noexcept}
a.cc: In function 'void solve()':
a.cc:24:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   24 |             candidate += time[i][j];
      |                                ^
a.cc:24:35: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   24 |             candidate += time[i][j];
      |                                   ^
a.cc:24:23: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   24 |             candidate += time[i][j];
      |             ~~~~~~~~~~^~~~~~~~~~~~~
a.cc:24:23: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'int' [-fpermissive]
   24 |             candidate += time[i][j];
      |             ~~~~~~~~~~^~~~~~~~~~~~~
      |                       |
      |                       time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}
a.cc: In function 'int main()':
a.cc:43:34: error: ISO C++ forbids applying 'sizeof' to an expression of function type [-fpermissive]
   43 |         memset(time, INF, sizeof(time));
      |                                 ~^~~~~
a.cc:43:16: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'void*' [-fpermissive]
   43 |         memset(time, INF, sizeof(time));
      |                ^~~~
      |                |
      |                time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}
In file included from /usr/include/c++/14/cstring:43,
                 from a.cc:2:
/usr/include/string.h:61:28: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |                      ~~~~~~^~~
a.cc:44:43: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   44 |         for(int i = 0; i < 10; i++) time[i][i] = 0;
      |                                           ^
a.cc:44:46: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   44 |         for(int i = 0; i < 10; i++) time[i][i] = 0;
      |                                              ^
a.cc:44:48: error: assignment of read-only location '*(time + (((sizetype)i) * 2))'
   44 |         for(int i = 0; i < 10; i++) time[i][i] = 0;
      |                                     ~~~~~~~~~~~^~~
a.cc:49:19: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   49 |             time[a][b] = time[b][a] = c;
      |                   ^
a.cc:49:22: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   49 |             time[a][b] = time[b][a] = c;
      |                      ^
a.cc:49:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   49 |             time[a][b] = time[b][a] = c;
      |                                ^
a.cc:49:35: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   49 |             time[a][b] = time[b][a] = c;
      |                                   ^
a.cc:49:37: error: assignment of read-only location '*(time + (((sizetype)b) + ((sizetype)a)))'
   49 |             time[a][b] = time[b][a] = c;
      |                          ~~~~~~~~~~~^~~