Submission #295741

#TimeUsernameProblemLanguageResultExecution timeMemory
295741peti1234Towns (IOI15_towns)C++17
0 / 100
21 ms392 KiB
#include <bits/stdc++.h>
#include "towns.h"
using namespace std;
const int c=112;
int dist[c][c], a, b, h, n, mini;
int tav(int a, int b) {
    if (a==b) return 0;
    if (!dist[a][b]) dist[a][b]=getDistance(a, b), dist[b][a]=dist[a][b];
    return dist[a][b];
}
int tavol(int x) {
    int pos=0, d=0;
    for (int i=0; i<n; i++) {
        int p=tav(0, i);
        if (p>tav(x,pos)) d=p, pos=i;
    }
    return pos;
}
int hubDistance(int q, int w) {
    n=q;
    for (int i=0; i<n; i++) for (int j=0; j<n; j++) dist[i][j]=0;
    a=tavol(0), b=tavol(a), h=tav(a, b), mini=h;
    for (int i=0; i<n; i++) {
        int x=tav(a, 0), y=tav(a, i), z=tav(i, 0), p=(x+y-z)/2;
        mini=min(mini, max(p, h-p));
    }
    return mini;
}

Compilation message (stderr)

towns.cpp: In function 'int tav(int, int)':
towns.cpp:6:21: warning: declaration of 'b' shadows a global declaration [-Wshadow]
    6 | int tav(int a, int b) {
      |                     ^
towns.cpp:5:20: note: shadowed declaration is here
    5 | int dist[c][c], a, b, h, n, mini;
      |                    ^
towns.cpp:6:21: warning: declaration of 'a' shadows a global declaration [-Wshadow]
    6 | int tav(int a, int b) {
      |                     ^
towns.cpp:5:17: note: shadowed declaration is here
    5 | int dist[c][c], a, b, h, n, mini;
      |                 ^
towns.cpp: In function 'int tavol(int)':
towns.cpp:12:16: warning: variable 'd' set but not used [-Wunused-but-set-variable]
   12 |     int pos=0, d=0;
      |                ^
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:19:28: warning: unused parameter 'w' [-Wunused-parameter]
   19 | int hubDistance(int q, int w) {
      |                        ~~~~^
#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...