Submission #1018436

# Submission time Handle Problem Language Result Execution time Memory
1018436 2024-07-10T04:16:03 Z huutuan Towns (IOI15_towns) C++14
25 / 100
14 ms 1116 KB
#include "towns.h"

#include <bits/stdc++.h>

using namespace std;

int d1[200], d2[200];

int hubDistance(int N, int sub) {
   int u=0, dis=0;
   for (int i=1; i<N; ++i){
      int d=getDistance(0, i);
      if (d>dis){
         dis=d;
         u=i;
      }
   }
   dis=0;
   int v=u;
   for (int i=0; i<N; ++i) if (i!=u){
      int d=getDistance(u, i);
      d1[i]=d;
      if (d>dis){
         dis=d;
         v=i;
      }
   }
   int ans=1e9;
   for (int i=0; i<N; ++i) if (i!=u && i!=v){
      d2[i]=getDistance(v, i);
      int common=(d1[i]+d2[i]-dis)/2;
      int dl=d1[i]-common, dr=d2[i]-common;
      ans=min(ans, max(dl, dr));
   }
   return ans;
}

Compilation message

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:9:28: warning: unused parameter 'sub' [-Wunused-parameter]
    9 | int hubDistance(int N, int sub) {
      |                        ~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 860 KB Output is correct
2 Correct 8 ms 936 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 9 ms 980 KB Output is correct
5 Correct 10 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 860 KB Output is correct
2 Correct 8 ms 860 KB Output is correct
3 Correct 10 ms 980 KB Output is correct
4 Correct 11 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 1116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 828 KB Output isn't correct
2 Halted 0 ms 0 KB -