Submission #96570

#TimeUsernameProblemLanguageResultExecution timeMemory
96570rubenvdTowns (IOI15_towns)C++14
0 / 100
18 ms632 KiB
#include <bits/stdc++.h> #include "towns.h" using namespace std; /*int dis[110][110]; int getDistance( int i, int j ){ return dis[i][j]; }*/ int hubDistance( int n, int sub ){ int m[n][n], s, t, maxd = -1; for( int i = 0; i < n; ++i ) for( int j = 0; j < n; ++j ) m[i][j] = -1; int maxi = -1; for( int i = 0; i < n; ++i ){ int disI = getDistance(i, 0); m[0][i] = m[i][0] = disI; if( disI > maxi ){ maxi = disI; s = i; } } for( int i = 1; i < n; ++i ){ int disT = getDistance(s, i); m[s][i] = m[i][s] = disT; if( disT > maxd ){ maxd = disT; t = i; } } int mini = 1e7+5; for( int i = 0; i < n; ++i ){ if( i != s && i != t ){ int z = (getDistance(i, t) - m[i][s] - maxd)/-2; int x = maxd - z, y = m[i][s] - z; mini = min(mini, max(x, z)); } } return mini; } /*int main(){ int sb, tc, n; cin >> sb >> tc >> n; for( int i = 0; i < n; ++i ){ for( int j = 0; j < n; ++j ){ cin >> dis[i][j]; } } cout << hubDistance(n, sb) << endl; return 0; }*/

Compilation message (stderr)

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:39:22: warning: unused variable 'y' [-Wunused-variable]
    int x = maxd - z, y = m[i][s] - z; 
                      ^
towns.cpp:10:29: warning: unused parameter 'sub' [-Wunused-parameter]
 int hubDistance( int n, int sub ){
                             ^~~
towns.cpp:38:24: warning: 't' may be used uninitialized in this function [-Wmaybe-uninitialized]
    int z = (getDistance(i, t) - m[i][s] - maxd)/-2;
             ~~~~~~~~~~~^~~~~~
towns.cpp:37:9: warning: 's' may be used uninitialized in this function [-Wmaybe-uninitialized]
   if( i != s && i != t ){
       ~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...