Submission #359785

#TimeUsernameProblemLanguageResultExecution timeMemory
359785kylych03Towns (IOI15_towns)C++14
0 / 100
23 ms512 KiB
#include "towns.h" #include <bits/stdc++.h> //#include "grader.cpp" using namespace std; int d1[1000]; int d2[1000]; int hubDistance(int N, int sub) { int mx = -1e9, u1, x , u2; for(int i = 1; i < N; i++){ x = getDistance(0,i); if(x > mx){ mx = x; u1 = i; } } d1[0]=mx; mx = -1e9; for(int i = 1; i < N; i++){ if( i== u1) continue; d1[i]=getDistance(u1,i); if(d1[i] > mx){ mx = d1[i]; u2 = i; } } d2[u1] = mx; int diam = mx; int res = diam; for(int i = 0; i < N; i++){ if( i== u1 || i==u2) continue; d2[i]=getDistance(u2,i); int len = (d1[i] + d2[i] - diam ) / 2; len = d2[i] - len; res = min(res, max(len, max(diam - len, (d1[i] + d2[i] - diam ) / 2))); } for(int i = 0 ; i < N ;i++) d1[i] = d2[i] = 0; return res; }

Compilation message (stderr)

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:7:28: warning: unused parameter 'sub' [-Wunused-parameter]
    7 | int hubDistance(int N, int sub) {
      |                        ~~~~^~~
towns.cpp:28:9: warning: 'u1' may be used uninitialized in this function [-Wmaybe-uninitialized]
   28 |  d2[u1] = mx;
      |  ~~~~~~~^~~~
towns.cpp:34:20: warning: 'u2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   34 |   d2[i]=getDistance(u2,i);
      |         ~~~~~~~~~~~^~~~~~
#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...