Submission #1086987

#TimeUsernameProblemLanguageResultExecution timeMemory
1086987the_coding_poohTowns (IOI15_towns)C++14
0 / 100
12 ms860 KiB
#include "towns.h" #include <bits/stdc++.h> #define uwu return 0; using namespace std; map <pair<int, int>, long long> mp; long long dis(int a, int b){ if(a == b) return 0; if(a > b) swap(a, b); if(mp.count({a, b})) return mp[{a, b}]; return mp[{a, b}] = getDistance(a, b); } int hubDistance(int N, int sub) { int diam_u, diam_v; long long mx = 0; for(int i = 1; i < N; i++){ if(dis(0, i) > mx){ mx = dis(0, i); diam_u = i; } } mx = 0; for(int i = 0; i < N; i++){ if(dis(diam_u, i) > mx){ mx = dis(diam_u, i); diam_v = i; } } long long diam = dis(diam_u, diam_v), R; R = diam; for(int i = 0; i < N; i++){ long long a = dis(diam_u, i), b = dis(diam_v, i), delta; delta = (a + b - diam) / 2; R = min(R, max(a - delta, b - delta)); } return R; }

Compilation message (stderr)

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:43:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   43 |  return R;
      |         ^
towns.cpp:19:28: warning: unused parameter 'sub' [-Wunused-parameter]
   19 | int hubDistance(int N, int sub) {
      |                        ~~~~^~~
towns.cpp:36:22: warning: 'diam_u' may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |  long long diam = dis(diam_u, diam_v), R;
      |                   ~~~^~~~~~~~~~~~~~~~
towns.cpp:36:22: warning: 'diam_v' may be used uninitialized in this function [-Wmaybe-uninitialized]
#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...