Submission #1030357

# Submission time Handle Problem Language Result Execution time Memory
1030357 2024-07-22T03:33:25 Z pcc Towns (IOI15_towns) C++17
0 / 100
1000 ms 544 KB
#include "towns.h"
#include <bits/stdc++.h>
using namespace std;

const int mxn = 120;

int dp[mxn][mxn];

int ask(int a,int b){
	if(a == b)return dp[a][b] = 0;
	if(dp[a][b] != -1)return dp[a][b];
	else return dp[a][b] = dp[b][a] = getDistance(a,b);
}

int tocen(int a,int b,int c){
	return ((ask(a,b)+ask(a,c)-ask(b,c))>>1);
}

int hubDistance(int N, int sub) {
	memset(dp,-1,sizeof(dp));
	int ans = 1e9;
	for(int i = 0;i<N;i++){
		for(int j = 0;j<N;j++){
			for(int k = 0;k<N;k++){
				if(i == j||j == k||i == k)continue;
				int d1 = tocen(i,j,k);
				int d2 = tocen(j,i,k);
				int d3 = tocen(k,i,j);
				int tans = max({d1,d2,d3});
				for(int l = 0;l<N;l++){
					if(l == i||l == j||l == k)continue;
					if(tocen(i,j,l) == d1&&tocen(j,i,l) == d2)tans = max(tans,tocen(l,i,j));
					if(tocen(i,k,l) == d1&&tocen(k,i,l) == d3)tans = max(tans,tocen(l,i,k));
					if(tocen(j,k,l) == d2&&tocen(k,j,l) == d3)tans = max(tans,tocen(l,j,k));
				}
				ans = min(ans,tans);
			}
		}
	}
	return ans;
}

Compilation message

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:19:28: warning: unused parameter 'sub' [-Wunused-parameter]
   19 | int hubDistance(int N, int sub) {
      |                        ~~~~^~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 544 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1045 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -