Submission #210962

#TimeUsernameProblemLanguageResultExecution timeMemory
210962autumn_eelTowns (IOI15_towns)C++14
35 / 100
29 ms548 KiB
#include "towns.h" #include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; int d[150][150]; int dist(int i,int j){ if(i==j)return 0; if(i>j)swap(i,j); if(d[i][j]!=-1)return d[i][j]; int x=getDistance(i,j); return d[i][j]=x; } int hubDistance(int N, int sub) { memset(d,-1,sizeof(d)); int Max=0,s=-1; rep(i,N){ if(Max<dist(0,i)){ Max=dist(0,i); s=i; } } Max=0;int t=-1; rep(i,N){ if(Max<dist(s,i)){ Max=dist(s,i); t=i; } } int Min=INT_MAX,id=-1; map<int,vector<int>>mp; rep(i,N){ int x=dist(s,i),y=dist(t,i); int z=(x+y-Max)/2; int a=x-z,b=y-z; mp[a].push_back(i); if(Min>max(a,b)){ Min=max(a,b); id=a; } } if(sub<=2)return Min; int c1=0,c2=0; for(auto p:mp){ if(p.first<id)c1+=p.second.size(); if(p.first>id)c2+=p.second.size(); } if(c1>N/2||c2>N/2)return -Min; vector<vector<int>>vs; for(int v:mp[id]){ bool flag=false; for(auto&V:vs){ if(dist(s,V[0])+dist(s,v)-2*id!=dist(V[0],v)){ V.push_back(v);flag=true; if(V.size()>N/2)return -Min; break; } } if(!flag)vs.push_back({v}); } return Min; }

Compilation message (stderr)

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:46:35: warning: conversion to 'int' from 'std::vector<int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
   if(p.first<id)c1+=p.second.size();
                                   ^
towns.cpp:47:35: warning: conversion to 'int' from 'std::vector<int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
   if(p.first>id)c2+=p.second.size();
                                   ^
towns.cpp:56:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(V.size()>N/2)return -Min;
        ~~~~~~~~^~~~
#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...