Submission #798493

#TimeUsernameProblemLanguageResultExecution timeMemory
798493Username4132Towns (IOI15_towns)C++14
0 / 100
12 ms1092 KiB
#include "towns.h" #include<iostream> using namespace std; #define forn(i, n) for(int i=0; i<(int)n; ++i) #define forsn(i, s, n) for(int i=s; i<(int)n; ++i) const int MAXN = 120; int n, d1[MAXN], d2[MAXN]; int hubDistance(int N, int sub) { n=N; int mx = -1, u, v; forsn(i, 1, n){ int dis = getDistance(0, i); if(dis>mx) mx=dis, u=i; } mx=-1; forn(i, n) if(i!=u){ d1[i]=getDistance(u, i); if(d1[i]>mx) mx=d1[i], v=i; } int mn=1000000000; forn(i, n) if(i!=v){ d2[i]=getDistance(v, i); mn=min(mn, abs(d1[i]-d2[i])); } return (d1[v]+mn)>>1; }

Compilation message (stderr)

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:10:28: warning: unused parameter 'sub' [-Wunused-parameter]
   10 | int hubDistance(int N, int sub) {
      |                        ~~~~^~~
towns.cpp:27:14: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
   27 |  return (d1[v]+mn)>>1;
      |          ~~~~^
towns.cpp:19:20: warning: 'u' may be used uninitialized in this function [-Wmaybe-uninitialized]
   19 |   d1[i]=getDistance(u, 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...