Submission #60167

# Submission time Handle Problem Language Result Execution time Memory
60167 2018-07-23T20:04:40 Z istlemin Towns (IOI15_towns) C++14
0 / 100
37 ms 572 KB
#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;

pii getFurthest(ll v){
	ll furthest = 0;
    ll mx = 0;
    rep(i,1,n){
		ll dist = getDistance(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 = getDistance(i,diaA);
        ll distB = getDistance(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
}

Compilation message

towns.cpp: In function 'pii getFurthest(ll)':
towns.cpp:21:28: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
   ll dist = getDistance(v,i);
                            ^
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:42:38: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
         ll distA = getDistance(i,diaA);
                                      ^
towns.cpp:43:38: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
         ll distB = getDistance(i,diaB);
                                      ^
towns.cpp:60:12: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
     return minR;
            ^~~~
towns.cpp:51:8: warning: variable 'center' set but not used [-Wunused-but-set-variable]
     ll center = 0;
        ^~~~~~
towns.cpp:30:28: warning: unused parameter 'sub' [-Wunused-parameter]
 int hubDistance(int N, int sub) {
                            ^~~
# Verdict Execution time Memory Grader output
1 Correct 23 ms 504 KB Output is correct
2 Correct 21 ms 560 KB Output is correct
3 Correct 3 ms 560 KB Output is correct
4 Incorrect 27 ms 572 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 572 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 572 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 572 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 572 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 572 KB Output isn't correct
2 Halted 0 ms 0 KB -