Submission #382695

#TimeUsernameProblemLanguageResultExecution timeMemory
382695MatheusLealVTowns (IOI15_towns)C++17
25 / 100
28 ms1260 KiB
#include "towns.h" #include <bits/stdc++.h> #define f first #define s second using namespace std; typedef pair<int, int> pii; int n; int dist[500][500]; int hubDistance(int nn, int sub) { n = nn; pii maior = {-1,-1}; for(int i = 1; i < n; i++){ dist[0][i] = getDistance(0, i); maior=max(maior, {dist[0][i], i}); } pii maior2 ={-1,-1}; for(int i = 0; i < n; i++){ dist[maior.s][i] = getDistance(maior.s, i); maior2 = max(maior2, {dist[maior.s][i], i}); } for(int i = 0; i < n; i++){ dist[maior2.s][i] = getDistance(maior2.s, i); } int diametro = maior2.f, R = (int)1e9; for(int i = 0; i < n; i++){ int x1 = dist[maior.s][i], x2 = dist[maior2.s][i]; //x1-d1 = x2-d2 ->d1-d2 = x1-x2 //d1+d2=diametro - >2*d1 = x1-x2+diametro int d1 = (x1-x2+diametro)/2; int d2 = diametro-d1; R=min(R, max(d1,d2)); } return R; }

Compilation message (stderr)

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:9:29: warning: unused parameter 'sub' [-Wunused-parameter]
    9 | int hubDistance(int nn, int sub) {
      |                         ~~~~^~~
#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...