이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "towns.h"
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
ll n;
map<pii,ll> distMem;
ll distance(ll a,ll b){
return getDistance(a,b);
pii p = {min(a,b),max(a,b)};
if(distMem.find(p)!=distMem.end()) return distMem[p];
return distMem[p] = getDistance(a,b);
}
pii getFurthest(ll v){
ll furthest = 0;
ll mx = 0;
rep(i,0,n){
ll dist = distance(v,i);
if(dist>mx){
mx = dist;
furthest = i;
}
}
return {furthest,mx};
}
int hubDistance(int N, int sub) {
n = N;
ll diaA = getFurthest(0).first;
pii tmp = getFurthest(diaA);
ll diaB = tmp.first;
ll diameter = tmp.second;
map<ll,ll> pointsOnDiameter;
rep(i,0,n){
if(i==diaA||i==diaB) continue;
ll distA = distance(i,diaA);
ll distB = distance(i,diaB);
ll distFromDiameter = (distA+distB-diameter)/2;
pointsOnDiameter[distA-distFromDiameter]++;
}
ll minR = 1e18;
ll center = 0;
trav(x,pointsOnDiameter){
ll currR = max(x.first,diameter-x.first);
if(currR<minR){
center = x.first;
minR = currR;
}
}
return minR;
//if(pointsOnDiameter[center]<=n/2) return
}
컴파일 시 표준 에러 (stderr) 메시지
towns.cpp: In function 'll distance(ll, ll)':
towns.cpp:21:27: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
return getDistance(a,b);
^
towns.cpp:21:27: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
towns.cpp:24:40: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
return distMem[p] = getDistance(a,b);
^
towns.cpp:24:40: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:70:12: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
return minR;
^~~~
towns.cpp:61:8: warning: variable 'center' set but not used [-Wunused-but-set-variable]
ll center = 0;
^~~~~~
towns.cpp:40:28: warning: unused parameter 'sub' [-Wunused-parameter]
int hubDistance(int N, int sub) {
^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |