Submission #433339

#TimeUsernameProblemLanguageResultExecution timeMemory
433339timmyfengTowns (IOI15_towns)C++17
25 / 100
25 ms952 KiB
#include <bits/stdc++.h> using namespace std; #include "towns.h" const int N = 110; int dist_0[N], dist_u[N], pos[N]; int hubDistance(int n, int subtask) { for (int i = 1; i < n; ++i) { dist_0[i] = getDistance(0, i); } int u = max_element(dist_0, dist_0 + n) - dist_0; dist_u[0] = dist_0[u]; for (int i = 1; i < n; ++i) { dist_u[i] = u == i ? 0 : getDistance(u, i); } int v = max_element(dist_u, dist_u + n) - dist_u; pos[0] = (dist_0[u] - dist_0[v] + dist_u[v]) / 2; for (int i = 1; i < n; ++i) { pos[i] = min(pos[0], (dist_0[u] - dist_0[i] + dist_u[i]) / 2); } int ans = INT_MAX; for (int i = 0; i < n; ++i) { ans = min(ans, max(pos[i], dist_u[v] - pos[i])); } return ans; }

Compilation message (stderr)

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:15:45: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   15 |     int u = max_element(dist_0, dist_0 + n) - dist_0;
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
towns.cpp:21:45: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   21 |     int v = max_element(dist_u, dist_u + n) - dist_u;
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
towns.cpp:10:28: warning: unused parameter 'subtask' [-Wunused-parameter]
   10 | int hubDistance(int n, int subtask) {
      |                        ~~~~^~~~~~~
#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...