Submission #387403

#TimeUsernameProblemLanguageResultExecution timeMemory
387403alishahali1382Towns (IOI15_towns)C++14
25 / 100
22 ms1004 KiB
#include "towns.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define debug(x) {cerr<<#x<<"="<<x<<"\n";}
#define debugp(p) {cerr<<#p<<"={"<<p.first<<", "<<p.second<<"}\n";}
#define debug2(x, y) {cerr<<#x<<", "<<#y<<" = "<<x<<", "<<y<<"\n";}
#define pb push_back
#define all(x) x.begin(), x.end()

const int inf=1000000010;
const int N=120;

int n, m, k, ans;
int D[N][N];

int ask(int i, int j){
	if (i==j) return 0;
	if (i>j) swap(i, j);
	if (D[i][j]==-1) D[i][j]=getDistance(i, j);
	return D[i][j];
}

int hubDistance(int n, int sub){
	memset(D, -1, sizeof(D));
	int X=0, Y=0;
	for (int i=1; i<n; i++) if (ask(0, i)>ask(0, X)) X=i;
	for (int i=1; i<n; i++) if (ask(X, i)>ask(X, Y)) Y=i;
	ans=inf;
	for (int i=0; i<n; i++){
		int a=(ask(X, i)+ask(X, Y)-ask(Y, i))/2;
		int b=ask(X, Y)-a, c=ask(X, i)-a;
		ans=min(ans, max(a, b));
	}
	return ans;
}

Compilation message (stderr)

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:26:31: warning: declaration of 'n' shadows a global declaration [-Wshadow]
   26 | int hubDistance(int n, int sub){
      |                               ^
towns.cpp:16:5: note: shadowed declaration is here
   16 | int n, m, k, ans;
      |     ^
towns.cpp:34:22: warning: unused variable 'c' [-Wunused-variable]
   34 |   int b=ask(X, Y)-a, c=ask(X, i)-a;
      |                      ^
towns.cpp:26:28: warning: unused parameter 'sub' [-Wunused-parameter]
   26 | int hubDistance(int n, 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...