이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "towns.h"
#include <bits/stdc++.h>
#define lp(i,a,b) for(int i = a ; i < b ; i++)
#define ff first
#define ss second
#define pii pair<int,int>
#define MAXN 120
const int inf = 1e9 + 5 ;
using namespace std;
//
int N , A , B , R = inf, man;
int perp[MAXN] ;
int d[MAXN][MAXN] ;
//
void query( int x )
{ lp(i,0,N) d[x][i] = getDistance(x,i) ;}
int findMax( int x )
{ return max_element(d[x] , d[x] + N) - d[x] ; }
int findPerpendicular( int x )
{ return (d[A][x] + d[B][x] - d[A][B])/2 ; }
void findRadio()
{
lp(i,0,N)
{
int fresh = max( d[A][i] , d[B][i] ) - perp[i];
if( fresh < R ) R = fresh , man = d[A][i] > d[B][i] ? A : B ;
}
}
int sub4()
{
int l = 0 , r = 0 , mid = 0 ;
lp(i,0,N)
{
int k = d[man][i] - perp[i] ;
if( k < R ) l ++ ;
else if ( k > R ) r ++ ;
else mid ++ ;
}
if(l>N/2 or r > N/2 or mid > N/2) return -R ;
return R ;
}
int hubDistance( int n , int sub)
{
N = n ;
query(0) ;
A = findMax(0) ;
query(A) ;
B = findMax(A) ;
query(B) ;
lp(i,0,n) perp[i] = findPerpendicular(i) ;
findRadio() ;
if( sub < 3 ) return R ;
if( sub == 4 ) return sub4() ;
}
컴파일 시 표준 에러 (stderr) 메시지
towns.cpp: In function 'int findMax(int)':
towns.cpp:24:39: warning: conversion to 'int' from 'long int' may alter its value [-Wconversion]
{ return max_element(d[x] , d[x] + N) - d[x] ; }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:64:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# | 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... |