제출 #133665

#제출 시각아이디문제언어결과실행 시간메모리
133665Mahdi_Jfri도시들 (IOI15_towns)C++14
25 / 100
21 ms476 KiB
#include "towns.h"
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back

const int maxn = 1e2 + 20;

int h[2][maxn];

int hubDistance(int n, int sub)
{
	memset(h , 0 , sizeof h);
	for(int i = 1; i < n; i++)
		h[0][i] = getDistance(0 , i);

	int a = max_element(h[0] , h[0] + n) - h[0];

	memset(h[0] , 0 , sizeof h[0]);
	for(int i = 0; i < n; i++)
		if(i != a)
			h[0][i] = getDistance(a , i);

	int b = max_element(h[0] , h[0] + n) - h[0];
	for(int i = 0; i < n; i++)
		if(i != b)
			h[1][i] = getDistance(b , i);

	vector<int> val;
	int ans = 1e9;
	for(int i = 0; i < n; i++)
	{
		int k = h[0][i] - h[1][i] + h[0][b];
		while(k % 2);

		k /= 2;
		ans = min(ans , max(k , h[0][b] - k));
	}

	return ans;
}











컴파일 시 표준 에러 (stderr) 메시지

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:19:39: warning: conversion to 'int' from 'long int' may alter its value [-Wconversion]
  int a = max_element(h[0] , h[0] + n) - h[0];
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
towns.cpp:26:39: warning: conversion to 'int' from 'long int' may alter its value [-Wconversion]
  int b = max_element(h[0] , h[0] + n) - h[0];
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
towns.cpp:13:28: warning: unused parameter 'sub' [-Wunused-parameter]
 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...