Submission #889907

# Submission time Handle Problem Language Result Execution time Memory
889907 2023-12-20T09:32:14 Z abcvuitunggio Towns (IOI15_towns) C++17
25 / 100
16 ms 1372 KB
#include "towns.h"
#include <bits/stdc++.h>
using namespace std;
int dist[111][111];
int d(int u, int v){
    if (u==v)
        return 0;
    if (u>v)
        swap(u,v);
    if (dist[u][v])
        return dist[u][v];
    return dist[u][v]=getDistance(u,v);
}
int hubDistance(int N, int sub){
    memset(dist,0,sizeof(dist));
    pair <int, int> mx={0,-1};
    for (int i=0;i<N;i++)
        mx=max(mx,{d(0,i),i});
    int u=mx.second;
    mx={0,-1};
    for (int i=0;i<N;i++)
        mx=max(mx,{d(u,i),i});
    int v=mx.second;
	int R=1e9;
	for (int i=0;i<N;i++)
        R=min(R,abs(d(i,u)-d(i,v)));
	return (R+d(u,v))/2;
}

Compilation message

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:14:28: warning: unused parameter 'sub' [-Wunused-parameter]
   14 | int hubDistance(int N, int sub){
      |                        ~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1116 KB Output is correct
2 Correct 9 ms 860 KB Output is correct
3 Correct 0 ms 436 KB Output is correct
4 Correct 12 ms 856 KB Output is correct
5 Correct 12 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1116 KB Output is correct
2 Correct 9 ms 860 KB Output is correct
3 Correct 12 ms 860 KB Output is correct
4 Correct 12 ms 900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 872 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 1372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 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 11 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -